Narrate

Canvas-first: add the S3 object to a canvas pool (per-video sourceLanguage), create a named version, then generate with required canvasVideoId. The video must already exist at S3_VIDEO_KEY. Workers must be running or jobs stay queued.

What you need

  • Workspace key to mint a project key — or skip create steps with PERCHAT_PROJECT_ID / PERCHAT_PROJECT_KEY. See Create a project key.
  • connectionId, bucket, and object key from Connect storage. Or let the script create the S3 connection from the env.
  • Project key with service:narrate, and job:read.

1. Create a canvas

POST /v1/canvases creates the canvas and video pool. Each videoSources[] item needs sourceLanguage. One video is enough for this walkthrough; you can also seed several in the same array. Save canvasId and the canvasVideoId you will generate against (videoAssets[0] here). See Canvases.

POST /v1/canvases
curl -X POST "{BASE_URL}/v1/canvases" \
  -H "Authorization: Bearer {PROJECT_KEY}" \
  -H "Content-Type: application/json" \
-d '{
    "name": "{CANVAS_NAME}",
    "videoSources": [{
      "connectionId": "{CONNECTION_ID}",
      "bucket": "{S3_BUCKET}",
      "sourceKey": "{S3_VIDEO_KEY}",
      "sourceLanguage": "{SOURCE_LANGUAGE}"
    }]
  }'
Same route — more than one video
# Same POST — two pool videos, each with its own sourceLanguage.
# Generate still takes one canvasVideoId per job (videoAssets[0] or videoAssets[1]).
curl -X POST "{BASE_URL}/v1/canvases" \
  -H "Authorization: Bearer {PROJECT_KEY}" \
  -H "Content-Type: application/json" \
-d '{
    "name": "{CANVAS_NAME}",
    "videoSources": [
      {
        "connectionId": "{CONNECTION_ID}",
        "bucket": "{S3_BUCKET}",
        "sourceKey": "{S3_VIDEO_KEY}",
        "sourceLanguage": "en"
      },
      {
        "connectionId": "{CONNECTION_ID}",
        "bucket": "{S3_BUCKET}",
        "sourceKey": "{S3_VIDEO_KEY_TA}",
        "sourceLanguage": "ta",
        "label": "Tamil master"
      }
    ]
  }'

2. Create a version

POST /v1/canvases creates the video pool only — it does not create a cut. versions on that response is empty. Then POST /v1/canvases/:canvasId/versions. Optional label only (omit it and the API assigns v1, v2, …). Save canvasVersionId from this response, not from canvas create. Walkthrough: Create a canvas version.

POST /v1/canvases/{canvasId}/versions
curl -X POST "{BASE_URL}/v1/canvases/{CANVAS_ID}/versions" \
  -H "Authorization: Bearer {PROJECT_KEY}" \
  -H "Content-Type: application/json" \
-d '{ "label": "v1" }'

3. Check workspace services

GET /v1/services with the project key lists whether this workspace may run each service. Fail fast if transcription or ai_narration is not enabled. API keys cannot request access — ask a workspace admin (console Settings → Services) or a platform admin. See GET /v1/services.

GET /v1/services
curl "{BASE_URL}/v1/services" \
  -H "Authorization: Bearer {PROJECT_KEY}"
# Confirm transcription and ai_narration show "enabled": true before any generate POST.
# API keys cannot request access — ask a workspace admin (Settings → Services).

4. Start narrate

POST /v1/narrate queues a ai_narration job. The response is the Job object (status: queued). Full fields: Services → Narrate.

POST /v1/narrate
curl -X POST "{BASE_URL}/v1/narrate" \
  -H "Authorization: Bearer {PROJECT_KEY}" \
  -H "Content-Type: application/json" \
-d '{
    "canvasId": "{CANVAS_ID}",
    "canvasVersionId": "{CANVAS_VERSION_ID}",
    "canvasVideoId": "{CANVAS_VIDEO_ID}"
  }'

