API reference

Batch

7 operations, 1 webhook. Base URL https://api.scarleta.ai. Select an operation to see its parameters, samples and errors.

Jump to an operation
POST/v1/batch

Submit a batch

Paid accounts onlyUses tokens
  • API key required
  • Paid accounts only
  • Uses tokens

Runs one recipe over up to 500 audio files in the background. The call returns 202 at once with a batch_id; follow progress with the status route or receive a batch_completed webhook when the batch ends. Batches are available on paid accounts only; a free-account key receives 403 batch_paid_only.

Each file is charged like a single run of the recipe: 1 token per second of audio at the base rate ($0.10 per minute), and recipes can carry their own per-step rates. Use the estimate route first to see the cost. The account needs a token balance, or auto-recharge turned on, otherwise the call returns 402 insufficient_balance.

Send an Idempotency-Key header to make retries safe: the same key with the same request returns the original batch_id (with meta.idempotent: true) and starts nothing new; the same key with a different request returns 409 idempotency_key_reused.

Capped at 10 requests per minute per account on top of the hourly account budget.

Cost. Charged per file when its run finishes: 1 token per second of audio at the base rate of $0.10 per minute. Recipes can use per-step rates, so check the estimate route first.

curl -X POST "https://api.scarleta.ai/v1/batch" \
  -H "Authorization: Bearer $SCARLETA_API_KEY" \
  -H "Idempotency-Key: a-unique-value-per-request" \
  -H "Content-Type: application/json" \
  -d '{
    "recipe_id": "rec_1005_cat_spectral",
    "audio_urls": [
      "https://example.com/track-1.wav",
      "https://example.com/track-2.wav"
    ],
    "name": "Morning session",
    "webhook_url": "https://example.com/hooks/scarleta"
  }'

Parameters

NameTypeRequiredDescription
Idempotency-KeyheaderstringOptional1 to 255 visible ASCII characters. Makes the submit safe to retry.

Request body

NameTypeRequiredDescription
recipe_idbodystringRequiredThe recipe to run on every file, for example `rec_1005_cat_spectral`. Allowed: at least 1 character.
audio_urlsbodyarray<string>RequiredHTTPS URLs of the audio files to process, 1 to 500 entries.
namebodystringOptionalA label for the batch, up to 32000 characters. Returned as `name` by the list route.
messagebodystringOptionalOlder alias of `name`. When both are sent, `name` wins. Allowed: at most 32000 characters.
webhook_urlbodystringOptionalWhere to POST the `batch_completed` event. Must be an https URL that resolves to a public address, at most 4096 bytes.
metadatabodyobjectOptionalFree-form JSON object kept with the batch, at most 8192 bytes when serialized. Keys are limited to 64 characters and string values to 2048.
Response fields
FieldTypeDescription
batch_idstringIdentifier of the new batch.
status"IN_QUEUE"
Errors
StatusCodeDescription
400missing_audio_urlsInvalid JSON, a missing or empty `audio_urls` or `recipe_id`, an unacceptable audio or webhook URL, a label or metadata that breaks its limits, or a malformed `Idempotency-Key`.
401invalid_keyMissing, malformed, unknown or revoked API key.
402insufficient_balanceNo token balance and no auto-recharge.
403batch_paid_onlyThe key belongs to a free account, or a file is not owned by your account.
404not_foundThe recipe does not exist or is not visible to your account.
409idempotency_key_reusedThe `Idempotency-Key` was used before with a different request.
413metadata_too_largeThe metadata is over 16384 bytes, or the `webhook_url` is over 4096 bytes.
422batch_too_largeMore than 500 files.
429rate_limit_exceededOver the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
500workflow_create_failedThe batch could not be started. Retry with the same `Idempotency-Key`.
503auth_unavailableTemporary platform condition; retry shortly.
Example responses
{
  "data": {
    "batch_id": "b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7",
    "status": "IN_QUEUE"
  },
  "meta": {
    "source": "workflow"
  }
}
  • 202 Accepted. The batch is queued. `meta` has no `request_id`; the `X-Request-ID` header carries the request id.
  • 400 Invalid JSON, a missing or empty `audio_urls` or `recipe_id`, an unacceptable audio or webhook URL, a label or metadata that breaks its limits, or a malformed `Idempotency-Key`.
  • 401 Missing, malformed, unknown or revoked API key.
  • 402 No token balance and no auto-recharge.
  • 403 The key belongs to a free account, or a file is not owned by your account.
  • 404 The recipe does not exist or is not visible to your account.
  • 409 The `Idempotency-Key` was used before with a different request.
  • 413 The metadata is over 16384 bytes, or the `webhook_url` is over 4096 bytes.
  • 422 More than 500 files.
  • 429 Over the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
  • 500 The batch could not be started. Retry with the same `Idempotency-Key`.
  • 503 Temporary platform condition; retry shortly.

