Skip to content
QwryAI
Documentation
Pages

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.

POSThttps://api.qwryai.com/api/v2/agents/{agentId}/conversations/{conversationId}/retry

Authentication

Send your API key as Authorization: Bearer <api-key>. The key needs Chat with agents. See Authentication.

Path parameters

NameTypeRequiredDescription
agentIdstringYesThe agent's id, from list_agents.
conversationIdstringYesThe conversation's id, from the answer's metadata.conversationId.

Body parameters

NameTypeRequiredDescription
messageIdstringYesThe id of the agent answer to regenerate: data.id from a non-streamed answer, or messageId from a stream's start and finish events.
streambooleanNoStream the new answer as Server-Sent Events. Defaults to true.

Any other field is refused with VALIDATION_INVALID_BODY.

Request example

Bash
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
  }'

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.

JSON
{
  "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 statusCodeWhen
400VALIDATION_INVALID_BODYNo messageId, or an unknown field.
400CHAT_RETRY_NO_USER_MESSAGENo customer message comes before that answer.
401AUTH_MISSING_API_KEY / AUTH_INVALID_API_KEYNo key, or an unknown, deleted or expired key.
402CHAT_CREDITS_EXHAUSTEDNot enough message credits for a new answer.
403SUBSCRIPTION_API_RESTRICTED_PLANThe workspace's plan doesn't include API access.
403CHAT_CONVERSATION_MISMATCHThe conversation doesn't exist or belongs to another agent.
404AGENT_NOT_FOUNDNo agent with that id in your workspace.
404CHAT_RETRY_MESSAGE_NOT_FOUNDmessageId isn't an agent answer in this conversation.
409CHAT_CONVERSATION_NOT_ONGOINGThe conversation ended or was taken over, another answer is still being written, or a client action is waiting for its result.
429RATE_LIMIT_TOO_MANY_REQUESTSToo many requests or open streams. Wait for Retry-After seconds.

See Error Handling for every code.

Explore the documentation