Skip to main content
POST
/
api
/
v1
/
products
/
{product_id}
/
ask
Ask a question
curl --request POST \
  --url https://api.clarityq.ai/api/v1/products/{product_id}/ask \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "prompt": "<string>",
  "data_partition": {
    "start": "2023-12-25",
    "end": "2023-12-25"
  }
}
'
import requests

url = "https://api.clarityq.ai/api/v1/products/{product_id}/ask"

payload = {
"prompt": "<string>",
"data_partition": {
"start": "2023-12-25",
"end": "2023-12-25"
}
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({prompt: '<string>', data_partition: {start: '2023-12-25', end: '2023-12-25'}})
};

fetch('https://api.clarityq.ai/api/v1/products/{product_id}/ask', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.clarityq.ai/api/v1/products/{product_id}/ask",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'data_partition' => [
'start' => '2023-12-25',
'end' => '2023-12-25'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.clarityq.ai/api/v1/products/{product_id}/ask"

payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"data_partition\": {\n \"start\": \"2023-12-25\",\n \"end\": \"2023-12-25\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.clarityq.ai/api/v1/products/{product_id}/ask")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"data_partition\": {\n \"start\": \"2023-12-25\",\n \"end\": \"2023-12-25\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.clarityq.ai/api/v1/products/{product_id}/ask")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"data_partition\": {\n \"start\": \"2023-12-25\",\n \"end\": \"2023-12-25\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "message": "<string>",
  "conversation_id": "<string>"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

X-API-Key
string
header
required

API key obtained from the ClarityQ dashboard.

Path Parameters

product_id
string<uuid>
required

Body

application/json
prompt
string
required

Question to send to the ClarityQ agent.

data_partition
DataPartition · object | null

Optional UTC date range restricting the data the agent analyzes, equivalent to the date filter in the ClarityQ app. When omitted, the product's configured default date filter is applied (the same default the ClarityQ app uses); if the product has no default, no date filter is applied.

Response

Successful Response

status
enum<string>
required

Current status of the request.

Available options:
IN_PROGRESS,
COMPLETED,
ERROR
message
string
required

Human-readable status message.

conversation_id
string
required

Conversation ID for tracking the request.