Skip to main content

Chat

Chat

toothfairyai@latest…

Manager for chat and message operations.

This manager provides methods to create, update, and manage chat conversations, as well as send messages to AI agents.

Example:

>>> client = ToothFairyClient(api_key="...", workspace_id="...")
>>> chat = client.chat.create(name="Support Chat", customer_id="cust-123")
>>> response = client.chat.send_to_agent("Hello", "agent-id", chat_id=chat.id)

Accessed via client.chat.

Methods

MethodHTTPEndpoint
createPOSTPOST /chat/create
updatePOSTPOST /chat/update
getGETGET /chat/get/{chat_id}
listGETGET /chat/list
deleteDELETEDELETE /chat/delete/{chat_id}
create_messagePOSTPOST /chat_message/create
get_messageGETGET /chat_message/get/{message_id}
update_messagePOSTPOST /chat_message/update
list_messagesGETGET /chat_message/list
send_to_agentPOSTPOST /agent

create

Create a new chat.

def create(
name: str = '',
customer_id: str = '',
customer_info: Optional[Dict[str, Any]] = None,
primary_role: str = 'user',
external_participant_id: str = '',
channel_settings: Optional[Dict[str, str]] = None
) -> Chat

Endpoint: POST /chat/create · API service

Request fields

FieldTypeRequiredDescription
idstringnoUnique identifier
workspaceidstringyesUnique workspace identifier (UUID v4)
createdBystringnoID of the user who created this resource
visibilitystringyesChat visibility: public, private, widget, job, or incognito

Allowed: public, private, widget, incognito | | primaryRole | string | yes | Primary agent ID or role for the chat | | plannerAgent | string | no | Orchestrator/planner agent ID for the chat | | name | string | yes | Name of the resource | | allowMultipleRoles | boolean | no | Whether multiple agents can participate in the chat | | isAIReplying | boolean | no | Whether the AI is currently replying | | creationTime | integer | yes | Unix timestamp when the resource was created | | description | string | no | Detailed description of purpose and capabilities | | topics | string | no | JSON-encoded list of topics associated with the chat | | metadata | string | no | Arbitrary metadata key-value pairs (JSON) | | documentId | string | no | ID of an associated document | | language | string | no | Language code for the chat (e.g. en, es) | | summary | string | no | Summary of the conversation | | caseId | string | no | Associated case ID (for case management) | | customerId | string | no | Associated customer ID | | caseInfo | string | no | JSON-encoded case information | | customerInfo | string | no | JSON-encoded customer information | | channelSettings | string | no | JSON-encoded communication channel settings for the chat | | externalParticipantId | string | no | ID of an external participant in the chat | | status | string | no | Current status of the resource | | activeMessageForAI | string | no | The active message being processed by the AI | | chatHistory | string | no | JSON-encoded conversation history | | primaryAgent | string | no | Primary agent ID for the chat | | forcePlannerStop | boolean | no | Whether to force-stop the planner | | handedOffToHuman | boolean | no | Whether the chat was handed off to a human | | roles | string | no | JSON-encoded list of roles in the chat | | projectId | string | no | Associated project ID | | projectInfo | string | no | JSON-encoded project information | | genericEntityId | string | no | ID of a generic entity associated with the chat | | genericEntityInfo | string | no | JSON-encoded generic entity information | | userFeedbackOnSteps | string | no | JSON-encoded user feedback on individual plan steps | | sourceJobID | string | no | ID of the scheduled job that created this chat (if any) | | canvasID | string | no | ID of the canvas workspace associated with the chat | | canvasOperations | string | no | JSON-encoded canvas operations | | canvasLastChangesetID | string | no | ID of the last canvas changeset | | canvasLastChangesetTimestamp | integer | no | Timestamp of the last canvas changeset | | piiDetected | boolean | no | Whether personally identifiable information was detected | | piiTypes | string | no | List of PII types detected | | piiOccurrences | string | no | JSON-encoded PII occurrence details | | toxicityDetected | boolean | no | Whether toxic content was detected | | toxicityScore | string | no | Toxicity score (0.0-1.0) | | toxicityCategories | string | no | JSON-encoded toxicity category scores | | customerSatisfactionScore | integer | no | Customer satisfaction score | | customerSatisfactionFeedback | string | no | Customer satisfaction feedback text | | requestCompleted | boolean | no | Whether the request was completed | | requestCompletionScore | string | no | Request completion score (0.0-1.0) | | escalationRequired | boolean | no | Whether escalation to a human is required | | escalationReason | string | no | Reason for escalation | | qualityScore | string | no | Quality score (0.0-1.0) | | qualityNotes | string | no | Quality assessment notes | | planMode | string | no | Plan mode (e.g. plan, act) | | planFile | string | no | File associated with the plan | | askBeforeExec | boolean | no | Whether to ask before executing plan steps | | planStatus | string | no | Status of the plan | | owner | string | no | Owner of this resource | | updatedBy | string | no | ID of the user who last updated this resource |

