> ## Documentation Index
> Fetch the complete documentation index at: /developers/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload a complete recording

> Upload audio to signed storage URLs, complete the recording, and retrieve its transcript.

Upload a complete recording, then retrieve its transcript. For audio captured
during a consultation, use [segmented transcription](/developers/segmented-transcription.md).

**Before you begin:** create a session and prepare a synthetic audio file.
Use `scribe:write` to upload and `scribe:read` to retrieve the result.

## Upload sequence

```mermaid theme={null}
sequenceDiagram
    participant E as Your backend
    participant C as Cortexa API
    participant S as Audio storage
    E->>C: Create recording upload
    C-->>E: Upload ID
    E->>C: Request signed URL for part 1
    C-->>E: Upload URL and required headers
    E->>S: PUT audio bytes
    S-->>E: ETag
    E->>C: Complete upload with parts and duration
    C-->>E: Transcription job ID
    E->>C: Poll job, then read transcript
```

## 1. Create an upload

`POST /sessions/{session_id}/recording-uploads`

```bash theme={null}
curl --request POST "$CORTEXA_API_BASE/sessions/$CORTEXA_SESSION_ID/recording-uploads" \
  --header "Authorization: Bearer $CORTEXA_JWT" \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: visit-001-audio-upload-1' \
  --data '{"file_name":"synthetic-consultation.wav","mime_type":"audio/wav","size_bytes":4096,"part_count":1}'
```

Replace the illustrative file size with the actual number of bytes in your file.

| Field | Required | Description |
| - | - | - |
| `file_name` | Yes | Original filename; 1–255 characters |
| `mime_type` | No | Audio MIME type; defaults to `audio/wav` |
| `size_bytes` | Yes | Total recording size in bytes, greater than zero |
| `part_count` | No | Number of parts, from 1 to 10,000; defaults to 1 |

The `201` response contains `id`, `session_id`, `status`, and `part_count`.
Save `id` as `CORTEXA_UPLOAD_ID`. This is the **upload ID**, not the recording ID
returned later on completion.

## 2. Request a URL for a part

```bash theme={null}
curl --request POST "$CORTEXA_API_BASE/recording-uploads/$CORTEXA_UPLOAD_ID/upload-urls" \
  --header "Authorization: Bearer $CORTEXA_JWT" \
  --header 'Content-Type: application/json' \
  --data '{"part_number":1}'
```

The response contains `upload_url`, `expires_at`, and required `headers`.
Parts are numbered from **1**, unlike zero-based segmented transcription indices.
Signed URLs expire after 15 minutes; request another URL if necessary.

## 3. Upload the bytes

Set `CORTEXA_UPLOAD_URL` to the returned URL. Send the returned headers; for the
`audio/wav` example they contain `Content-Type: audio/wav`:

```bash theme={null}
curl --fail-with-body --request PUT "$CORTEXA_UPLOAD_URL" \
  --header 'Content-Type: audio/wav' \
  --data-binary '@./synthetic-consultation.wav' \
  --dump-header ./synthetic-upload-response.headers
```

Save the storage response's `ETag` for completion. Use only the returned storage
headers on this PUT; the signed URL supplies authorization. Keep the Partner JWT
on Cortexa API requests.

For multiple parts, request and upload each consecutive part, retaining every
part's number and ETag.

## 4. Complete the upload

`POST /recording-uploads/{upload_id}/completion`

```bash theme={null}
curl --request POST "$CORTEXA_API_BASE/recording-uploads/$CORTEXA_UPLOAD_ID/completion" \
  --header "Authorization: Bearer $CORTEXA_JWT" \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: visit-001-audio-complete-1' \
  --data '{"parts":[{"part_number":1,"etag":"ETAG_FROM_STORAGE_RESPONSE"}],"duration_ms":30000}'
```

Replace the ETag and duration with the values for your recording. `duration_ms`
is the **whole recording's duration in milliseconds**. Include every uploaded part.

The `202` response contains the recording `id`, `status`, and a
`transcription_job_id` when processing is scheduled.

## 5. Retrieve the transcript and generate a note

Poll the returned transcription job until it succeeds, then read
`GET /sessions/{session_id}/transcript`. Submit the resulting session to
[consult-note generation](/developers/notes.md).

Completing the upload starts transcription. Fetching the transcript only reads
the current result.

## Retry an interrupted upload

Reuse the same idempotency key and body for a retried upload-creation or completion
operation. If a signed URL expires, request a fresh URL for that part. Do not call
completion until the part PUTs have succeeded and their ETags are available.

Keep upload and recording IDs separate in your application. See [Errors](/developers/errors.md)
for request failures and [Jobs](/developers/jobs.md) for transcription failures.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.