API reference

AI template chat

Send changes to a template's AI chat, check each draft, and save the draft you choose as the next version.

Use with your agent

Give this prompt to your AI agent. The agent does the task for you.

Read https://thirds.ai/docs/api-reference/template-chat 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.

Endpoints

getSavedImageProposal

GET /v1/ai-image-proposals/{message_id}

Read a saved image suggestion

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
message_idpathYesTemplateMessageId
StatusMeaningBody
200Read a saved image suggestion.application/json: ChatImageProposal
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
409The one error envelope every backend response uses.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

applyImageProposal

POST /v1/ai-image-proposals/{message_id}/apply

Keep an image suggestion with an applied layout

Keep this owned successful message’s image suggestion after applying its layout. This call does not generate an image or spend credits. A rejected suggestion can be restored by this explicit action.

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
message_idpathYesTemplateMessageId
StatusMeaningBody
200Keep an image suggestion with an applied layout.application/json: ChatImageProposal
400The one error envelope every backend response uses.application/json: ErrorEnvelope
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
409The one error envelope every backend response uses.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

getChatImageProposal

GET /v1/templates/{template_id}/messages/{message_id}/image-proposal

Read a chat image proposal

Read the private prompt and aspect ratio without spending credits. A new chat message rejects an unapplied suggestion. Applied frames stay available to fill later.

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
template_idpathYesTemplateId
message_idpathYesTemplateMessageId
StatusMeaningBody
200The current proposal and approval state.application/json: ChatImageProposal
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
409The one error envelope every backend response uses.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

rejectChatImageProposal

DELETE /v1/templates/{template_id}/messages/{message_id}/image-proposal

Reject a chat image proposal

Reject a pending image proposal. Rejection makes no image call and spends no image credits. An approved proposal keeps its state.

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
template_idpathYesTemplateId
message_idpathYesTemplateMessageId
StatusMeaningBody
200The current proposal and approval state.application/json: ChatImageProposal
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
409The one error envelope every backend response uses.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

sendTemplateMessage

POST /v1/templates/{template_id}/messages

Send a template chat message

Send one message to the chat of a saved template. The first message of a template without a chat starts its chat, and then brand_kit_id is required. A later message can name a new brand_kit_id, which becomes the chat kit. A chat has one pending message at a time. It keeps its newest 100 messages; older settled messages drop off. A words or HTML message costs 25 credits. A source image costs 50 credits. The first message of a new blank template costs 50 credits. A source message makes no model call and costs 0 credits. A failed message keeps the previous draft and releases its reservation. All available credits, including free monthly credits, can pay for AI work. An account without enough available credits answers 402 insufficient_credits and holds nothing. Read message.progress for elapsed time, the current stages, and recent successful timing estimates. Estimates use the last 48 hours for the same model route and task when enough samples exist; completion time varies.

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
template_idpathYesTemplateId
Idempotency-KeyheaderYes{"type":"string","minLength":1,"maxLength":255,"pattern":"^[ -~]+$"}

Request body: application/json, TemplateMessageCreate.

StatusMeaningBody
200An earlier matching message was replayed.application/json: TemplateChatMessage
202The message was accepted.application/json: TemplateChatMessage
400The one error envelope every backend response uses.application/json: ErrorEnvelope
401The one error envelope every backend response uses.application/json: ErrorEnvelope
402The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
409The one error envelope every backend response uses.application/json: ErrorEnvelope
413The one error envelope every backend response uses.application/json: ErrorEnvelope
429The one error envelope every backend response uses.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
503The one error envelope every backend response uses.application/json: ErrorEnvelope

getTemplateMessage

GET /v1/templates/{template_id}/messages/{message_id}

Get a template chat message

Read one message of the chat with its progress, and the chat state. Poll this until the message is succeeded, failed, or cancelled.

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
template_idpathYesTemplateId
message_idpathYesTemplateMessageId
StatusMeaningBody
200The message and the chat state.application/json: TemplateChatMessage
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

cancelTemplateMessage

DELETE /v1/templates/{template_id}/messages/{message_id}

Cancel a pending template message

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
template_idpathYesTemplateId
message_idpathYesTemplateMessageId
StatusMeaningBody
200The message was cancelled and its reservation was released.application/json: TemplateChatMessage
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
409The one error envelope every backend response uses.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

