Rest API
Retrieving an answer (async)
GET /api/v1/ai/async/answer
Retrieve the result of an asynchronous AI query using the questionId returned from /v1/ai/async/query. This endpoint returns the current processing status and the full ChatData response when complete.
Status values
- PENDING: Query is queued for processing
- PROCESSING: Query is currently being processed
- DONE: Query completed successfully,
chatDatacontains the result - ERROR: Query failed,
errorcontains the error message
Usage flow
- First, submit a query using
/v1/ai/async/queryto get aquestionId - Poll this endpoint using the
questionIdto check the status - Continue polling until status changes to
DONEorERROR - When
DONE, the full AI response is available in thechatDataobject
Parameters
Section titled “ Parameters ”Header Parameters
Section titled “Header Parameters ”Your API key from account settings.
The email address of your user.
The ID of your account. You can find this in the account settings.
The ID of the workspace you want to use.
Query Parameters
Section titled “Query Parameters ”The questionId returned from /v1/ai/async/query.
Responses
Section titled “ Responses ”Current status and, when complete, the chat data.
object
PENDING — queued, PROCESSING — actively running, DONE — completed (chatData present), ERROR — failed (error present).
Conversation state object returned by query endpoints.
object
Array of conversation turns.
object
object
Arbitrary metadata associated with the conversation.
object
Example
{ "history": [ { "type": "message", "timestamp": 1687956110772, "uuid": "57c1968c-1b49-48d5-a484-ed299e609b8a", "hidden": false, "sender": "user", "message": "What does Unless do?", "metadata": [], "languageCode": "en", "showMetadata": false, "canGetFeedback": false, "feedback": "" }, { "type": "message", "timestamp": 1687956112605, "uuid": "5aa331df-1e6d-4ee2-b6aa-93176e521469", "hidden": false, "sender": "bot", "canGetFeedback": true, "message": "Unless is a tool that allows companies to create highly personalized and compelling landing pages to highlight their benefits compared to competitors. It also offers AI training to become an expert in a company's product and provides conversational UI components.", "metadata": [ { "title": "Rapid experimentation", "isPublic": true, "isUsedForAnswer": true, "source": "https://unless.com/en/blog/customer-cases/rapid-experimentation-at-prenatal/", "documentId": "4c0cbe48-bd8b-403e-bbad-3d16a9c679c9", "stableId": "c37310599c08a2a2d5295fbd98c42a34", "trainingDataId": "1e61e2e6-8b3f-4b90-8703-a40aa6d7783f" } ], "showMetadata": false, "feedback": "" } ], "metadata": {}, "toolsetName": null, "personalizationId": "", "sessionId": "23d1b8d1-64f5-4dd2-8122-73e56d0c78ff", "conversationName": null, "conversationId": "e796d388-ddb3-4ab6-9891-06f2e4dd16cb"}Examples
Pending status
{ "questionId": "550e8400-e29b-41d4-a716-446655440000", "status": "PENDING"}Processing status
{ "questionId": "550e8400-e29b-41d4-a716-446655440000", "status": "PROCESSING"}Completed response
{ "questionId": "550e8400-e29b-41d4-a716-446655440000", "status": "DONE", "chatData": { "history": [ { "type": "message", "sender": "user", "message": "What does Unless do?", "timestamp": 1687956110772 }, { "type": "message", "sender": "bot", "message": "Unless helps companies create personalized experiences...", "timestamp": 1687956112605, "metadata": [] } ], "conversationId": "async-550e8400-e29b-41d4-a716-446655440000", "sessionId": "session-123" }}Error response
{ "questionId": "550e8400-e29b-41d4-a716-446655440000", "status": "ERROR", "error": "Timeout processing query"}