# Send a call to the analysis

`POST /v1/analyses`

Required scope: `analyses:write`

Store a call Valeron did not record, from its transcript, and analyze it like any recording. `external_id` is your own ID for the call: sending it again returns the first recording with a 200 and charges nothing more. The call's minutes are `duration_seconds`, or else the last segment's `end_seconds`; with neither the answer is `422 duration_required`. The analysis costs $0.014 per started minute, charged when it is stored; the request is refused with `402 insufficient_balance` when the balance can't cover the whole call. The answer is a 202 with the recording's ID: fetch the result from `GET /v1/recordings/{id}/analysis`, or wait for the `recording.analyzed` webhook event.

## Request body (application/json)

- `contact` (object or null, optional): The contact the call was with: `id`, or an `email` and/or `phone` matched like any contact. `first_name` and `last_name` are used only when `create_contact` makes it.
  - `email` (string or null, optional)
  - `first_name` (string or null, optional)
  - `id` (string or null, optional)
  - `last_name` (string or null, optional)
  - `phone` (string or null, optional)
- `create_contact` (boolean, optional) Default: `false`.
- `duration_seconds` (integer or null, optional)
- `external_id` (string, required)
- `member` (string, required)
- `participants` (object[], optional) Default: `[]`.
  - `email` (string or null, optional)
  - `is_member` (boolean, required)
  - `name` (string, required)
  - `phone` (string or null, optional)
- `started_at` (string (date-time), required)
- `title` (string or null, optional)
- `transcript` (object[], required)
  - `end_seconds` (number or null, optional)
  - `is_member` (boolean or null, optional)
  - `speaker` (string, required)
  - `start_seconds` (number or null, optional)
  - `text` (string, required)
- `type` (string, optional) Allowed values: `"meeting"`, `"phone_call"`. Default: `"meeting"`.

## Responses

- `200`: This `external_id` was sent before: the first recording, and how far its analysis is. Nothing more is charged.
- `202`: 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/analyses" \
  -H "Authorization: Bearer $VALERON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "contact": {
    "email": "jordan@example.com",
    "first_name": "Jordan",
    "id": "rec_01JCRZFXEH",
    "last_name": "Rivera",
    "phone": "+14155550132"
  },
  "create_contact": false,
  "duration_seconds": 1260,
  "external_id": "rec_01JAHQMWM0",
  "member": "maya@acme.com",
  "participants": [
    {
      "email": "jordan@example.com",
      "is_member": true,
      "name": "Jordan Rivera",
      "phone": "+14155550132"
    }
  ],
  "started_at": "2026-12-03T14:30:00Z",
  "transcript": [
    {
      "end_seconds": 12,
      "is_member": true,
      "speaker": "Maya Chen",
      "start_seconds": 12,
      "text": "Thanks for your time today. Here is what we agreed."
    }
  ]
}'
```

```js title="JavaScript"
const response = await fetch("https://api.valeron.io/v1/analyses", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VALERON_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "contact": {
      "email": "jordan@example.com",
      "first_name": "Jordan",
      "id": "rec_01JCRZFXEH",
      "last_name": "Rivera",
      "phone": "+14155550132"
    },
    "create_contact": false,
    "duration_seconds": 1260,
    "external_id": "rec_01JAHQMWM0",
    "member": "maya@acme.com",
    "participants": [
      {
        "email": "jordan@example.com",
        "is_member": true,
        "name": "Jordan Rivera",
        "phone": "+14155550132"
      }
    ],
    "started_at": "2026-12-03T14:30:00Z",
    "transcript": [
      {
        "end_seconds": 12,
        "is_member": true,
        "speaker": "Maya Chen",
        "start_seconds": 12,
        "text": "Thanks for your time today. Here is what we agreed."
      }
    ]
  }),
});
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/analyses",
    headers={"Authorization": f"Bearer {os.environ['VALERON_API_KEY']}"},
    json={
        "contact": {
            "email": "jordan@example.com",
            "first_name": "Jordan",
            "id": "rec_01JCRZFXEH",
            "last_name": "Rivera",
            "phone": "+14155550132",
        },
        "create_contact": False,
        "duration_seconds": 1260,
        "external_id": "rec_01JAHQMWM0",
        "member": "maya@acme.com",
        "participants": [
            {
                "email": "jordan@example.com",
                "is_member": True,
                "name": "Jordan Rivera",
                "phone": "+14155550132",
            },
        ],
        "started_at": "2026-12-03T14:30:00Z",
        "transcript": [
            {
                "end_seconds": 12,
                "is_member": True,
                "speaker": "Maya Chen",
                "start_seconds": 12,
                "text": "Thanks for your time today. Here is what we agreed.",
            },
        ],
    },
)
response.raise_for_status()
data = response.json()
```

### Response 200

```json
{
  "recording_id": "rec_01JR70S5VT",
  "status": "queued"
}
```

### Response 202

```json
{
  "recording_id": "rec_01JR70S5VT",
  "status": "queued"
}
```

### Response 401

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

### Response 402

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

### Response 403

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

### Response 404

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