The Python SDK accepts snake_case keyword arguments and converts them to the camelCase wire fields shown above.

Response fields

FieldTypeDescription
idstringUnique identifier for the chat session
ownerstringOwner of this resource
namestringHuman-readable name of the chat session
descriptionstringOptional description of the chat purpose
statusobjectCurrent status of the resource
workspaceIDstringUnique workspace identifier (UUID v4)
creationTimeintegerUnix timestamp of chat creation
createdBystringUser ID who created the chat
updatedBystringID of the user who last updated this resource
visibilitystringChat visibility level

Allowed: public, private, widget, job, incognito | | isAIReplying | boolean | Whether the AI is currently replying | | activeMessageForAI | string | The active message being processed by the AI | | chatHistory | string | JSON-encoded conversation history | | topics | object | Topic IDs for content scope limitation (retriever agents only) | | documentId | string | Single document ID for knowledge retrieval (retriever agents only) | | primaryRole | string | Primary agent ID associated with the chat | | primaryAgent | string | Primary agent ID for the chat | | plannerAgent | string | Orchestrator agent ID for multi-agent coordination | | forcePlannerStop | boolean | Whether to force-stop the planner | | allowMultipleRoles | boolean | Whether multiple agents can participate in the chat | | handedOffToHuman | boolean | Whether the chat was handed off to a human | | roles | array<string> | JSON-encoded list of roles in the chat | | language | string | ISO language code for chat localization | | summary | string | Auto-generated conversation summary | | caseId | string | Associated support case identifier | | customerId | string | Associated customer identifier | | caseInfo | object | Additional case-related metadata | | customerInfo | object | Additional customer-related metadata | | projectId | string | Associated project ID | | projectInfo | object | JSON-encoded project information | | genericEntityId | string | ID of a generic entity associated with the chat | | genericEntityInfo | object | JSON-encoded generic entity information | | metadata | object | Arbitrary metadata key-value pairs (JSON) | | userFeedbackOnSteps | object | JSON-encoded user feedback on individual plan steps | | channelSettings | object | Multi-channel communication settings | | sourceJobID | string | ID of the scheduled job that created this chat (if any) | | canvasID | string | ID of the canvas workspace associated with the chat | | canvasOperations | object | JSON-encoded canvas operations | | canvasLastChangesetID | string | ID of the last canvas changeset | | canvasLastChangesetTimestamp | integer | Timestamp of the last canvas changeset | | externalParticipantId | string | External participant identifier (email, phone, etc.) | | piiDetected | boolean | Whether personally identifiable information was detected | | piiTypes | array<string> | List of PII types detected | | piiOccurrences | integer | JSON-encoded PII occurrence details | | toxicityDetected | boolean | Whether toxic content was detected | | toxicityScore | number | Toxicity score (0.0-1.0) | | toxicityCategories | array<string> | JSON-encoded toxicity category scores | | customerSatisfactionScore | number | Customer satisfaction score | | customerSatisfactionFeedback | string | Customer satisfaction feedback text | | requestCompleted | boolean | Whether the request was completed | | requestCompletionScore | number | Request completion score (0.0-1.0) | | escalationRequired | boolean | Whether escalation to a human is required | | escalationReason | string | Reason for escalation | | qualityScore | string | Quality score (0.0-1.0) | | qualityNotes | string | Quality assessment notes | | planMode | boolean | Plan mode (e.g. plan, act) | | planFile | string | File associated with the plan | | askBeforeExec | boolean | Whether to ask before executing plan steps | | planStatus | string | Status of the plan | | createdAt | string | Timestamp when this resource was created | | updatedAt | string | Timestamp when this resource was last updated |

