Rest API
Sending a question (async)
const url = 'https://api.unless.com/api/v1/ai/async/query';const options = { method: 'POST', headers: { 'x-api-key': 'example', 'x-user-email': 'example', 'x-account-id': 'example', 'x-website-id': 'example', 'Content-Type': 'application/json' }, body: '{"query":"example","sessionId":"example","visitorId":"example","segmentId":"example","metadata":{},"conversationName":"example","audienceId":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.unless.com/api/v1/ai/async/query \ --header 'Content-Type: application/json' \ --header 'x-account-id: example' \ --header 'x-api-key: example' \ --header 'x-user-email: example' \ --header 'x-website-id: example' \ --data '{ "query": "example", "sessionId": "example", "visitorId": "example", "segmentId": "example", "metadata": {}, "conversationName": "example", "audienceId": "example" }'Submit AI queries for asynchronous processing using the Unless API. This returns a questionId to retrieve the results later.
The async AI query endpoint allows you to submit questions for background processing, ideal for long-running queries or batch processing scenarios where immediate response is not required.
How it works
- Submit query: Send your question to
/ai/async/query - Get question ID: Receive a
questionIdimmediately - Retrieve results: Use the
questionIdwith/ai/async/answerto get results when ready
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.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The question you want to send to the AI.
An unique identifier for the current session.
An unique identifier for your visitor.
Optional segment ID to search within for relevant content.
Optional metadata object displayed in the dashboard.
object
In case you have multiple topics, you can give each a different name.
An audienceId to use for content lookup.
Example generated
{ "query": "example", "sessionId": "example", "visitorId": "example", "segmentId": "example", "metadata": {}, "conversationName": "example", "audienceId": "example"}Responses
Section titled “Responses”Question accepted. Use questionId to poll for the answer.
object
Unique identifier for retrieving the query results later.
Example
{ "questionId": "550e8400-e29b-41d4-a716-446655440000"}