Developers · API reference

Chartapir agent API.

JSON over HTTPS. One API key, thirteen routes: price a video, send a table, poll until it is done, and download the MP4. The developer overview covers keys, MCP and plan limits in plainer terms.

Basics

Base URL

https://yoikbbjcspyahnunmujx.supabase.co/functions/v1/v1-agent

Every path below is relative to it. The examples assume CHARTAPIR_API_URL holds the base URL and CHARTAPIR_API_KEY your key.

The links in a video answer are different: they start with /v1-agent/ and resolve against the Functions root, https://yoikbbjcspyahnunmujx.supabase.co/functions/v1. So /v1-agent/videos/<id>/download is https://yoikbbjcspyahnunmujx.supabase.co/functions/v1/v1-agent/videos/<id>/download.

Authentication

Send your API key from Account → API keys as a bearer token. No other header is needed.

Authorization: Bearer cpk_live_…

A key carries scopes. Make videos keys have all three; Read only keys have account and videos:read. A route outside a key’s scopes answers 404 request.not_found, the same as a video that does not exist.

Requests and responses

Bodies are JSON. Most answers carry schemaVersion: 1; the estimate and the video object do not. Every answer carries an x-correlation-id header, which is worth quoting if you contact support.

Idempotency

Every write needs an Idempotency-Key header: POST /uploads, POST /videos, and the confirm, revise, cancel and retry routes. Use any unique string, such as a UUID, per intent. After a timeout or network error, send the same request again with the same key: the action is not repeated, so a video is never made or charged twice. The answer is not a stored copy, though: a replayed create, confirm, revise, cancel or retry returns the video as it is now, and a replayed upload returns a freshly signed URL for the same upload. The same key with a different request is refused with 409 billing.idempotency_key_conflict.

Polling

A video takes minutes. Every video answer carries pollAfterSeconds; wait at least that long before reading it again. It is null once the video has ended, and while it is held for preview, because only you can move it then.

Account

GET/mescope: account

Who this key acts for. Call it first.

Response

FieldTypeMeaning
planstringThe plan code: free, starter, pro or business (Premium).
availableUnits, includedUnitsintegerCredits available now, and credits the plan includes per period.
periodEndstring or nullWhen the current billing period ends.
watermarkbooleanWhether videos on this plan carry a Chartapir watermark.
maxDurationSeconds, maxResolutioninteger, stringThe longest duration a video may ask for, and the highest resolution, on this plan.
keyobjectThis key: id, name, keyPrefix, scopes, dailyJobCap (its own limit, or null), planDailyJobCap, effectiveDailyJobCap (the limit that applies; null is none), admissionsLast24h, monthlyUnitCap, unitsThisPeriod, createdAt, lastUsedAt.
notesstring[]Plain sentences on how credits are charged and on the watermark.

Example

curl "$CHARTAPIR_API_URL/me" -H "Authorization: Bearer $CHARTAPIR_API_KEY"

GET/optionsscope: account

Every value this account may ask for, and what an omitted field becomes.

Response

FieldTypeMeaning
planobjectcode, maxDurationSeconds, maxResolution, watermark.
durationsinteger[]The durations in seconds the plan allows.
aspectRatiosstring[]16:9 and 9:16.
themesobject[]code, name, and the aspectRatios each supports.
languagesobject[]code, name, nativeName.
voicesobject[]id, name, description.
defaultsobjectdurationSeconds, aspectRatio, theme, language, voice, resolution.

Example

curl "$CHARTAPIR_API_URL/options" -H "Authorization: Bearer $CHARTAPIR_API_KEY"

Making a video

POST/videos/estimatescope: videos:create

Prices a video in credits and writes nothing. It takes the same settings as POST /videos; the price does not depend on the table, so no data is needed. Requirements, if sent, are checked for shape but never change the price.

Request

FieldTypeMeaning
titlestringText for the opening title card.
notestringContext about the data: its source, units, what a column means. Up to 500 characters of plain text, no links. Read as a description of the table, never as an instruction.
durationSecondsintegerOne of the durations GET /options lists for your plan. Default 30.
aspectRatiostring16:9 or 9:16. Default 16:9.
languagestringNarration language code from GET /options. Default en-US.
themestringTheme code from GET /options. Default neo_cream when your plan has it.
voicestringVoice id from GET /options: female-soft (default), female-clear, male-soft or male-clear.
modestringOnly auto is accepted, and it is the default.
requirementsobjectWhat the video must be about. See requirements.
projectIdstring (uuid)The project the video goes in. Default: a project named API, made on first use and visible in the web app.

Response