getTemplateMessageDraft

GET /v1/templates/{template_id}/messages/{message_id}/draft

Get a message draft

Read the final source, sample data, schema, and output of a succeeded message. The response excludes the brand snapshot. Reading it changes no state and costs no credits. Pending, failed, and cancelled messages have no draft.

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
template_idpathYesTemplateId
message_idpathYesTemplateMessageId
StatusMeaningBody
200The final draft. Cache-Control is private, no-store.application/json: TemplateDraft
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

applyTemplateMessage

POST /v1/templates/{template_id}/messages/{message_id}/apply

Apply a message result

Record that the customer applied the draft of the current succeeded message. With save true, the default, the draft becomes the next immutable template version. Repeating it for the same message returns the same version. With save false, the call only records the decision, and the caller saves a version later. After either call, chat.current_message_reviewed is true. An empty body means save true.

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
template_idpathYesTemplateId
message_idpathYesTemplateMessageId

Request body: application/json, TemplateApplyRequest.

StatusMeaningBody
200This draft was already saved as this version.application/json: TemplateVersionDetail
201The draft was saved as the next template version.application/json: TemplateVersionDetail
204The decision was recorded. No version was saved.No body
400The one error envelope every backend response uses.application/json: ErrorEnvelope
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
409The one error envelope every backend response uses.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

discardTemplateMessage

POST /v1/templates/{template_id}/messages/{message_id}/discard

Discard a message result

Record that the customer does not want the result of the current message. The template does not change. After this call, chat.current_message_reviewed is true.

Authentication: bearer API key. See authentication.

ParameterLocationRequiredRule
template_idpathYesTemplateId
message_idpathYesTemplateMessageId
StatusMeaningBody
204The decision was recorded.No body
401The one error envelope every backend response uses.application/json: ErrorEnvelope
403The authenticated account is suspended. The code is account_suspended.application/json: ErrorEnvelope
404The one error envelope every backend response uses.application/json: ErrorEnvelope
405The method is not allowed on this route.application/json: ErrorEnvelope
409The one error envelope every backend response uses.application/json: ErrorEnvelope
431The request has more than 64 headers or more than 32 KiB of header names and values.application/json: ErrorEnvelope
500The one error envelope every backend response uses.application/json: ErrorEnvelope

Schemas

ChatImageProposal

FieldRequiredDescription and type
proposalYes{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":false,"required":["prompt","aspect_ratio","target_layer_id"],"properties":{"prompt":{"type":"string"},"aspect_ratio":{"type":"string","enum":["1:1","1:2","2:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","9:19.5","19.5:9","9:20","20:9","9:21","21:9"]},"target_layer_id":{"type":"string","maxLength":64,"pattern":"^[A-Za-z][A-Za-z0-9_-]{0,63}$"}}}]}
stateYes{"type":"string","enum":["pending","rejected","approved"]}
generation_idYes{"type":["string","null"],"pattern":"^aimg_[0-9a-f]{32}$"}
appliedYes{"type":"boolean"}

Schema rules: {"type":"object","additionalProperties":false}.

TemplateMessageCreate

FieldRequiredDescription and type
inputYesTemplateMessageInput
outputNoTemplateOutputIntent
brand_kit_idNoThe kit of this message and of the chat from now on. The first message of a chat requires it. Omit it to keep the chat kit. BrandKitId

Schema rules: {"type":"object","additionalProperties":false}.

TemplateApplyRequest

FieldRequiredDescription and type
saveNoSave the draft as the next template version. {"type":"boolean","default":true}

Schema rules: {"type":"object","additionalProperties":false}.

TemplateChatMessage

FieldRequiredDescription and type
chatYesTemplateChat
messageYesTemplateMessage

Schema rules: {"type":"object","additionalProperties":false}.

TemplateDraft

FieldRequiredDescription and type
sourceYes{"type":"string","maxLength":1048576}
sample_dataYes{"type":"object"}
schemaYes{}
outputYesTemplateOutput

Schema rules: {"type":"object","additionalProperties":false}.

Shared errors, headers, and authentication schemes are in shared types and security.

Ready to make your first file?

Start in the playground with a gallery template, or get an API key and send your first request from your own terminal.