# Transactions

Transactions metrics are always related to an App. This means that all endpoints have the same root so it could be helpful to wrap your api call under the same base URI:

&#x20;`https://app.inspector.dev`**`/api/apps/:id`**

## Transactions List

<mark style="color:green;">`POST`</mark> `/api/apps/:id/transactions`

Get the list of transactions in the given interval.

#### Path Parameters

| Name                                 | Type    | Description      |
| ------------------------------------ | ------- | ---------------- |
| id<mark style="color:red;">\*</mark> | Integer | App's identifier |

#### Headers

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

#### Request Body

| Name                                           | Type   | Description                             |
| ---------------------------------------------- | ------ | --------------------------------------- |
| filter.start<mark style="color:red;">\*</mark> | String | ISO-8601 date format                    |
| filter.end                                     | String | ISO-8601 date format                    |
| filter.hosts                                   | Array  | Filter the transactions list by servers |
| filter.query\_string                           | String | Filter by transaction's name            |

{% tabs %}
{% tab title="200 " %}

```
[
    {
        name: "request",
        transactions: [
            {
                type: "request",
                duration: 42.8,
                group_hash: "4fbb4fa36bad346bbe8a26827a244e70",
                hash: "37d6f2a1bd370759ff46cc63266603b81b60da4774bfa9a72af7bf26ba3d4fb1",
                host: {hostname: "307510.cloudwaysapps.com", ip: "127.0.0.1"},
                memory_peak: 16.98,
                name: "GET /api",
                project_id: 389,
                result: "success",
                timestamp: "2024-10-04 16:52:02",
                doc_count: 60,
                performance: [
                    {label: "2021-02-03 16:00", value: 38, doc_count: 61},
                    {label: "2021-02-03 17:00", value: 5, doc_count: 63},
                    {label: "2021-02-03 18:00", value: 65, doc_count: 123},
                    {label: "2021-02-03 19:00", value: 34, doc_count: 11},
                    {label: "2021-02-03 20:00", value: 43, doc_count: 110},
                    {label: "2021-02-03 21:00", value: 2, doc_count: 123},
                    ...
                ]
            },
            
            {...},
        ],
    },
    
    {
        name: "command",
        transactions: [...],
    },
    
    {...}
]
```

{% endtab %}
{% endtabs %}

## Transaction occurrences

<mark style="color:green;">`POST`</mark> `/api/apps/:id/transactions/:group_hash/occurrences`

Get the last occurrences of a specific transaction.

#### Path Parameters

| Name                                          | Type    | Description                        |
| --------------------------------------------- | ------- | ---------------------------------- |
| id<mark style="color:red;">\*</mark>          | Integer | Project's Identifier               |
| group\_hash<mark style="color:red;">\*</mark> | String  | The transaction group's identifier |

#### Query Parameters

| Name                                           | Type    | Description                                                                                              |
| ---------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------- |
| filter.start<mark style="color:red;">\*</mark> | Date    | ISO-8601 date format                                                                                     |
| filter.end                                     | Date    | ISO-8601 date format                                                                                     |
| filter.from                                    | Integer | The results are paginated 25 elements at a time. Use **from** to advance the starting point of the list. |

#### Headers

| Name                                             | Type   | Description |
| ------------------------------------------------ | ------ | ----------- |
| Authentication<mark style="color:red;">\*</mark> | String | API key     |

{% tabs %}
{% tab title="200: OK An array of items." %}

```javascript
[
    {
        duration: 164.22,
        group_hash: "7d8647ff14a84a458b0f6xxxxxxxxxxxx",
        memory_peak: 19.09,
        name: "GET /api/users",
        result: "success",
        timestamp: "2022-04-19 14:10:04",
        type: "process"
    },
    {
        ...
    },
]
```

{% endtab %}
{% endtabs %}

## Performance Distribution

<mark style="color:green;">`POST`</mark> `/api/apps/:id/transactions/:group_hash/time-distribution`

Performance distribution of a specific transaction.

#### Path Parameters

| Name                                          | Type    | Description                    |
| --------------------------------------------- | ------- | ------------------------------ |
| id<mark style="color:red;">\*</mark>          | integer | Project's identifier           |
| group\_hash<mark style="color:red;">\*</mark> | String  | Transaction group's identifier |

#### Headers

| Name                                             | Type   | Description |
| ------------------------------------------------ | ------ | ----------- |
| Authentication<mark style="color:red;">\*</mark> | string | API key     |

#### Request Body

| Name                                           | Type | Description          |
| ---------------------------------------------- | ---- | -------------------- |
| filter.start<mark style="color:red;">\*</mark> | Date | ISO-8601 date format |
| filter.end                                     | Date | ISO-8601 date format |

{% tabs %}
{% tab title="200 " %}

```json
[
  {
    "ms": 0,
    "occurrences": 29
  },
  {
    "ms": 152,
    "occurrences": 30
  },
  {
    "ms": 304,
    "occurrences": 1
  },
  {
    "ms": 456,
    "occurrences": 0
  },
  {
    "ms": 608,
    "occurrences": 0
  },
  {
    "ms": 760,
    "occurrences": 0
  },
  {
    "ms": 912,
    "occurrences": 0
  },
  {
    "ms": 1064,
    "occurrences": 0
  },
  {
    "ms": 1216,
    "occurrences": 0
  },
  {
    "ms": 1368,
    "occurrences": 0
  },
  {
    "ms": 1520,
    "occurrences": 0
  },
  {
    "ms": 1672,
    "occurrences": 0
  },
  {
    "ms": 1824,
    "occurrences": 0
  },
  {
    "ms": 1976,
    "occurrences": 0
  },
  {
    "ms": 2128,
    "occurrences": 0
  },
  {
    "ms": 2280,
    "occurrences": 0
  },
  {
    "ms": 2432,
    "occurrences": 0
  },
  {
    "ms": 2584,
    "occurrences": 0
  },
  {
    "ms": 2736,
    "occurrences": 0
  },
  {
    "ms": 2888,
    "occurrences": 0
  },
  {
    "ms": 3040,
    "occurrences": 0
  },
  {
    "ms": 3192,
    "occurrences": 0
  },
  {
    "ms": 5776,
    "occurrences": 1
  },
  {
    "ms": 5928,
    "occurrences": 5
  },
  {
    "ms": 6080,
    "occurrences": 9
  },
]
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
You can get the **group\_hash** value of a specific transaction in the address bar of your browser navigating the detail page of the transaction of your interest.
{% endhint %}

![](https://2873457055-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LQ51SrLj6qvIRejC1XD%2Fuploads%2FozUqYxyA3Zj7sGcrfNPT%2Fgroup_hash-url-parameter.png?alt=media\&token=74e02fa2-797a-41f5-8d3f-4d4be0a16598)