Example

client.chat.create()

update

Update an existing chat.

def update(
chat_id: str,
name: Optional[str] = None,
customer_id: Optional[str] = None,
customer_info: Optional[Dict[str, Any]] = None,
primary_role: Optional[str] = None,
external_participant_id: Optional[str] = None,
channel_settings: Optional[Dict[str, str]] = None
) -> Chat

Endpoint: POST /chat/update · API service

Request fields

FieldTypeRequiredDescription
idstringyesUnique identifier
workspaceidstringnoUnique workspace identifier (UUID v4)
createdBystringnoID of the user who created this resource
visibilitystringnoChat visibility: public, private, widget, job, or incognito

Allowed: public, private, widget, incognito | | primaryRole | string | no | Primary agent ID or role for the chat | | plannerAgent | string | no | Orchestrator/planner agent ID for the chat | | name | string | no | Name of the resource | | allowMultipleRoles | boolean | no | Whether multiple agents can participate in the chat | | isAIReplying | boolean | no | Whether the AI is currently replying | | creationTime | integer | no | Unix timestamp when the resource was created | | description | string | no | Detailed description of purpose and capabilities | | topics | string | no | JSON-encoded list of topics associated with the chat | | metadata | string | no | Arbitrary metadata key-value pairs (JSON) | | documentId | string | no | ID of an associated document | | language | string | no | Language code for the chat (e.g. en, es) | | summary | string | no | Summary of the conversation | | caseId | string | no | Associated case ID (for case management) | | customerId | string | no | Associated customer ID | | caseInfo | string | no | JSON-encoded case information | | customerInfo | string | no | JSON-encoded customer information | | channelSettings | string | no | JSON-encoded communication channel settings for the chat | | externalParticipantId | string | no | ID of an external participant in the chat | | status | string | no | Current status of the resource | | activeMessageForAI | string | no | The active message being processed by the AI | | chatHistory | string | no | JSON-encoded conversation history | | primaryAgent | string | no | Primary agent ID for the chat | | forcePlannerStop | boolean | no | Whether to force-stop the planner | | handedOffToHuman | boolean | no | Whether the chat was handed off to a human | | roles | string | no | JSON-encoded list of roles in the chat | | projectId | string | no | Associated project ID | | projectInfo | string | no | JSON-encoded project information | | genericEntityId | string | no | ID of a generic entity associated with the chat | | genericEntityInfo | string | no | JSON-encoded generic entity information | | userFeedbackOnSteps | string | no | JSON-encoded user feedback on individual plan steps | | sourceJobID | string | no | ID of the scheduled job that created this chat (if any) | | canvasID | string | no | ID of the canvas workspace associated with the chat | | canvasOperations | string | no | JSON-encoded canvas operations | | canvasLastChangesetID | string | no | ID of the last canvas changeset | | canvasLastChangesetTimestamp | integer | no | Timestamp of the last canvas changeset | | piiDetected | boolean | no | Whether personally identifiable information was detected | | piiTypes | string | no | List of PII types detected | | piiOccurrences | string | no | JSON-encoded PII occurrence details | | toxicityDetected | boolean | no | Whether toxic content was detected | | toxicityScore | string | no | Toxicity score (0.0-1.0) | | toxicityCategories | string | no | JSON-encoded toxicity category scores | | customerSatisfactionScore | integer | no | Customer satisfaction score | | customerSatisfactionFeedback | string | no | Customer satisfaction feedback text | | requestCompleted | boolean | no | Whether the request was completed | | requestCompletionScore | string | no | Request completion score (0.0-1.0) | | escalationRequired | boolean | no | Whether escalation to a human is required | | escalationReason | string | no | Reason for escalation | | qualityScore | string | no | Quality score (0.0-1.0) | | qualityNotes | string | no | Quality assessment notes | | planMode | string | no | Plan mode (e.g. plan, act) | | planFile | string | no | File associated with the plan | | askBeforeExec | boolean | no | Whether to ask before executing plan steps | | planStatus | string | no | Status of the plan | | owner | string | no | Owner of this resource | | updatedBy | string | no | ID of the user who last updated this resource |

