POST/conversations

Create a conversation

Creates a conversation that can include metadata and initial context items. Use items to seed the conversation with up to 20 items; metadata can store additional key-value information.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 body fields

Optional initial conversation context and metadata.

metadataobject | nulloptional
Optional key-value metadata for the conversation. Supports up to 16 pairs with keys no longer than 64 characters.
itemsarray<InputMessage>optional
Optional initial items to include in the conversation context. You can supply up to 20 items.

4 status codes
200Returns the created conversation with its unique identifier, object type, metadata, and creation time.
idstringrequired
The unique ID of the conversation.
objectstringrequired
The object type, which is always `conversation`.
Allowed:conversationDefault:conversation
metadataobjectrequired
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
created_atintegerrequired
The time at which the conversation was created, measured in seconds since the Unix epoch.
400Returned when the conversation input is invalid.
errorobjectrequired
429Returned when the request exceeds a rate limit.
errorobjectrequired
500Returned when the conversation update could not be finalized.
errorobjectrequired

Error handling

A 400 is returned when the conversation input is invalid; a 429 indicates a rate limit; and a 500 means the conversation update could not be finalized. items can contain at most 20 entries, and metadata supports up to 16 key-value pairs with keys no longer than 64 characters.