Shared types and security
Look up shared request and response fields, error types, response headers, and API authentication schemes.
Give this prompt to your AI agent. The agent does the task for you.
Read https://thirds.ai/docs/api-reference/shared and help me choose the right thirds.ai endpoint and write a request. Check the fields and credentials in this reference.
See all API resources or read the PDF generation API guide.
Schemas
AiProgressStage
| Field | Required | Description and type |
|---|---|---|
stage | Yes | {"type":"string","enum":["waiting","generating","checking","fixing","adjusting"]} |
started_at | Yes | {"type":"string","format":"date-time"} |
elapsed_ms | Yes | {"type":"integer","minimum":0} |
average_ms | Yes | {"type":["integer","null"],"minimum":0} |
sample_count | Yes | {"type":"integer","minimum":0} |
status | Yes | {"type":"string","enum":["running","completed"]} |
Schema rules: {"type":"object","additionalProperties":false}.
AiProgress
Measured stages and elapsed time. Estimates use at least five successful requests from the last 48 hours for the same model route and task. Unknown routes have no estimate.
| Field | Required | Description and type |
|---|---|---|
route | Yes | {"type":"string"} |
task | Yes | {"type":"string"} |
created_at | Yes | {"type":"string","format":"date-time"} |
finished_at | Yes | {"type":["string","null"],"format":"date-time"} |
elapsed_ms | Yes | {"type":"integer","minimum":0} |
average_ms | Yes | {"type":["integer","null"],"minimum":0} |
sample_count | Yes | {"type":"integer","minimum":0} |
stages | Yes | {"type":"array","items":{"$ref":"#/components/schemas/AiProgressStage"}}. See AiProgressStage |
Schema rules: {"type":"object","additionalProperties":false}.
FieldDetail
One request field that failed, its fixed safe reason, and an optional bounded source location. Details never carry template source, customer values, rendered output, or raw evaluator prose.
| Field | Required | Description and type |
|---|---|---|
field | Yes | The path to the field, such as "pdf.scale". Schema errors use data followed by a JSON Pointer, such as data/items/0/count. The pointer is cut at 256 UTF-8 bytes. A template schema error names the template followed by /schema, such as tpl_0123456789abcdef0123456789abcdef/schema. Empty for a problem with the whole document. {"type":"string","maxLength":260} |
reason | Yes | A fixed, safe reason. It never repeats the value the caller sent. {"type":"string","enum":["malformed JSON","missing field","unknown field","wrong type","invalid value","A required value is missing.","Use the expected value type.","Declare this variable before using it.","Choose an allowed value.","Use the required format.","Add a value.","Use a shorter value.","Use a number within the allowed range.","Check this value against its data rule."]} |
line | No | The one-based template source line when the evaluator provides one within the published bound. {"type":"integer","minimum":1,"maximum":1000000} |
column | No | The one-based template source column when the evaluator provides one within the published bound. {"type":"integer","minimum":1,"maximum":1000000} |
Schema rules: {"type":"object","additionalProperties":false}.
BrandKitId
Schema rules: {"type":"string","pattern":"^kit_[0-9a-f]{32}$"}.
TemplateMessageId
Schema rules: {"type":"string","pattern":"^msg_[0-9a-f]{32}$"}.
TemplateMessageInput
Schema rules: {"oneOf":[{"type":"object","properties":{"type":{"const":"prompt"},"prompt":{"type":"string","minLength":1,"maxLength":65536}},"required":["type","prompt"],"additionalProperties":false},{"type":"object","properties":{"type":{"const":"html"},"html":{"type":"string","minLength":1,"maxLength":65536},"prompt":{"type":"string","maxLength":65536}},"required":["type","html"],"additionalProperties":false,"description":"HTML plus optional written instructions, at most 65536 UTF-8 bytes together."},{"type":"object","description":"Use a still PNG, JPEG, or WebP to rebuild its layout or guide a written request. Reference images require a nonempty prompt. At most 10 MiB, 7680 by 4320, 32 million pixels, and 64 MiB decoded. Invalid files fail before the model.","properties":{"type":{"const":"image"},"base64":{"type":"string","minLength":1,"maxLength":13981016,"contentEncoding":"base64"},"purpose":{"type":"string","enum":["rebuild","reference"]},"prompt":{"type":"string","maxLength":65536}},"required":["type","base64","purpose"],"additionalProperties":false,"allOf":[{"if":{"properties":{"purpose":{"const":"reference"}}},"then":{"required":["prompt"],"properties":{"prompt":{"minLength":1,"pattern":"\\S"}}}}]},{"type":"object","description":"Your own working template, sent as data. It must pass the saved-template checks and evaluate with sample_data. It becomes the draft without a model call and costs 0 credits.","properties":{"type":{"const":"source"},"source":{"type":"string","minLength":1,"maxLength":1048576},"sample_data":{"type":"object"},"schema":{"oneOf":[{"type":"object"},{"type":"boolean"}]}},"required":["type","source"],"additionalProperties":false}]}.
TemplateOutputIntent
Schema rules: {"oneOf":[{"type":"object","description":"Let the model choose PDF or image from the message. An image result from a source image uses the source dimensions.","properties":{"type":{"const":"auto"}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"const":"pdf"}},"required":["type"],"additionalProperties":false},{"type":"object","description":"Request an image. Explicit width and height take priority. Otherwise source-image dimensions or the model’s resolved image dimensions are used. The initial fallback is 1200 by 628 when neither supplies a size.","properties":{"type":{"const":"image"},"format":{"type":"string","enum":["png","jpeg","webp"],"default":"png"},"width":{"type":"integer","minimum":320,"maximum":7680},"height":{"type":"integer","minimum":200,"maximum":4320}},"required":["type"],"additionalProperties":false}]}.
TemplateOutput
Schema rules: {"oneOf":[{"type":"object","properties":{"type":{"const":"pdf"}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"const":"image"},"format":{"type":"string","enum":["png","jpeg","webp"]},"width":{"type":"integer","minimum":320,"maximum":7680},"height":{"type":"integer","minimum":200,"maximum":4320}},"required":["type","format","width","height"],"additionalProperties":false}]}.
TemplateMessage
| Field | Required | Description and type |
|---|---|---|
id | Yes | TemplateMessageId |
state | Yes | {"type":"string","enum":["queued","running","previewing","succeeded","failed","cancelled"]} |
phase | Yes | {"type":"string","enum":["generate","candidate","review","final"]} |
input_type | Yes | {"type":"string","enum":["prompt","html","image","source"]} |
credits | Yes | {"type":"integer","enum":[0,25,50]} |
preview_id | Yes | {"type":["string","null"],"pattern":"^(pdf|image)_[0-9a-f]{32}$"} |
output | Yes | {"oneOf":[{"$ref":"#/components/schemas/TemplateOutput"},{"type":"null"}]}. See TemplateOutput |
review_count | Yes | {"type":"integer","minimum":0,"maximum":5} |
max_reviews | Yes | {"type":"integer","minimum":0,"maximum":5} |
input_text | No | The written request or attachment instructions. This does not contain submitted HTML or image bytes. {"type":"string","maxLength":65536} |
repair_code | No | The last safe generation or render code that blocked this message. Present while a repair is in progress and after a failed message. It never holds customer content. {"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"} |
failure_category | Yes | {"type":["string","null"],"enum":["provider","validation","renderer","unsupported_input","internal",null]} |
failure_code | Yes | {"type":["string","null"],"pattern":"^[a-z][a-z0-9_]{0,63}$"} |
progress | Yes | AiProgress |
image_purpose | Yes | {"type":["string","null"],"enum":["rebuild","reference",null]} |
Schema rules: {"type":"object","additionalProperties":false}.
TemplateChat
The AI chat of one template. A template has at most one chat.
| Field | Required | Description and type |
|---|---|---|
brand_kit_id | Yes | BrandKitId |
current_message_id | Yes | The message that owns the current draft. {"oneOf":[{"$ref":"#/components/schemas/TemplateMessageId"},{"type":"null"}]}. See TemplateMessageId |
current_draft | Yes | {"type":"boolean"} |
current_message_reviewed | Yes | True when the customer applied or discarded the result of the current message. {"type":"boolean"} |
messages | No | The newest messages, oldest first. Present only in a template read with include=chat, and in the answer of a create request with a message. {"type":"array","maxItems":100,"items":{"$ref":"#/components/schemas/TemplateMessage"}}. See TemplateMessage |
Schema rules: {"type":"object","additionalProperties":false}.
TemplateId
Schema rules: {"type":"string","pattern":"^tpl_[0-9a-f]{32}$"}.
ArchivePeriod
| Field | Required | Description and type |
|---|---|---|
archived_at | Yes | {"type":"string","format":"date-time"} |
restored_at | Yes | {"type":["string","null"],"format":"date-time"} |
Schema rules: {"type":"object","additionalProperties":false}.
FileExpiryChange
The file's new end, in days from the job's created_at.
| Field | Required | Description and type |
|---|---|---|
retention_days | Yes | Days from the job's created_at. It can't be more than your plan maximum, and the end must be in the future. {"type":"integer","minimum":1,"maximum":365} |
Schema rules: {"type":"object","additionalProperties":false}.
TemplatePdfPage
The printed PDF page of a saved template, such as 85mm by 55mm. A PDF render of the template with no format, width, or height uses this page, and the design scales to fit it. Without a page, the render uses the canvas size, or A4 when the source has no canvas.
| Field | Required | Description and type |
|---|---|---|
width | Yes | {"type":"string","pattern":"^(?:0\\.(?=[0-9]{1,4}(?:px|in|cm|mm)$)(?=[0-9]*[1-9])[0-9]{1,4}|[1-9][0-9]*(?:\\.[0-9]{1,4})?)(?:px|in|cm|mm)$"} |
height | Yes | {"type":"string","pattern":"^(?:0\\.(?=[0-9]{1,4}(?:px|in|cm|mm)$)(?=[0-9]*[1-9])[0-9]{1,4}|[1-9][0-9]*(?:\\.[0-9]{1,4})?)(?:px|in|cm|mm)$"} |
Schema rules: {"type":"object","additionalProperties":false}.
TemplateVersionDetail
| Field | Required | Description and type |
|---|---|---|
version | Yes | {"type":"integer","minimum":1} |
created_at | Yes | {"type":"string","format":"date-time"} |
source | Yes | {"type":"string","maxLength":1048576} |
schema | Yes | {} |
sizes | Yes | SizeVariantList |
page | Yes | {"oneOf":[{"$ref":"#/components/schemas/TemplatePdfPage"},{"type":"null"}]}. See TemplatePdfPage |
Schema rules: {"type":"object","additionalProperties":false}.
SizeVariant
One saved canvas size for a template version. docs/SMART-RESIZE.md owns the rules.
| Field | Required | Description and type |
|---|---|---|
id | Yes | Unique within the version. The id original is reserved for the version's own canvas. {"type":"string","pattern":"^[a-z0-9][a-z0-9-]{0,39}$"} |
name | Yes | {"type":"string","minLength":1,"maxLength":120} |
width | Yes | {"type":"integer","minimum":320,"maximum":7680} |
height | Yes | {"type":"integer","minimum":200,"maximum":4320} |
status | Yes | {"type":"string","enum":["auto","edited"]} |
source | Yes | The source canvas must declare exactly width by height. {"type":"string","maxLength":1048576} |
data_overrides | No | Merged over the version's rendered data for this size only. {"type":"object"} |
Schema rules: {"type":"object","additionalProperties":false}.
SizeVariantList
Schema rules: {"type":"array","maxItems":20,"items":{"$ref":"#/components/schemas/SizeVariant"}}. See SizeVariant.
PlanLimitInfo
Present when the account's plan causes the refusal: brand_kit_limit and batch_row_limit. It names the limit and the plan that sets it, so a caller can act without a second request. The message text never names the number.
| Field | Required | Description and type |
|---|---|---|
plan | Yes | The account's plan at the time of the refusal. {"type":"string","enum":["scale","growth","starter","pack","free"]} |
limit | Yes | What that plan allows: brand kits for brand_kit_limit, rows in one run for batch_row_limit. {"type":"integer","minimum":1} |
Schema rules: {"type":"object","additionalProperties":false}.
RetryInfo
How long the caller must wait before it retries.
| Field | Required | Description and type |
|---|---|---|
retry_after_seconds | Yes | {"type":"integer","minimum":1,"maximum":3600} |
Schema rules: {"type":"object","additionalProperties":false}.
ErrorEnvelope
The one error shape every backend response uses.
| Field | Required | Description and type |
|---|---|---|
error | Yes | {"type":"object","properties":{"code":{"type":"string","enum":["account_suspended","account_concurrency_limited","abuse_limited","ai_failure_limit_reached","already_subscribed","auth_unavailable","batch_row_limit","billing_unavailable","brand_asset_account_limit_reached","brand_asset_invalid","brand_asset_kind_invalid","brand_asset_kind_mismatch","brand_asset_limit_reached","brand_asset_too_large","brand_asset_type_unsupported","brand_data_conflict","brand_font_glyphs_exceeded","brand_font_tables_invalid","brand_image_animated","brand_image_dimensions_invalid","brand_image_pixels_exceeded","brand_kit_colours_invalid","brand_kit_conflict","brand_kit_limit","brand_kit_name_invalid","brand_kit_not_found","brand_kit_patch_empty","brand_kit_tone_invalid","brand_kit_unavailable","brand_lookup_unavailable","captcha_rejected","checkout_superseded","cross_origin_rejected","csrf_rejected","download_expired","email_already_set","gallery_template_not_found","generated_template_invalid","idempotency_conflict","image_asset_header_unsupported","image_asset_invalid","image_asset_limit","image_asset_not_found","image_asset_reference_invalid","image_asset_too_large","image_asset_type_unsupported","image_asset_unavailable","image_url_invalid","image_url_unavailable","insufficient_credits","internal_error","invalid_cursor","invalid_email","invalid_event","invalid_link","invalid_profile","invalid_request","invalid_upload","job_not_finished","key_concurrency_limited","key_limit_reached","message_not_found","method_not_allowed","no_billing_customer","not_found","operation_conflict","operation_limit_exceeded","operation_pending","overage_limit_reached","overage_unavailable","overloaded","playground_busy","playground_daily_limited","playground_kit_invalid","playground_request_invalid","playground_selection_invalid","playground_unavailable","policy_version_stale","provider_unavailable","rate_limited","render_probe_busy","render_probe_failed","render_probe_not_configured","render_probe_required","render_probe_timeout","request_headers_too_large","request_too_large","resize_timeout","retention_limit","review_account","signed_out","spend_cap_reached","template_data_collection_limit","template_data_depth_limit","template_data_invalid","template_data_limit","template_depth_limit","template_draft_not_found","template_evaluation_error","template_invalid_filter_input","template_missing_data","template_output_limit","template_not_found","template_schema_complexity","template_schema_draft_unsupported","template_schema_invalid","template_schema_missing","template_schema_too_large","template_schema_unsupported","template_size_canvas_mismatch","template_size_data_overrides_too_large","template_size_duplicate_id","template_size_invalid_dimensions","template_size_invalid_id","template_size_invalid_name","template_sizes_too_large","template_sizes_too_many","template_source_limit","template_syntax_error","template_timeout","template_version_changed","template_work_limit","testimonial_busy","testimonial_invalid","testimonial_rate_limited","testimonial_unavailable","unauthorized","unsupported_media_type","webhook_limit_reached"],"description":"A fixed, machine-readable error code."},"message":{"type":"string","description":"A fixed, human-readable message."},"request_id":{"type":"string","format":"uuid","description":"The identifier this answer also carries in its x-request-id header."},"details":{"type":"array","description":"Present on a validation failure. Schema failures return at most 16 entries with bounded data paths and fixed reasons. Values from the request are never repeated.","items":{"$ref":"#/components/schemas/FieldDetail"}},"retry":{"$ref":"#/components/schemas/RetryInfo"},"plan_limit":{"$ref":"#/components/schemas/PlanLimitInfo"}},"required":["code","message","request_id"],"additionalProperties":false}. See FieldDetail, RetryInfo, PlanLimitInfo |
Schema rules: {"type":"object","additionalProperties":false}.
Headers and security
XRequestId
{
"description": "The UUID that identifies this request and matches error.request_id on an error response.",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
sessionCookie
{
"type": "apiKey",
"in": "cookie",
"name": "__Host-thirds_session",
"description": "A browser session. Browser writes also require the matching x-csrf-token header from GET /v1/me."
}
bearerAuth
{
"type": "http",
"scheme": "bearer",
"description": "An API key's secret, sent as \"Authorization: Bearer thirds_sk_v1_...\"."
}