Retrieving an answer (async)

Retrieve the result of an asynchronous AI query using the questionId returned from the async query endpoint.

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, chatData contains the result
  • ERROR: Query failed, error contains the error message

Example requests

curl -X GET "https://rest-endpoint.unless.com/api/v1/ai/async/answer?questionId=550e8400-e29b-41d4-a716-446655440000" \
  -H "x-api-key: your-api-key-here"

Example responses

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"
}

Usage flow

  1. First, submit a query using /v1/ai/async/query to get a questionId
  2. Poll this endpoint using the questionId to check the status
  3. Continue polling until status changes to DONE or ERROR
  4. When DONE, the full AI response is available in the chatData object

Response headers

  • Access-Control-Allow-Origin: CORS header for browser requests
Language