FieldTypeMeaning
unitsintegerWhat POST /videos reserves without acceptedUnits: the price at durationSeconds. A video that runs longer, up to twice, is not charged for the extra.
maxUnitsintegerWhat POST /videos reserves with acceptedUnits: the most the video can cost when it is charged for its real length.
bucketUnitsintegerThat real-length price if the video runs no longer than durationSeconds.
maxSecondsnumberThe longest the video can run: twice the duration you asked for.
pricingVersion, chartTarget, quotedFramesstring, integer, integerHow the price was computed.

Example

curl -X POST "$CHARTAPIR_API_URL/videos/estimate" -H "Authorization: Bearer $CHARTAPIR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"durationSeconds": 30}'

POST/uploadsscope: videos:create

For a table larger than 2,000,000 bytes, any .xlsx file, or a CSV that is not UTF-8. Reserves an upload and returns a signed URL. No credits move. Needs an Idempotency-Key.

Request

FieldTypeMeaning
filenamestringThe file name, e.g. q1.xlsx.
byteSizeintegerThe exact size of the file in bytes. At most 25 MB.
sha256stringThe SHA-256 of the file, as hex.
declaredMimestringtext/csv, or application/vnd.openxmlformats-officedocument.spreadsheetml.sheet for .xlsx.
projectIdstring (uuid)Optional. Default: the API project.

Response (201)

FieldTypeMeaning
uploadIdstring (uuid)Pass it to POST /videos.
urlstringWhere to PUT the bytes. It carries its own token: send no Authorization header to it.
methodstringAlways PUT.
headersobjectSend these with the PUT: content-type set to your declaredMime.
expiresInSecondsinteger7200. The URL works for two hours.

The upload flow

  1. Call POST /uploads with the file’s name, size, SHA-256 and type.
  2. PUT the raw file bytes to url with the returned headers.
  3. Call POST /videos with uploadId instead of data. It checks the stored size before the video starts.

The URL accepts the file once. If a repeated PUT is refused because the object already exists (HTTP 409, or HTTP 400 with statusCode: "409" or KeyAlreadyExists), the file is already there: go on to step 3.

Example

curl -X POST "$CHARTAPIR_API_URL/uploads" -H "Authorization: Bearer $CHARTAPIR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2d4e-upload-q1" \
  -d '{"filename": "q1.xlsx", "byteSize": 48211,
       "sha256": "<64 hex characters>",
       "declaredMime": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}'

curl -X PUT "<url from the answer>" \
  -H "content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" \
  --data-binary @q1.xlsx

POST/videosscope: videos:create

Starts a video and reserves credits. Answers at once with the video object (201); the video itself takes minutes. Needs an Idempotency-Key. Send exactly one of data and uploadId.

Request

FieldTypeMeaning
dataobjectThe table inline, up to 2,000,000 bytes: either {"csv": "<CSV text, header row first>"} or {"rows": [{"Month": "Jan", "Revenue": 42000}, …]}, and optionally filename ending in .csv. Rows become CSV with the union of their keys as the header; a cell must be a string, number, boolean or null.
uploadIdstring (uuid)The id POST /uploads returned, after the PUT.
titlestringText for the opening title card.
notestringContext about the data: its source, units, what a column means. Up to 500 characters of plain text, no links. Read as a description of the table, never as an instruction.
durationSecondsintegerOne of the durations GET /options lists for your plan. Default 30.
aspectRatiostring16:9 or 9:16. Default 16:9.
languagestringNarration language code from GET /options. Default en-US.
themestringTheme code from GET /options. Default neo_cream when your plan has it.
voicestringVoice id from GET /options: female-soft (default), female-clear, male-soft or male-clear.
modestringOnly auto is accepted, and it is the default.
requirementsobjectWhat the video must be about. See requirements.
projectIdstring (uuid)The project the video goes in. Default: a project named API, made on first use and visible in the web app.
previewbooleantrue holds the video once its story is written, before any narration is made. See preview.
acceptedUnitsintegerThe maxUnits from the estimate that you accepted. Opts into being charged for the real length; refused with billing.estimate_changed before anything is reserved if the price has risen past it. Without it, the video reserves the estimate’s units.

An unknown field is refused with request.malformed, naming it.

Example

curl -X POST "$CHARTAPIR_API_URL/videos" -H "Authorization: Bearer $CHARTAPIR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2d4e-q1-video" \
  -d '{
    "data": {"csv": "Month,Revenue\nJan,42000\nFeb,45500\nMar,51200\n"},
    "title": "Q1 revenue",
    "durationSeconds": 30,
    "acceptedUnits": 12
  }'