Try it

Sends this request from your browser to https://api.scarleta.ai with your own key. The key stays in this page only (never saved or put in the address) and is cleared when you leave. Revoke any key you have shared.

Not sent from the browser: Idempotency-Key. The API only accepts those headers from server-side callers; use the cURL sample to send them.

Cost. Charged per file when its run finishes: 1 token per second of audio at the base rate of $0.10 per minute. Recipes can use per-step rates, so check the estimate route first.

Other error codes this operation can return: invalid_audio_url, invalid_auth_format, invalid_idempotency_key, invalid_json, invalid_key_format, invalid_message, invalid_metadata, invalid_name, invalid_recipe_id, invalid_webhook_url, media_not_owned, message_too_long, missing_api_key, missing_auth, missing_recipe_id, name_too_long, rate_limit_unavailable, unauthorized, webhook_url_too_large, webhook_validation_unavailable.

GET/v1/batch/{batch_id}

Get a batch

Paid accounts only
  • API key required
  • Paid accounts only
  • No token cost

Returns the live state of one batch: its status, per-state item counters and progress. A batch is final when status is completed, failed, partial or cancelled. Only batches created by your own account can be read; any other id returns 404. Capped at 600 requests per minute per account on top of the hourly account budget.

Cost. Free of charge.

BATCH_ID="YOUR_BATCH_ID"
curl "https://api.scarleta.ai/v1/batch/$BATCH_ID" \
  -H "Authorization: Bearer $SCARLETA_API_KEY"

Parameters

NameTypeRequiredDescription
batch_idpathstringRequiredThe `batch_id` returned when the batch was submitted. Batches submitted today get a UUID; an older batch can carry an id of the form `batch_<digits>_<hex>`, which is accepted too.
Response fields
FieldTypeDescription
messagestringHuman-readable progress line.
batch_idstringIdentifier of the batch.
status"processing" | "completed" | "failed" | "partial" | "cancelled" | nullCurrent state. `processing` until every item is final.
errorstring | nullSummary of why the batch failed, when it did.
totalintegerItems in the batch. Allowed: -9007199254740991 to 9007199254740991.
completedintegerItems that finished successfully. Allowed: -9007199254740991 to 9007199254740991.
failedintegerItems that failed. Allowed: -9007199254740991 to 9007199254740991.
cancelledintegerItems cancelled before they finished. Allowed: -9007199254740991 to 9007199254740991.
pendingintegerItems waiting to start. Allowed: -9007199254740991 to 9007199254740991.
processingintegerItems running now. Allowed: -9007199254740991 to 9007199254740991.
percent_completenumber`completed` divided by `total`, as a percentage with one decimal.
actual_costnumberTokens charged so far for the batch.
estimated_costnumber | nullEstimate recorded at submit, when there was one.
created_atnumber | nullMilliseconds since the Unix epoch.
completed_atnumber | nullMilliseconds since the Unix epoch.
webhook_delivery_statusstring | nullState of the `batch_completed` delivery: `in_progress`, `delivered`, `failed`, `skipped` (no `webhook_url`, or the batch was cancelled, which sends no webhook) or `unconfirmed`; null before the batch ends. It describes only the per-request `webhook_url`: addresses registered with `POST /v1/webhooks` are retried the same way, but their outcome is not shown in this field.
webhook_last_attempt_atnumber | nullMilliseconds since the Unix epoch.
Errors
StatusCodeDescription
400invalid_batch_id`batch_id` is neither a UUID nor a legacy `batch_<digits>_<hex>` id.
401invalid_keyMissing, malformed, unknown or revoked API key.
404batch_not_foundNo batch with this id exists for your account.
429rate_limit_exceededOver the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
503auth_unavailableTemporary platform condition; retry shortly.
Example responses
{
  "data": {
    "message": "Batch b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7: 100.0% complete (2/2)",
    "batch_id": "b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7",
    "status": "completed",
    "error": null,
    "total": 2,
    "completed": 2,
    "failed": 0,
    "cancelled": 0,
    "pending": 0,
    "processing": 0,
    "percent_complete": 100,
    "actual_cost": 40,
    "estimated_cost": null,
    "created_at": 1791333870854,
    "completed_at": 1791333895009,
    "webhook_delivery_status": "delivered",
    "webhook_last_attempt_at": 1791333895229
  },
  "meta": {
    "request_id": "req_0b7a3c2e-6f1d-4d9a-8e55-3a4b5c6d7e8f"
  }
}
  • 200 Success
  • 400 `batch_id` is neither a UUID nor a legacy `batch_<digits>_<hex>` id.
  • 401 Missing, malformed, unknown or revoked API key.
  • 404 No batch with this id exists for your account.
  • 429 Over the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
  • 503 Temporary platform condition; retry shortly.

