curl --request GET \
--url https://api.wordsmith.ai/api/v1/assistants/{assistant_id}/questions/{question_id} \
--header 'Authorization: Bearer <token>'{
"id": "550e8400-e29b-41d4-a716-446655440000",
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"session_url": "https://app.wordsmith.ai/chat/550e8400-e29b-41d4-a716-446655440000",
"status": "in_progress",
"answer": null,
"attachments": null
}
Retrieve the status and results of a previously submitted question
curl --request GET \
--url https://api.wordsmith.ai/api/v1/assistants/{assistant_id}/questions/{question_id} \
--header 'Authorization: Bearer <token>'{
"id": "550e8400-e29b-41d4-a716-446655440000",
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"session_url": "https://app.wordsmith.ai/chat/550e8400-e29b-41d4-a716-446655440000",
"status": "in_progress",
"answer": null,
"attachments": null
}
"default" for the
general Wordsmith assistant, or the specific assistant ID used in the original
request.curl -X GET "https://api.wordsmith.ai/api/v1/assistants/default/questions/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer sk-ws-api1-your_api_key_here" \
-H "Content-Type: application/json"
"in_progress": The assistant is still
processing your question. "completed": Processing is complete and the answer
is available. "error": An error occurred during processing.status is
"completed".status is "completed" and files were generated.{
"id": "550e8400-e29b-41d4-a716-446655440000",
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"session_url": "https://app.wordsmith.ai/chat/550e8400-e29b-41d4-a716-446655440000",
"status": "in_progress",
"answer": null,
"attachments": null
}
id: The unique identifier for this specific question. For the first question in a session, this equals the session_id. For follow-up questions, this is a unique feed item ID.session_id: The session ID that contains this question. This remains constant for all questions within the same conversation.id and session_id are the sameid is a unique question ID, session_id is the original session IDid field to check the status of individual questions, and the session_id to identify which conversation session the question belongs to.
async function waitForCompletion(questionId, maxWaitTime = 300000) {
// 5 minutes max
const startTime = Date.now();
const pollInterval = 2000; // Start with 2 seconds
let currentInterval = pollInterval;
while (Date.now() - startTime < maxWaitTime) {
const response = await fetch(
`https://api.wordsmith.ai/api/v1/assistants/default/questions/${questionId}`,
{
headers: { Authorization: "Bearer sk-ws-api1-your_api_key_here" },
}
);
const result = await response.json();
if (result.status === "completed" || result.status === "error") {
return result;
}
// Exponential backoff: increase interval up to 30 seconds
await new Promise((resolve) => setTimeout(resolve, currentInterval));
currentInterval = Math.min(currentInterval * 1.5, 30000);
}
throw new Error("Timeout waiting for question completion");
}
// Usage
try {
const result = await waitForCompletion(
"550e8400-e29b-41d4-a716-446655440000"
);
console.log("Question completed:", result);
} catch (error) {
console.error("Failed to get result:", error);
}
{
"error": "Question not found",
"status": 404
}
curl -o "contract_analysis.pdf" "https://files.wordsmith.ai/download/abc123def456"