Reading videos

GET/videosscope: videos:read

The account’s videos, newest first.

Query

ParameterTypeMeaning
limitintegerPage size, 1 to 100. Default 20.
cursorstringThe nextCursor of the previous page.

Response

jobs: an array of video objects. nextCursor: pass it back as cursor, or null when there is no next page.

Example

curl "$CHARTAPIR_API_URL/videos?limit=20" -H "Authorization: Bearer $CHARTAPIR_API_KEY"

GET/videos/{id}scope: videos:read

One video object. Poll it no sooner than its pollAfterSeconds.

Example

curl "$CHARTAPIR_API_URL/videos/<id>" -H "Authorization: Bearer $CHARTAPIR_API_KEY"

Response (abridged, values illustrative)

{
  "id": "4f0f1f7e-8c1b-4d3e-9a51-2a7c1d9e0b11",
  "status": "rendering",
  "progress": 80,
  "error_code": null,
  "retryable": false,
  "compliance": null,
  "reservedUnits": 12,
  "settledUnits": null,
  "durationSeconds": 41.5,
  "pollAfterSeconds": 20,
  "links": {
    "self": "/v1-agent/videos/4f0f1f7e-8c1b-4d3e-9a51-2a7c1d9e0b11",
    "download": "/v1-agent/videos/4f0f1f7e-8c1b-4d3e-9a51-2a7c1d9e0b11/download"
  }
}

Preview, confirm, revise

A video created with preview: true stops in awaiting_confirmation once its story is written, before any narration is made. Its credits stay reserved. Read the preview, then confirm, revise or cancel. Left alone for an hour, it cancels itself (cancel.confirmation_expired) and nothing is charged.

GET/videos/{id}/previewscope: videos:read

Response

FieldTypeMeaning
statusstringThe video’s status.
previewobject or nullscenes: each scene’s headline and narration.
complianceobject or nullThe report on your requirements so far.
revisionNo, revisionsRemainingintegerRevisions used and left: two per video, one on the Free plan.
holdExpiresAtstring or nullWhen an unconfirmed hold cancels itself.

Example

curl "$CHARTAPIR_API_URL/videos/<id>/preview" -H "Authorization: Bearer $CHARTAPIR_API_KEY"

POST/videos/{id}/confirmscope: videos:create

Approves a held video, which goes on to narration and render. It is charged when it completes. No body. Needs an Idempotency-Key. Answers with the video object.

curl -X POST "$CHARTAPIR_API_URL/videos/<id>/confirm" -H "Authorization: Bearer $CHARTAPIR_API_KEY" \
  -H "Idempotency-Key: 6f1c2d4e-q1-confirm"

POST/videos/{id}/revisescope: videos:create

Re-writes a held video’s story and holds it again. No new reservation. Needs an Idempotency-Key. Answers with the video object; poll until it is held again and read the new preview.

Request (both optional; an empty body re-writes with nothing changed)

FieldTypeMeaning
requirementsobject or nullReplaces the stored requirements, so name every one to keep. Absent or null keeps them; {} removes them.
notestring or nullReplaces the note: 1 to 500 characters of plain text. Absent or null keeps it.
curl -X POST "$CHARTAPIR_API_URL/videos/<id>/revise" -H "Authorization: Bearer $CHARTAPIR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2d4e-q1-revise-1" \
  -d '{"note": "Revenue is in USD"}'

Cancel and retry

POST/videos/{id}/cancelscope: videos:create

Stops a video that has not finished; none of its reserved credits are charged. Cannot be undone, and a cancelled video cannot be retried. No body. Needs an Idempotency-Key. Answers with the video object.

curl -X POST "$CHARTAPIR_API_URL/videos/<id>/cancel" -H "Authorization: Bearer $CHARTAPIR_API_KEY" \
  -H "Idempotency-Key: 6f1c2d4e-q1-cancel"

POST/videos/{id}/retryscope: videos:create

Restarts a failed video whose retryable is true, and reserves credits again. A failure that is not retryable needs a different table or settings: make a new video. No body. Needs an Idempotency-Key. Answers with the video object.

curl -X POST "$CHARTAPIR_API_URL/videos/<id>/retry" -H "Authorization: Bearer $CHARTAPIR_API_KEY" \
  -H "Idempotency-Key: 6f1c2d4e-q1-retry"

Download

GET/videos/{id}/downloadscope: videos:read

A signed link to the finished MP4. Each call spends one download token, so call it once the video is completed, fetch the file, and keep it. Answers 404 request.not_found until the video has a file.

Response