5. Monitor job status

Poll GET /v1/jobs/{jobId} until status is completed, failed, or cancelled. While running, currentStage is the worker stage. Same loop as every generate route — see How jobs work.

GET /v1/jobs/{jobId}
curl "{BASE_URL}/v1/jobs/{JOB_ID}" \
  -H "Authorization: Bearer {PROJECT_KEY}"

# Repeat until data.status is completed (or failed / cancelled).

6. Read the result

The narration result is stored on the canvas. Refresh GET /v1/canvases/{canvasId}.

Shared body fields (canvasId, canvasVersionId, canvasVideoId, overwrite, webhookUrl) are on Services.

Another take? Same cut and pool video — New narrate version. Every service: New service versions. A new named cut is Create a canvas version.

Run the script

Replace {…} placeholders. After each POST, copy jobId and poll until completed before the next job.

Canvas → version → narrate → poll
# Video object must already exist at {S3_VIDEO_KEY} in {S3_BUCKET}.
# Full partner flow: workspace key → project key → S3 → canvas → (transcribe) → this service.

curl "{BASE_URL}/v1/workspace" \
  -H "Authorization: Bearer {WORKSPACE_KEY}"

curl -X POST "{BASE_URL}/v1/projects" \
  -H "Authorization: Bearer {WORKSPACE_KEY}" \
  -H "Content-Type: application/json" \
-d '{"name": "{PROJECT_NAME}"}'

curl -X POST "{BASE_URL}/v1/project-api-keys" \
  -H "Authorization: Bearer {WORKSPACE_KEY}" \
  -H "Content-Type: application/json" \
-d '{"projectId": "{PROJECT_ID}", "serviceAccountName": "{SERVICE_ACCOUNT_NAME}"}'

curl -X POST "{BASE_URL}/v1/storage-connections" \
  -H "Authorization: Bearer {PROJECT_KEY}" \
  -H "Content-Type: application/json" \
-d '{
    "name": "{STORAGE_CONNECTION_NAME}",
    "provider": "s3",
    "region": "{AWS_REGION}",
    "accessKeyId": "{AWS_ACCESS_KEY_ID}",
    "secretAccessKey": "{AWS_SECRET_ACCESS_KEY}",
    "buckets": [{ "name": "{S3_BUCKET}", "defaultOutputPrefix": "{S3_OUTPUT_PREFIX}" }]
  }'

curl -X POST "{BASE_URL}/v1/canvases" \
  -H "Authorization: Bearer {PROJECT_KEY}" \
  -H "Content-Type: application/json" \
-d '{
    "name": "{CANVAS_NAME}",
    "videoSources": [{
      "connectionId": "{CONNECTION_ID}",
      "bucket": "{S3_BUCKET}",
      "sourceKey": "{S3_VIDEO_KEY}",
      "sourceLanguage": "{SOURCE_LANGUAGE}"
    }]
  }'

curl -X POST "{BASE_URL}/v1/canvases/{CANVAS_ID}/versions" \
  -H "Authorization: Bearer {PROJECT_KEY}" \
  -H "Content-Type: application/json" \
-d '{ "label": "v1" }'

curl "{BASE_URL}/v1/services" \
  -H "Authorization: Bearer {PROJECT_KEY}"
# Confirm transcription and ai_narration show "enabled": true before generate POSTs.

curl -X POST "{BASE_URL}/v1/narrate" \
  -H "Authorization: Bearer {PROJECT_KEY}" \
  -H "Content-Type: application/json" \
-d '{
    "canvasId": "{CANVAS_ID}",
    "canvasVersionId": "{CANVAS_VERSION_ID}",
    "canvasVideoId": "{CANVAS_VIDEO_ID}"
  }'

# Poll until data.status is completed
curl "{BASE_URL}/v1/jobs/{JOB_ID}" \
  -H "Authorization: Bearer {PROJECT_KEY}"