Try it

Sends this request from your browser to https://api.scarleta.ai with your own key. The key stays in this page only (never saved or put in the address) and is cleared when you leave. Revoke any key you have shared.

Other error codes this operation can return: invalid_auth_format, invalid_key_format, missing_api_key, missing_auth, rate_limit_unavailable, unauthorized.

DELETE/v1/batch/{batch_id}

Cancel a batch

Paid accounts only
  • API key required
  • Paid accounts only
  • No token cost

Stops a batch that is still running: items that have not finished are cancelled and their work is stopped. Items that already finished keep their results and their charges. A batch that has already reached a final state returns 409 batch_already_final. Capped at 10 requests per minute per account on top of the hourly account budget.

Cost. Free of charge. Items that already finished stay charged.

BATCH_ID="YOUR_BATCH_ID"
curl -X DELETE "https://api.scarleta.ai/v1/batch/$BATCH_ID" \
  -H "Authorization: Bearer $SCARLETA_API_KEY"

Parameters

NameTypeRequiredDescription
batch_idpathstringRequiredThe `batch_id` returned when the batch was submitted. Batches submitted today get a UUID; an older batch can carry an id of the form `batch_<digits>_<hex>`, which is accepted too.
Response fields
FieldTypeDescription
messagestring
batch_idstringIdentifier of the batch.
cancelledintegerItems this call cancelled. Allowed: -9007199254740991 to 9007199254740991.
Errors
StatusCodeDescription
400invalid_batch_id`batch_id` is neither a UUID nor a legacy `batch_<digits>_<hex>` id.
401invalid_keyMissing, malformed, unknown or revoked API key.
404batch_not_foundNo batch with this id exists for your account.
409batch_already_finalThe batch had already reached a final state. `error.details.status` holds that state.
429rate_limit_exceededOver the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
503auth_unavailableTemporary platform condition; retry shortly.
Example responses
{
  "data": {
    "message": "Batch b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7 cancellation requested. 2 items cancelled.",
    "batch_id": "b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7",
    "cancelled": 2
  },
  "meta": {
    "request_id": "req_0b7a3c2e-6f1d-4d9a-8e55-3a4b5c6d7e8f"
  }
}
  • 200 Success
  • 400 `batch_id` is neither a UUID nor a legacy `batch_<digits>_<hex>` id.
  • 401 Missing, malformed, unknown or revoked API key.
  • 404 No batch with this id exists for your account.
  • 409 The batch had already reached a final state. `error.details.status` holds that state.
  • 429 Over the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
  • 503 Temporary platform condition; retry shortly.

Try it

Sends this request from your browser to https://api.scarleta.ai with your own key. The key stays in this page only (never saved or put in the address) and is cleared when you leave. Revoke any key you have shared.

Other error codes this operation can return: invalid_auth_format, invalid_key_format, missing_api_key, missing_auth, rate_limit_unavailable, unauthorized.

GET/v1/batch/{batch_id}/results

Get batch results

Paid accounts only
  • API key required
  • Paid accounts only
  • No token cost

Returns the per-file results of a batch, 50 items per page by default. Page with offset and limit while has_more is true. The keys inside each raw_results depend on the recipe that ran. Capped at 600 requests per minute per account on top of the hourly account budget.

Cost. Free of charge.

BATCH_ID="YOUR_BATCH_ID"
curl "https://api.scarleta.ai/v1/batch/$BATCH_ID/results" \
  -H "Authorization: Bearer $SCARLETA_API_KEY"

Parameters