FieldTypeMeaning
urlstringThe MP4. Fetch it with a plain GET and no Authorization header.
expiresInSecondsintegerHow long the link works: five minutes.
curl "$CHARTAPIR_API_URL/videos/<id>/download" -H "Authorization: Bearer $CHARTAPIR_API_KEY"

The video object

POST /videos, GET /videos/{id}, GET /videos and the confirm, revise, cancel and retry routes all answer with this shape. More fields may appear; ignore the ones you do not use.

FieldTypeMeaning
idstring (uuid)The video id.
statusstringqueued, parsing, analyzing, script_ready, generating_speech, ready_to_render, rendering, uploading, then completed, failed or cancelled. A preview waits in awaiting_confirmation.
progressintegerHow far along the video is, 0 to 100.
error_code, safe_messagestring or nullWhy a video failed, as a code from the error table and a sentence you can show a person.
retryablebooleanWhether POST /videos/{id}/retry can restart a failed video.
complianceobject or nullThe line-by-line report on your requirements: whether each was honoured and what the video said. Final once the video ends.
reservedUnitsinteger or nullCredits held for this video: the most it can cost.
settledUnitsinteger or nullCredits charged. null until the video is completed.
durationSecondsnumber or nullThe video’s real length, to one decimal. null until the narration exists.
pollAfterSecondsinteger or nullWait at least this long before asking again. null once the video has ended, and while it is held for preview.
nextActionstringOnly on a held video: confirm_or_revise.
linksobjectself, download, and on a held video preview: paths that start with /v1-agent/. They are not relative to the base URL; prefix them with the Functions root, which is the base URL without its last /v1-agent. See Basics.
created_at, started_at, completed_at, updated_atstringTimestamps.
aspect_ratio, output_language, opening_title, voice_persona_id, resolution_code, project_id, upload_idvariousThe settings the video was made with.

Requirements

When a person says what the video must be about, send it as fields rather than as prose in note. The service applies columns, entities and period to the table before any chart is planned, and fails the video before any charge when the file cannot satisfy one. cover and focus are enforced on the story: a story that still misses one fails with plan.requirements_unmet, nothing charged. An ask is different: when the data cannot answer it, the story may say so, and the video goes ahead with that ask reported as missed in compliance. Names must match the file’s headers and values as written; case and surrounding spaces are ignored.

KeyTypeMeaning
columnsobject{"include": [...]} or {"exclude": [...]}: only these columns, or all but these. 1 to 50 names.
entitiesobjectcolumn plus exactly one of include or exclude: keep or drop rows by that column’s values. 1 to 100 values.
periodobjectfrom and/or to, as YYYY, YYYY-Qn, YYYY-MM or YYYY-MM-DD, and optionally the date column.
coverstring[]1 to 10 columns the video must show.
asksstring[]1 to 10 questions for the video to answer, or instructions for it to follow. One the data cannot answer is reported, not failed.
focusobjectcolumn, subject (1 to 10 values the video is about) and optionally compareTo (up to 10 values to compare with).
briefobjectYour own analysis: keyNumbers (1 to 8, each a label, a decimal-string value, a source cell or formula, and at most one headline), semantics (what a column’s sign or baseline means), statements (up to 5 sentences said as written, with no figures in them), angle and audience. Every key number is checked against the data before any charge. At most 8 KB.

Text values are 1 to 200 characters of plain text with no links or markup, except a key number’s label, which is 1 to 80. A malformed object is refused at once with request.malformed and details[0].field naming the first bad field, such as requirements.period.from. Whether a column or value exists is decided once the file is read; those failures arrive as the video’s error_code. Once a video ends, compliance reports on each requirement.

Errors

Every error has the same envelope:

{
  "schemaVersion": 1,
  "code": "request.malformed",
  "message": "We couldn't complete that request. Please try again.",
  "correlationId": "…",
  "retryable": false,
  "details": [{ "field": "durationSeconds", "issue": "must be one of 30, 60" }]
}

Decide from code, never from message, which is written for people. retryable says whether waiting and retrying can help. details appears only when there is a field or a number to report.

Returned by a request