The Python SDK accepts snake_case keyword arguments and converts them to the camelCase wire fields shown above.

Response

Returns the Chat object — fields documented in the create section above.

Example

client.chat.update(chat_id="agent-id")

get

Get a chat by ID.

def get(chat_id: str) -> Chat

Endpoint: GET /chat/get/{chat_id} · API service

Response fields

No fields.

Example

client.chat.get(chat_id="agent-id")

list

List all chats.

def list(
limit: Optional[int] = None,
offset: Optional[int] = None
) -> ListResponse

Endpoint: GET /chat/list · API service

Example

client.chat.list()

delete

Delete a chat.

def delete(chat_id: str) -> Dict[str, bool]

Endpoint: DELETE /chat/delete/{chat_id} · API service

Response fields

FieldTypeDescription
successbooleanOperation success status
dataobjectResponse data
messagestringOptional success message

Example

client.chat.delete(chat_id="agent-id")

create_message

Create a message in a chat.

def create_message(
chat_id: str,
text: str,
role: str = 'user',
user_id: str = '',
images: Optional[List[str]] = None,
audios: Optional[List[str]] = None,
videos: Optional[List[str]] = None,
files: Optional[List[str]] = None
) -> Message

Endpoint: POST /chat_message/create · API service

Request fields

FieldTypeRequiredDescription
idstringnoUnique identifier
workspaceidstringyesUnique workspace identifier (UUID v4)
rolestringyesMessage author role: system, user, or assistant

Allowed: system, user, assistant | | chatID | string | yes | ID of the chat this message belongs to | | text | string | yes | The message text content | | t_text | string | no | Translated text of the message | | t_text_summary | string | no | Translated summary of the message text | | createdAt | string | no | Timestamp when this resource was created | | creationTime | integer | no | Unix timestamp when the resource was created | | updatedAt | string | no | Timestamp when this resource was last updated | | humanFeedback | string | no | Human feedback on the message: positive, negative, or neutral | | humanFeedbackComment | string | no | Comment accompanying the human feedback | | humanFeedbackType | string | no | Type of human feedback: multilanguage, documentation, reasoning, images, charting, api, code, math, or moderation | | humanFeedbackSubType | string | no | Sub-type of human feedback (varies by parent type) | | humanFeedbackProvidedBy | string | no | User who provided the human feedback | | adminResolution | string | no | Admin resolution notes for the feedback | | prevMessage | string | no | Previous message text (for context) | | prevMessagePosEq | string | no | List of positive equivalence annotations on the previous message | | prevMessageNegEq | string | no | List of negative equivalence annotations on the previous message | | correctContext | string | no | Corrected context for the message | | correctAnswer | string | no | Corrected answer for the message | | adminChecked | boolean | no | Whether an admin has reviewed this message | | autoTune | boolean | no | Whether auto-tuning from feedback is enabled | | userID | string | no | ID of the user associated with this resource | | agentID | string | no | ID of the agent associated with this resource | | images | string | no | List of image file keys attached to the message | | audios | string | no | List of audio file keys attached to the message | | videos | string | no | List of video file keys attached to the message | | files | string | no | List of file keys associated with the benchmark | | imagesText | string | no | Extracted text from attached images | | audiosText | string | no | Transcribed text from attached audios | | videosText | string | no | Extracted text from attached videos | | filesText | string | no | Extracted text from attached files | | isAI | boolean | no | Whether the message was generated by the AI | | messageType | string | no | Message type: system, handoff, or notification

Allowed: system, handoff, notification | | status | string | no | Current status of the resource

Allowed: success, failed, timeout, fulfilled, pending, inProgress, cancelled | | metadata | string | no | Arbitrary metadata key-value pairs (JSON) | | callbackMetadata | string | no | JSON-encoded metadata from a callback | | scoring | string | no | JSON-encoded quality scoring for the message | | embeddingId | string | no | ID of the embedding associated with the message | | humanFeedbackForInstruction | string | no | Human feedback for instruction tuning |