NameTypeRequiredDescription
batch_idpathstringRequiredThe `batch_id` returned when the batch was submitted. Batches submitted today get a UUID; an older batch can carry an id of the form `batch_<digits>_<hex>`, which is accepted too.
offsetqueryintegerOptionalItems to skip. Defaults to 0. Allowed: 0 to 9007199254740991.
limitqueryintegerOptionalItems per page. Defaults to 50; values above 100 are clamped to 100. Allowed: 1 to 100.
Response fields
FieldTypeDescription
messagestring
batch_idstringIdentifier of the batch.
itemsarray<object>
items[].item_idstringIdentifier of this item attempt.
items[].item_indexinteger | nullPosition of the file in `audio_urls`, starting at 0. Allowed: -9007199254740991 to 9007199254740991.
items[].audio_urlstringThe file this item processed.
items[].display_namestring | nullThe file's library name, when it is in your library; null otherwise.
items[].reference_urlstring | null
items[].status"pending" | "processing" | "completed" | "failed" | "cancelled"
items[].raw_resultsobject | nullOutput of the recipe for this file. The keys depend on the recipe that ran.
items[].errorstring | nullWhy the item failed, when it did.
items[].costnumber | nullTokens charged for this item.
items[].duration_msnumber | nullHow long the item took, in milliseconds.
items[].retry_countinteger | nullHow many times this item has been retried. Allowed: -9007199254740991 to 9007199254740991.
totalintegerItems in the batch. Allowed: -9007199254740991 to 9007199254740991.
offsetintegerAllowed: -9007199254740991 to 9007199254740991.
limitintegerAllowed: -9007199254740991 to 9007199254740991.
has_morebooleanTrue when another page follows.
filters_appliedobject
filters_applied.status_filterstring
Errors
StatusCodeDescription
400invalid_batch_id`batch_id` is neither a UUID nor a legacy `batch_<digits>_<hex>` id.
401invalid_keyMissing, malformed, unknown or revoked API key.
404batch_not_foundNo batch with this id exists for your account.
429rate_limit_exceededOver the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
503auth_unavailableTemporary platform condition; retry shortly.
Example responses
{
  "data": {
    "message": "Returning 1 items (offset 0)",
    "batch_id": "b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7",
    "items": [
      {
        "item_id": "3f2a9c1e-7b64-4c0d-8e21-5a6b7c8d9e0f",
        "item_index": 0,
        "audio_url": "https://example.com/track-1.wav",
        "reference_url": null,
        "status": "completed",
        "raw_results": {
          "recipe_id": "rec_1005_cat_spectral",
          "status": "COMPLETED"
        },
        "error": null,
        "cost": 20,
        "duration_ms": 8120,
        "retry_count": 0
      }
    ],
    "total": 2,
    "offset": 0,
    "limit": 50,
    "has_more": true,
    "filters_applied": {
      "status_filter": "all"
    }
  },
  "meta": {
    "request_id": "req_0b7a3c2e-6f1d-4d9a-8e55-3a4b5c6d7e8f"
  }
}
  • 200 Success
  • 400 `batch_id` is neither a UUID nor a legacy `batch_<digits>_<hex>` id.
  • 401 Missing, malformed, unknown or revoked API key.
  • 404 No batch with this id exists for your account.
  • 429 Over the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
  • 503 Temporary platform condition; retry shortly.

Try it

Sends this request from your browser to https://api.scarleta.ai with your own key. The key stays in this page only (never saved or put in the address) and is cleared when you leave. Revoke any key you have shared.

Other error codes this operation can return: invalid_auth_format, invalid_key_format, missing_api_key, missing_auth, rate_limit_unavailable, unauthorized.

POST/v1/batch/{batch_id}/retry

Retry failed items of a batch

Paid accounts onlyUses tokens
  • API key required
  • Paid accounts only
  • Uses tokens

Re-queues the items of a finished batch that failed, as new attempts, and reopens the batch. Only a batch whose status is failed, partial or cancelled can be retried; any other status returns 409 batch_not_retryable. An item that has already been retried max_retries times is left as failed and counted in permanently_failed. The body is optional. Capped at 10 requests per minute per account on top of the hourly account budget.

Cost. Re-queued items are charged again when they finish, at the same per-file rate as the original run.

BATCH_ID="YOUR_BATCH_ID"
curl -X POST "https://api.scarleta.ai/v1/batch/$BATCH_ID/retry" \
  -H "Authorization: Bearer $SCARLETA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "max_retries": 2
  }'