CodeHTTPMeaning
request.unauthenticated401The key is missing, unknown or revoked, or the assistant was disconnected. Stop and ask for a working key.
request.not_found404No such route or video, a video that is not yours, or a route outside the key’s access. A Read only key gets this for every write.
request.malformed400A field is wrong. details[0].field names it and details[0].issue says why.
request.idempotency_key_required400A write was sent without an Idempotency-Key header.
billing.rate_limited429Too many calls too fast: this key’s or assistant’s 60-call budget is empty, or, on a create or retry, the account is starting videos faster than its own submission limit allows (a burst of 10, then one every 6 seconds, shared by every way into the account). Wait, then retry. retryable is true.
billing.api_key_limit_reached429This key’s or assistant’s own limit. details[0].issue is daily or monthly; details[0].field is apiKey or connection. Ask the account owner.
billing.insufficient_credits402Fewer credits than the most this video can cost. details[0].issue reads need N, have M.
billing.estimate_changed409The price rose past acceptedUnits since the estimate. Nothing was reserved. details[0].issue reads units N, accepted M. Estimate again.
billing.idempotency_key_conflict409The same Idempotency-Key was sent with a different request. Stop: use a new key only for a new intent.
billing.daily_limit_reached402The plan’s videos for today are used.
billing.concurrency_limit_reached402Another video is still in progress. Wait for it to finish.
billing.per_video_cap_exceeded402Longer, or with more charts, than the plan allows for one video. Choose a shorter duration.
billing.resolution_unavailable400A resolution above the plan’s.
billing.no_active_plan402The account has no plan.
billing.plan_feature_unavailable402The plan does not include API access.
billing.download_limit_reached429Too many downloads just now. Wait, then download once. retryable is true.
validation.oversize400The upload is over 25 MB.
validation.empty_file400An upload with a byteSize of 0.
validation.bad_format400Not a CSV or XLSX file.
validation.upload_incomplete400The uploaded file did not fully arrive, or its size does not match byteSize.
validation.video_not_awaiting_confirmation400Confirm or revise on a video that is not held.
validation.revision_limit_reached400The video has used its revisions.

Reported on a failed video

These arrive as the video’s error_code, with status: "failed" (or cancelled for an expired preview). None of them is charged.

CodeMeaning
validation.too_many_rowsOver 100,000 rows.
validation.too_many_columnsOver 100 columns.
validation.encrypted_workbookThe workbook has a password.
validation.scope_unknown_columnA column named in requirements is not a header in the file.
validation.scope_unknown_entityA value named in requirements is not in that column.
validation.scope_no_temporal_columnA period was given but the file has no dates.
validation.scope_emptyThe requirements leave nothing to chart.
validation.focus_unknown_labelA focus value is not in the focus column.
validation.brief_source_unknownA key number’s column or row is not in the file.
validation.brief_formula_invalidA key number cannot be computed as written.
validation.brief_number_mismatchA key number’s value is not what the data computes; compliance names the computed value.
plan.requirements_unmetThe story could not meet cover or focus, or left an ask neither answered nor declared unanswerable. compliance says which.
parse.no_headerNo header row.
parse.duplicate_columnsTwo columns share a name.
parse.malformed_rowsRows with the wrong number of fields.
parse.undetectable_encodingThe file is not readable text.
analysis.no_numeric_seriesNo numeric column.
analysis.insufficient_chartable_dataToo little data to chart.
analysis.single_value_onlyOne value is not a chart.
analysis.all_null_measuresThe numeric columns are empty.
billing.failure_spend_ceiling_dailySpending on recent previews that were shown and then abandoned or revised into a failure reached the account’s limit for a rolling 24 hours. New videos can go ahead as that spending ages out of the window.
billing.failure_spend_ceiling_cycleThe same, for the billing period.
cancel.confirmation_expiredA held video waited an hour without approval and was cancelled.

A video can also fail on our side with a system.*, render.*, speech.* or provider.* code. Check retryable: when it is true, POST /videos/{id}/retry.

Limits

LimitValueWhen exceeded
Calls per key or assistantA budget of 60 that refills continuously at 60 a minute. One route can spend several: creating a video spends up to six.429 billing.rate_limited
Videos started per accountA burst of 10, then one every 6 seconds, for creates and retries together, across the web app, the API and assistants.429 billing.rate_limited
Videos a day per key or assistantStarter 10, Pro 50, Free and Premium none of their own. A key or assistant can be set lower. Rolling 24 hours; starts and retries count.429 billing.api_key_limit_reached, issue daily
Credits a month per key or assistantOptional, set on the key.429 billing.api_key_limit_reached, issue monthly
Plan’s daily videosFree: 3 a day, for the whole account.402 billing.daily_limit_reached
Inline table2,000,000 bytes of UTF-8 CSV.400 request.malformed, issue exceeds_inline_max
Uploaded file25 MB, .csv or .xlsx.400 validation.oversize
TableOne header row, unique headers, at least one numeric column, at most 100,000 rows and 100 columns.The video fails with the code in the error table.
Page size1 to 100 videos.400 request.malformed

Plan limits on length, credits and concurrent videos apply as well. See the developer overview and the plans page.