Endpoints
Retry a message
Throw away one of the agent's answers and write it again
Retry regenerates an agent answer in a conversation you started with the Chat API. QwryAI finds the customer message the answer replied to, deletes that answer and everything after it, and answers the customer message again. Use it when an answer failed, was cut off, or you want a fresh one. The new answer gets a new id and uses message credits like any other.
https://api.qwryai.com/api/v2/agents/{agentId}/conversations/{conversationId}/retryAuthentication
Send your API key as Authorization: Bearer <api-key>. The key needs Chat with agents. See Authentication.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
agentId | string | Yes | The agent's id, from list_agents. |
conversationId | string | Yes | The conversation's id, from the answer's metadata.conversationId. |
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
messageId | string | Yes | The id of the agent answer to regenerate: data.id from a non-streamed answer, or messageId from a stream's start and finish events. |
stream | boolean | No | Stream the new answer as Server-Sent Events. Defaults to true. |
Any other field is refused with VALIDATION_INVALID_BODY.
Request example
curl -X POST 'https://api.qwryai.com/api/v2/agents/YOUR_AGENT_ID/conversations/fd5ae9e1-9b30-4503-b346-ccd4d7ef16a3/retry' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"messageId": "5b0e7c1a-2f4d-4c55-9a51-6d8e3f2b9c10",
"stream": false
}'const conversationId = "fd5ae9e1-9b30-4503-b346-ccd4d7ef16a3";
const response = await fetch(
`https://api.qwryai.com/api/v2/agents/YOUR_AGENT_ID/conversations/${conversationId}/retry`,
{
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
messageId: "5b0e7c1a-2f4d-4c55-9a51-6d8e3f2b9c10",
stream: false,
}),
}
);
const { data } = await response.json();import requests
conversation_id = "fd5ae9e1-9b30-4503-b346-ccd4d7ef16a3"
response = requests.post(
f"https://api.qwryai.com/api/v2/agents/YOUR_AGENT_ID/conversations/{conversation_id}/retry",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"messageId": "5b0e7c1a-2f4d-4c55-9a51-6d8e3f2b9c10", "stream": False},
)
data = response.json()["data"]Response
The new answer, in the same shape as Chat with an agent. With streaming on, you get the same events as a chat stream.
{
"data": {
"id": "9e2d4b7c-61a3-4f0e-8c5d-2b7a9f1e3c48",
"role": "assistant",
"parts": [
{ "type": "text", "text": "Order 1042 left our warehouse on Monday. UPS expects to deliver it by Friday." }
],
"metadata": {
"conversationId": "fd5ae9e1-9b30-4503-b346-ccd4d7ef16a3",
"userMessageId": "0c4f6a2e-8d13-4b7a-b0e9-1a2c3d4e5f60",
"userId": "customer_1042",
"finishReason": "stop",
"usage": { "credits": 1 }
}
}
}userMessageId is the customer message that was answered again. data.id is the new answer's id; the old one no longer exists.
Errors
| HTTP status | Code | When |
|---|---|---|
| 400 | VALIDATION_INVALID_BODY | No messageId, or an unknown field. |
| 400 | CHAT_RETRY_NO_USER_MESSAGE | No customer message comes before that answer. |
| 401 | AUTH_MISSING_API_KEY / AUTH_INVALID_API_KEY | No key, or an unknown, deleted or expired key. |
| 402 | CHAT_CREDITS_EXHAUSTED | Not enough message credits for a new answer. |
| 403 | SUBSCRIPTION_API_RESTRICTED_PLAN | The workspace's plan doesn't include API access. |
| 403 | CHAT_CONVERSATION_MISMATCH | The conversation doesn't exist or belongs to another agent. |
| 404 | AGENT_NOT_FOUND | No agent with that id in your workspace. |
| 404 | CHAT_RETRY_MESSAGE_NOT_FOUND | messageId isn't an agent answer in this conversation. |
| 409 | CHAT_CONVERSATION_NOT_ONGOING | The conversation ended or was taken over, another answer is still being written, or a client action is waiting for its result. |
| 429 | RATE_LIMIT_TOO_MANY_REQUESTS | Too many requests or open streams. Wait for Retry-After seconds. |
See Error Handling for every code.