Parameters

NameTypeRequiredDescription
batch_idpathstringRequiredThe `batch_id` returned when the batch was submitted. Batches submitted today get a UUID; an older batch can carry an id of the form `batch_<digits>_<hex>`, which is accepted too.

Request body

NameTypeRequiredDescription
max_retriesbodyintegerOptionalHighest number of times one item may be retried, 1 to 10. Defaults to 2.
Response fields
FieldTypeDescription
messagestring
batch_idstringIdentifier of the batch.
requeuedintegerItems put back in the queue. Allowed: -9007199254740991 to 9007199254740991.
permanently_failedintegerFailed items that were not re-queued because they reached `max_retries`. Allowed: -9007199254740991 to 9007199254740991.
supersededbooleanTrue when a cancel or another retry changed the batch while this call ran, so nothing was started.
Errors
StatusCodeDescription
400invalid_max_retriesThe body is not a JSON object, `max_retries` is not an integer in range, or `batch_id` is neither a UUID nor a legacy `batch_<digits>_<hex>` id.
401invalid_keyMissing, malformed, unknown or revoked API key.
404batch_not_foundNo batch with this id exists for your account. If the batch exists but its recipe was deleted, the code is `not_found` instead (past results are kept).
409batch_not_retryableThe batch is still running or already completed.
429rate_limit_exceededOver the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
500workflow_create_failedThe retry could not be started.
503auth_unavailableTemporary platform condition; retry shortly.
Example responses
{
  "data": {
    "message": "Retry results: 1 items requeued, 0 permanently failed (already at 2 retries)",
    "batch_id": "b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7",
    "requeued": 1,
    "permanently_failed": 0
  },
  "meta": {
    "request_id": "req_0b7a3c2e-6f1d-4d9a-8e55-3a4b5c6d7e8f"
  }
}
  • 200 Success
  • 400 The body is not a JSON object, `max_retries` is not an integer in range, or `batch_id` is neither a UUID nor a legacy `batch_<digits>_<hex>` id.
  • 401 Missing, malformed, unknown or revoked API key.
  • 404 No batch with this id exists for your account. If the batch exists but its recipe was deleted, the code is `not_found` instead (past results are kept).
  • 409 The batch is still running or already completed.
  • 429 Over the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
  • 500 The retry could not be started.
  • 503 Temporary platform condition; retry shortly.

Try it

Sends this request from your browser to https://api.scarleta.ai with your own key. The key stays in this page only (never saved or put in the address) and is cleared when you leave. Revoke any key you have shared.

Cost. Re-queued items are charged again when they finish, at the same per-file rate as the original run.

Other error codes this operation can return: batch_recipe_missing, batch_tenant_missing, invalid_auth_format, invalid_batch_id, invalid_json, invalid_key_format, missing_api_key, missing_auth, not_found, rate_limit_unavailable, unauthorized.

POST/v1/batch/estimate

Estimate the cost of a batch

Paid accounts only
  • API key required
  • Paid accounts only
  • No token cost

Returns the token cost of running a recipe over a list of files, per file and in total, without starting anything and without charging. Batches are available on paid accounts only; a free-account key receives 403 batch_paid_only. Accepts the same recipe_id and audio_urls as submit, at most 500 files. A file whose length cannot be read contributes 0 and reports duration_seconds: null. Capped at 600 requests per minute per account on top of the hourly account budget.

Cost. Free of charge: estimating never spends tokens.

curl -X POST "https://api.scarleta.ai/v1/batch/estimate" \
  -H "Authorization: Bearer $SCARLETA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "recipe_id": "rec_1005_cat_spectral",
    "audio_urls": [
      "https://example.com/track-1.wav",
      "https://example.com/track-2.wav"
    ]
  }'

Request body

