# Query recordings

`POST /v1/recordings/query`

Required scope: `recordings:read`

Meetings and phone calls, including the ones sent with `POST /v1/analyses`. The body is a table query: `columns`, `filters` (`{ field, op, value }`), `sort` (up to 5 keys), `group_by`, `cursor` and `limit`. `GET /v1/fields?object=` lists the columns you can ask for, filter, sort and group by.

## Request body (application/json)

- `columns` (string[] or null, optional)
- `cursor` (string or null, optional)
- `filters` (object[] or null, optional)
  - `field` (string, required)
  - `op` (string, required) Allowed values: `"eq"`, `"neq"`, `"contains"`, `"starts_with"`, `"in"`, `"gt"`, `"gte"`, `"lt"`, `"lte"`, `"is_empty"`, `"is_not_empty"`.
  - `value` (string | integer | number | boolean | string[] or null, optional): What the field is compared with; a list for `in`.
- `group_by` (string or null, optional)
- `is_archived` (boolean, optional) Default: `false`.
- `limit` (integer, optional) Default: `50`.
- `offset` (integer or null, optional)
- `sort` (object[] or null, optional)
  - `direction` (string, optional) Allowed values: `"asc"`, `"desc"`. Default: `"asc"`.
  - `field` (string, required)
- `view_id` (string or null, optional)

## Responses

- `200`: Successful Response
- `400`: The request is not valid.
- `401`: Not signed in, or the credentials are not valid.
- `402`: The balance is too low.
- `403`: Not allowed to do this.
- `404`: Not found.
- `409`: Conflicts with the current state.
- `413`: The request body is too large.
- `415`: The content type is not supported.
- `422`: A value in the request is not valid.
- `429`: Too many requests. Wait for `Retry-After` seconds.
- `500`: Something went wrong on our side.
- `502`: A service Valeron depends on refused the request.
- `503`: A service Valeron depends on is unavailable.

## Examples

### Request

```bash title="cURL"
curl -X POST "https://api.valeron.io/v1/recordings/query" \
  -H "Authorization: Bearer $VALERON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "columns": [
    "example"
  ],
  "cursor": "eyJ1cGRhdGVkX2F0IjoiMjAyNi0xMi0wM1QxNDozMDowMFoifQ",
  "filters": [
    {
      "field": "example",
      "op": "eq",
      "value": "example"
    }
  ],
  "group_by": "example",
  "is_archived": false,
  "limit": 50
}'
```

```js title="JavaScript"
const response = await fetch("https://api.valeron.io/v1/recordings/query", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VALERON_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "columns": [
      "example"
    ],
    "cursor": "eyJ1cGRhdGVkX2F0IjoiMjAyNi0xMi0wM1QxNDozMDowMFoifQ",
    "filters": [
      {
        "field": "example",
        "op": "eq",
        "value": "example"
      }
    ],
    "group_by": "example",
    "is_archived": false,
    "limit": 50
  }),
});
if (!response.ok) throw new Error(`Valeron returned ${response.status}`);
const data = await response.json();
```

```python title="Python"
import os
import requests

response = requests.post(
    "https://api.valeron.io/v1/recordings/query",
    headers={"Authorization": f"Bearer {os.environ['VALERON_API_KEY']}"},
    json={
        "columns": [
            "example",
        ],
        "cursor": "eyJ1cGRhdGVkX2F0IjoiMjAyNi0xMi0wM1QxNDozMDowMFoifQ",
        "filters": [
            {
                "field": "example",
                "op": "eq",
                "value": "example",
            },
        ],
        "group_by": "example",
        "is_archived": False,
        "limit": 50,
    },
)
response.raise_for_status()
data = response.json()
```

### Response 200

```json
{
  "columns": [
    {
      "description": "A short description.",
      "group": "example",
      "id": "rec_01JCRZFXEH",
      "is_ai": true,
      "is_custom": true,
      "is_multi": true,
      "is_read_only": true,
      "key": "example_key",
      "label": "Example",
      "link_object": "example",
      "metric": {
        "key": "example_key",
        "minimum_sample": 1,
        "period": "example",
        "unit": "example"
      },
      "options": [
        {
          "color": "purple",
          "label": "Example",
          "value": "example"
        }
      ],
      "type": {
        "label": "Example",
        "value": "example"
      }
    }
  ],
  "data": [
    {
      "id": "rec_01JCRZFXEH",
      "values": {
        "example_key": {
          "amount": 2400000,
          "currency": "USD"
        }
      }
    }
  ],
  "groups": [
    {
      "amounts": [
        {
          "amount": 2400000,
          "currency": "USD"
        }
      ],
      "record_count": 3,
      "value": "example"
    }
  ],
  "has_more": false,
  "next_cursor": "eyJ1cGRhdGVkX2F0IjoiMjAyNi0xMi0wM1QxNDozMDowMFoifQ",
  "total": 3
}
```

### Response 401

```json
{
  "error": null
}
```

### Response 402

```json
{
  "error": null
}
```

### Response 403

```json
{
  "error": null
}
```

### Response 404

```json
{
  "error": null
}
```