The Python SDK accepts snake_case keyword arguments and converts them to the camelCase wire fields shown above.

Response fields

FieldTypeDescription
idstringUnique identifier for the chat message
rolestringRole of the message sender

Allowed: system, user, assistant | | chatID | string | ID of the chat this message belongs to | | text | string | The message text content | | t_text | string | Translated message content | | t_text_summary | string | Summary of translated content | | createdAt | string | Message creation timestamp | | creationTime | integer | Unix timestamp of message creation | | updatedAt | string | Message last update timestamp | | scoring | integer | JSON-encoded quality scoring for the message | | embeddingId | string | ID of the embedding associated with the message | | humanFeedback | string | Human feedback rating

Allowed: positive, negative, neutral | | humanFeedbackComment | string | Additional feedback comments | | humanFeedbackType | string | Category of feedback provided

Allowed: multilanguage, documentation, reasoning, images, charting, api, code, math, moderation | | humanFeedbackSubType | string | Subcategory of feedback | | humanFeedbackProvidedBy | string | User ID who provided feedback | | adminResolution | string | Administrative resolution notes | | prevMessage | string | Previous message text (for context) | | prevMessagePosEq | array<string> | List of positive equivalence annotations on the previous message | | prevMessageNegEq | array<string> | List of negative equivalence annotations on the previous message | | correctContext | string | Corrected context for the message | | correctAnswer | string | Corrected answer for the message | | adminChecked | boolean | Whether an admin has reviewed this message | | autoTune | boolean | Whether auto-tuning from feedback is enabled | | userID | string | ID of the user who sent the message | | agentID | string | ID of the AI agent (for planner-based chats) | | humanFeedbackForInstruction | boolean | Human feedback for instruction tuning | | images | array<string> | Array of image URLs attached to the message | | audios | array<string> | Array of audio file URLs attached to the message | | videos | array<string> | Array of video file URLs attached to the message | | files | array<string> | Array of file URLs attached to the message | | imagesText | string | Extracted text from attached images | | audiosText | string | Transcribed text from attached audios | | videosText | string | Extracted text from attached videos | | filesText | string | Extracted text from attached files | | isAI | boolean | Whether the message was generated by AI | | messageType | string | Special message type classification

Allowed: system, handoff, notification, continuation | | status | string | Current processing status of the message

Allowed: success, failed, timeout, fulfilled, pending, inProgress, cancelled, awaitingUserInput, continued, ingested | | metadata | object | Arbitrary metadata key-value pairs (JSON) | | callbackMetadata | object | JSON-encoded metadata from a callback | | workspaceID | string | Unique workspace identifier (UUID v4) |

Example

client.chat.create_message(chat_id="agent-id", text="…")

get_message

Get a message by ID.

def get_message(message_id: str) -> Message

Endpoint: GET /chat_message/get/{message_id} · API service

Response

Returns the ChatMessage object — fields documented in the create-message section above.

Example

client.chat.get_message(message_id="agent-id")

update_message

Update a message.

def update_message(
message_id: str,
text: Optional[str] = None,
role: Optional[str] = None,
user_id: Optional[str] = None,
images: Optional[List[str]] = None,
audios: Optional[List[str]] = None,
videos: Optional[List[str]] = None,
files: Optional[List[str]] = None
) -> Message

Endpoint: POST /chat_message/update · API service

Request fields

FieldTypeRequiredDescription
idstringyesUnique identifier
workspaceidstringnoUnique workspace identifier (UUID v4)
rolestringnoMessage author role: system, user, or assistant