NameTypeRequiredDescription
recipe_idbodystringRequiredThe recipe to run on every file, for example `rec_1005_cat_spectral`. Allowed: at least 1 character.
audio_urlsbodyarray<string>RequiredHTTPS URLs of the audio files to process, 1 to 500 entries.
Response fields
FieldTypeDescription
messagestring
recipe_idstring
total_costnumberTokens the whole batch would cost.
file_countintegerAllowed: -9007199254740991 to 9007199254740991.
per_filearray<object>
per_file[].audio_urlstring
per_file[].duration_secondsnumber | null
per_file[].costnumber
Errors
StatusCodeDescription
400missing_audio_urlsThe body is not valid JSON, `recipe_id` or `audio_urls` is missing, or a URL is not an acceptable public audio URL.
401invalid_keyMissing, malformed, unknown or revoked API key.
403batch_paid_onlyThe key belongs to a free account.
404recipe_not_foundThe recipe does not exist or is not visible to your account.
422batch_too_largeMore than 500 files.
429rate_limit_exceededOver the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
503auth_unavailableTemporary platform condition; retry shortly.
Example responses
{
  "data": {
    "message": "Estimated cost for 2 file(s) with recipe rec_1005_cat_spectral",
    "recipe_id": "rec_1005_cat_spectral",
    "total_cost": 40,
    "file_count": 2,
    "per_file": [
      {
        "audio_url": "https://example.com/track-1.wav",
        "duration_seconds": 4,
        "cost": 20
      },
      {
        "audio_url": "https://example.com/track-2.wav",
        "duration_seconds": 3.2,
        "cost": 20
      }
    ]
  },
  "meta": {
    "request_id": "req_0b7a3c2e-6f1d-4d9a-8e55-3a4b5c6d7e8f"
  }
}
  • 200 Success
  • 400 The body is not valid JSON, `recipe_id` or `audio_urls` is missing, or a URL is not an acceptable public audio URL.
  • 401 Missing, malformed, unknown or revoked API key.
  • 403 The key belongs to a free account.
  • 404 The recipe does not exist or is not visible to your account.
  • 422 More than 500 files.
  • 429 Over the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
  • 503 Temporary platform condition; retry shortly.

Try it

Sends this request from your browser to https://api.scarleta.ai with your own key. The key stays in this page only (never saved or put in the address) and is cleared when you leave. Revoke any key you have shared.

Other error codes this operation can return: invalid_audio_url, invalid_auth_format, invalid_json, invalid_key_format, missing_api_key, missing_auth, missing_recipe_id, rate_limit_unavailable, unauthorized.

GET/v1/batches

List batches

Free and paid accounts
  • API key required
  • Free and paid accounts
  • No token cost

Returns your most recent batches, newest first, each with its item counters and the tokens charged so far. Page past the first limit batches with offset; total is how many batches you have in all. Returns an empty list for a free account, which cannot create batches. Capped at 600 requests per minute per account on top of the hourly account budget.

Cost. Free of charge.

curl "https://api.scarleta.ai/v1/batches" \
  -H "Authorization: Bearer $SCARLETA_API_KEY"

Parameters

NameTypeRequiredDescription
limitqueryintegerOptionalRows to return. Defaults to 50; values above 100 are clamped to 100. Allowed: 1 to 100.
offsetqueryintegerOptionalBatches to skip, newest first. Defaults to 0; a negative or non-numeric value is read as 0. Allowed: 0 to 9007199254740991.
Response fields
FieldTypeDescription
messagestring
batchesarray<object>
batches[].batch_idstringIdentifier of the batch. Batches submitted today get a UUID. An older batch can carry an id of the form `batch_<digits>_<hex>`: it is listed here and every batch route accepts it.
batches[].status"processing" | "completed" | "failed" | "partial" | "cancelled" | nullCurrent state of the batch.
batches[].recipe_idstring | null
batches[].namestring | nullThe label sent as `name` (or `message`) at submit, if any.
batches[].total_itemsinteger | nullAllowed: -9007199254740991 to 9007199254740991.
batches[].completed_itemsintegerItems that finished successfully. Allowed: -9007199254740991 to 9007199254740991.
batches[].failed_itemsintegerItems that failed. Allowed: -9007199254740991 to 9007199254740991.
batches[].cancelled_itemsintegerItems cancelled before they finished. Allowed: -9007199254740991 to 9007199254740991.
batches[].created_atnumber | nullWhen the batch was submitted, in milliseconds since the Unix epoch.
batches[].completed_atnumber | nullWhen the batch reached a final state, in milliseconds since the Unix epoch.
batches[].actual_costintegerTokens charged so far for this batch's items; 0 when nothing was charged. Allowed: -9007199254740991 to 9007199254740991.
countintegerAllowed: -9007199254740991 to 9007199254740991.
totalintegerHow many batches you have in all, which can be more than the page returned. On a page past the end it is the offset you asked for. Allowed: -9007199254740991 to 9007199254740991.
offsetintegerThe offset this page starts at. Allowed: -9007199254740991 to 9007199254740991.
Errors
StatusCodeDescription
401invalid_keyMissing, malformed, unknown or revoked API key.
429rate_limit_exceededOver the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
503auth_unavailableTemporary platform condition; retry shortly.
Example responses
{
  "data": {
    "message": "Returning 1 batches",
    "batches": [
      {
        "batch_id": "b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7",
        "status": "completed",
        "recipe_id": "rec_1005_cat_spectral",
        "name": "Morning session",
        "total_items": 2,
        "completed_items": 2,
        "failed_items": 0,
        "cancelled_items": 0,
        "created_at": 1791333870854,
        "completed_at": 1791333895009,
        "actual_cost": 120
      }
    ],
    "count": 1,
    "total": 1,
    "offset": 0
  },
  "meta": {
    "request_id": "req_0b7a3c2e-6f1d-4d9a-8e55-3a4b5c6d7e8f"
  }
}
  • 200 Success
  • 401 Missing, malformed, unknown or revoked API key.
  • 429 Over the account request budget or the per-minute cap of this route. Wait for the `Retry-After` header, then retry.
  • 503 Temporary platform condition; retry shortly.

