API Reference
The reference below covers every endpoint in the Chat API. Code examples are generated automatically; the live playground is disabled to prevent accidental writes to production from the docs site.
/api/v1/chatsAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Query Parameters
Which queue to list. Omit for everything not in spam or trash.
Value in
- "waiting"
- "open"
- "closed"
- "spam"
- "trash"
- "all"
Who is answering the visitor. Case-insensitive.
Value in
- "AI"
- "HUMAN"
- "WAITING"
Only conversations assigned to this workspace user. Pass none for unassigned ones.
Only conversations on this chat site.
Only conversations with a message at or after this ISO 8601 datetime. updatedSince is accepted as an alias.
date-timePage size.
1 <= value <= 1000100The nextCursor value from the previous page.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X GET "https://example.com/api/v1/chats"{ "chats": [ { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" } ], "nextCursor": "string"}{ "error": "status must be one of: waiting, open, closed, spam, trash, all."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: read:chat."}{ "error": "Rate limit exceeded."}/api/v1/chats/{id}Authorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Query Parameters
Only return messages after this message id.
Maximum number of messages to return.
1 <= value <= 500500Response Body
application/json
application/json
application/json
application/json
application/json
curl -X GET "https://example.com/api/v1/chats/string"{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }, "messages": [ { "id": "string", "role": "VISITOR", "userId": "string", "userName": "string", "body": "string", "createdAt": "2019-08-24T14:15:22Z" } ], "messagesNextCursor": "string"}{ "error": "limit must be an integer between 1 and 500."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: read:chat."}{ "error": "Conversation not found."}/api/v1/chats/{id}/replyAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/chats/string/reply" \ -H "Content-Type: application/json" \ -d '{ "body": "Yes, we ship to Canada. Most orders arrive in 3 to 5 business days." }'{ "message": { "id": "string", "role": "VISITOR", "userId": "string", "userName": "string", "body": "string", "createdAt": "2019-08-24T14:15:22Z" }, "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "asUserId (or asUserEmail) is required to reply: name the workspace member the visitor will see."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "Conversation not found."}/api/v1/chats/{id}/take-overAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
The workspace member the action is taken as. Give one of the two.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/chats/string/take-over" \ -H "Content-Type: application/json" \ -d '{ "asUserId": "cmq1user0alk34567890" }'{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "asUserId (or asUserEmail) is required to take over a chat: name the workspace member the visitor will see."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "Conversation not found."}/api/v1/chats/{id}/hand-backAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
The workspace member the action is taken as. Give one of the two.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/chats/string/hand-back" \ -H "Content-Type: application/json" \ -d '{}'{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "Only the person handling this chat can hand it back."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "Conversation not found."}/api/v1/chats/{id}/closeAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
The workspace member the action is taken as. Give one of the two.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/chats/string/close" \ -H "Content-Type: application/json" \ -d '{}'{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "asUserId \"cmq1user9alk34567890\" is not a member of this workspace."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "Conversation not found."}/api/v1/chats/{id}/reopenAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
The workspace member the action is taken as. Give one of the two.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/chats/string/reopen" \ -H "Content-Type: application/json" \ -d '{}'{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "asUserId \"cmq1user9alk34567890\" is not a member of this workspace."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "Conversation not found."}/api/v1/chats/{id}/assignAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/chats/string/assign" \ -H "Content-Type: application/json" \ -d '{ "assigneeId": "cmq1user0alk34567890" }'{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "assigneeId \"cmq1user9alk34567890\" is not an active member of this workspace."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "Conversation not found."}/api/v1/chats/{id}/tagsAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Give tagId or name.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/chats/string/tags" \ -H "Content-Type: application/json" \ -d '{ "name": "Pricing" }'{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "Pass tagId (an existing tag) or name."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "Tag not found."}/api/v1/chats/{id}/tagsAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Query Parameters
The tag to remove.
The tag to remove, by name, instead of tagId.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X DELETE "https://example.com/api/v1/chats/string/tags"{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "Pass tagId (an existing tag) or name."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "No tag named \"Pricing\" in this workspace."}/api/v1/chats/{id}/spamAuthorization
BearerAuth Pass an API key issued from the agentlyleads workspace settings.
Example: Authorization: Bearer alk_live_xxxxxxxxxxxx
In: header
Path Parameters
The chat conversation ID.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/chats/string/spam" \ -H "Content-Type: application/json" \ -d '{ "spam": true }'{ "chat": { "id": "cmq5chat0alk34567890", "threadKey": "chat:cmq5chat0alk34567890", "status": "OPEN", "spam": true, "trashed": true, "handler": "AI", "handlerUser": { "id": "string", "name": "string" }, "waitingReason": "TEAM_MODE", "waitingSince": "2019-08-24T14:15:22Z", "waitingMins": 0, "live": true, "hot": true, "site": { "id": "string", "name": "string" }, "visitor": { "name": "string", "email": "string", "phone": "string", "pageUrl": "string", "referrer": "string", "locale": "string", "timezone": "string", "blocked": true, "blockedUntil": "2019-08-24T14:15:22Z" }, "contact": { "id": "string", "name": "string", "email": "string" }, "lead": { "id": "string", "name": "string", "email": "string" }, "assignee": { "id": "string", "name": "string" }, "tags": [ { "id": "string", "name": "string", "color": "string" } ], "subject": "string", "snippet": "string", "messageCount": 0, "lastMessageAt": "2019-08-24T14:15:22Z", "lastVisitorAt": "2019-08-24T14:15:22Z", "lastAgentAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z" }}{ "error": "spam is required: true to mark as spam and block the visitor, false to undo."}{ "error": "Invalid or missing API key."}{ "error": "API key missing required scope: write:chat."}{ "error": "Conversation not found."}