Allowed: system, user, assistant | | chatID | string | no | ID of the chat this message belongs to | | text | string | no | The message text content | | t_text | string | no | Translated text of the message | | t_text_summary | string | no | Translated summary of the message text | | createdAt | string | no | Timestamp when this resource was created | | creationTime | integer | no | Unix timestamp when the resource was created | | updatedAt | string | no | Timestamp when this resource was last updated | | humanFeedback | string | no | Human feedback on the message: positive, negative, or neutral | | humanFeedbackComment | string | no | Comment accompanying the human feedback | | humanFeedbackType | string | no | Type of human feedback: multilanguage, documentation, reasoning, images, charting, api, code, math, or moderation | | humanFeedbackSubType | string | no | Sub-type of human feedback (varies by parent type) | | humanFeedbackProvidedBy | string | no | User who provided the human feedback | | adminResolution | string | no | Admin resolution notes for the feedback | | prevMessage | string | no | Previous message text (for context) | | prevMessagePosEq | string | no | List of positive equivalence annotations on the previous message | | prevMessageNegEq | string | no | List of negative equivalence annotations on the previous message | | correctContext | string | no | Corrected context for the message | | correctAnswer | string | no | Corrected answer for the message | | adminChecked | boolean | no | Whether an admin has reviewed this message | | autoTune | boolean | no | Whether auto-tuning from feedback is enabled | | userID | string | no | ID of the user associated with this resource | | agentID | string | no | ID of the agent associated with this resource | | images | string | no | List of image file keys attached to the message | | audios | string | no | List of audio file keys attached to the message | | videos | string | no | List of video file keys attached to the message | | files | string | no | List of file keys associated with the benchmark | | imagesText | string | no | Extracted text from attached images | | audiosText | string | no | Transcribed text from attached audios | | videosText | string | no | Extracted text from attached videos | | filesText | string | no | Extracted text from attached files | | isAI | boolean | no | Whether the message was generated by the AI | | messageType | string | no | Message type: system, handoff, or notification

Allowed: system, handoff, notification | | status | string | no | Current status of the resource

Allowed: success, failed, timeout, fulfilled, pending, inProgress, cancelled | | metadata | string | no | Arbitrary metadata key-value pairs (JSON) | | callbackMetadata | string | no | JSON-encoded metadata from a callback | | scoring | string | no | JSON-encoded quality scoring for the message | | embeddingId | string | no | ID of the embedding associated with the message | | humanFeedbackForInstruction | string | no | Human feedback for instruction tuning |

The Python SDK accepts snake_case keyword arguments and converts them to the camelCase wire fields shown above.

Response

Returns the ChatMessage object — fields documented in the create-message section above.

Example

client.chat.update_message(message_id="agent-id")

list_messages

List messages in a chat.

def list_messages(
chat_id: str,
limit: Optional[int] = None,
offset: Optional[int] = None
) -> ListResponse

Endpoint: GET /chat_message/list · API service

Example

client.chat.list_messages(chat_id="agent-id")

send_to_agent

Send a message to an AI agent.

def send_to_agent(
message: str,
agent_id: str,
chat_id: Optional[str] = None,
phone_number: Optional[str] = None,
customer_id: Optional[str] = None,
provider_id: Optional[str] = None,
customer_info: Optional[Dict[str, Any]] = None,
attachments: Optional[Attachments] = None
) -> AgentResponse

Endpoint: POST /agent · AI service

The SDK routes this call via its internal chatter endpoint alias; the canonical API operation is /agent.

Request fields

FieldTypeRequiredDescription
workspaceidstringyesUnique workspace identifier
chatidstringnoChat ID. Omit to create a new chat (a new ID is returned in the stream).
agentidstringyesAgent ID to handle the conversation
messagesarray<object>yesMessages to send to the Agent
chat_historyarray<object>noProvide conversation context from previous turns without persisting.
base_imagestringnoBase image key for vision-enabled agents. Used as visual context for the conversation. Upload via document API first.
storeMessagesbooleannoWhether to persist the generated messages to the chat (camelCase; the backend reads storeMessages, not store_messages)
nextMessageIdstringnoOptional ID for the next message (for client-side correlation)
external_channel_typestringnoOptional external channel type (e.g. whatsapp, sms, email) when the request originates from a channel
email_metadataobjectnoOptional email metadata (subject, from, to, etc.) when the request originates from email
plannerAgentstringnoOptional planner/orchestrator agent ID for the conversation
from_plannerbooleannoWhether this request is being made from a planner flow
namestringnoOptional chat name (defaults to "New Chat" when creating a new chat)

The Python SDK accepts snake_case keyword arguments and converts them to the camelCase wire fields shown above.

Response fields

FieldTypeDescription
contentsobjectChat response content
workspaceidstringWorkspace identifier associated with the Agent

Example

client.chat.send_to_agent(message="…", agent_id="agent-id")