Try it

Sends this request from your browser to https://api.scarleta.ai with your own key. The key stays in this page only (never saved or put in the address) and is cleared when you leave. Revoke any key you have shared.

Other error codes this operation can return: invalid_auth_format, invalid_key_format, missing_api_key, missing_auth, rate_limit_unavailable, unauthorized.

EVENTbatch_completed

Webhook: Batch completed

Sent by Scarleta

Sent when a batch ends as completed, failed or partial: to the webhook_url of the batch, if it has one, and to every address registered with POST /v1/webhooks. The body is a JSON object with exactly the fields below. Each delivery carries X-Scarleta-Timestamp (Unix seconds) and X-Scarleta-Signature (v1= followed by the lowercase hex HMAC-SHA256 of <timestamp>.<raw body>, keyed with your signing secret from GET /v1/webhooks/signing-secret). Reject deliveries whose timestamp is more than 300 seconds from your clock. For one day after a rotation a delivery also carries X-Scarleta-Signature-Previous, signed with the previous secret; a receiver that has not switched to the new secret yet can verify that header with its old secret. Addresses registered with POST /v1/webhooks receive this event too, signed the same way; an address identical to the webhook_url is delivered once.

Your endpoint must answer with a 2xx status within 10 seconds. Scarleta makes up to 3 attempts, waiting 2 s and 4 s before the second and third; redirects are not followed. Targets that are not public https endpoints are never called. A batch you cancel sends no batch_completed: its webhook_delivery_status is skipped, and the cancel call itself is the answer. If you retry a batch, the webhook is sent when the retry ends. Each completion starts one delivery sequence to the webhook_url of the batch and never a second one, but inside that sequence an attempt that timed out or got a non-2xx answer is sent again with the same body, and the earlier attempt may already have reached you: de-duplicate by batch_id and completed_at. Registered addresses are delivered at least once, on a best-effort basis: a failed delivery to a registered address can also be sent again when the same completion is replayed, so de-duplicate by batch_id and completed_at there too. webhook_delivery_status on the batch shows the outcome of the delivery to its webhook_url only; registered addresses are retried the same way, but their outcome is not shown in that field.

Set by the webhook_url field of Submit a batch.

Payload

FieldTypeDescription
event"batch_completed"
batch_idstringThe batch that ended.
status"completed" | "failed" | "partial"How the batch ended.
total_itemsintegerItems in the batch. Allowed: -9007199254740991 to 9007199254740991.
completed_itemsintegerAllowed: -9007199254740991 to 9007199254740991.
failed_itemsintegerAllowed: -9007199254740991 to 9007199254740991.
cancelled_itemsintegerAllowed: -9007199254740991 to 9007199254740991.
actual_total_costnumberTokens charged for the whole batch.
completed_atnumberWhen the batch ended, in milliseconds since the Unix epoch.

Example payload

{
  "event": "batch_completed",
  "batch_id": "b1a2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7",
  "status": "completed",
  "total_items": 2,
  "completed_items": 2,
  "failed_items": 0,
  "cancelled_items": 0,
  "actual_total_cost": 40,
  "completed_at": 1791333895009
}