> ## Documentation Index
> Fetch the complete documentation index at: /developers/llms.txt
> Use this file to discover all available pages before exploring further.

# Ask a question about a session

> Submit a focused clinical-documentation question and retrieve the generated answer.

Ask questions about the session's clinical context and previous partner replies.

**Scopes:** `scribe:generate` to ask; `scribe:read` to retrieve the answer.

## Submit a question

`POST /sessions/{session_id}/ask-ai`

```bash theme={null}
curl --request POST "$CORTEXA_API_BASE/sessions/$CORTEXA_SESSION_ID/ask-ai" \
  --header "Authorization: Bearer $CORTEXA_JWT" \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: visit-001-question-1' \
  --data '{"message":"Summarize the follow-up plan documented in this consultation."}'
```

`message` is required and must contain 1–12,000 characters. The `202` response
includes `job_id` and `status`. Save that job ID as `CORTEXA_JOB_ID`.

## Read the answer

```bash theme={null}
curl "$CORTEXA_API_BASE/sessions/$CORTEXA_SESSION_ID/ask-ai/$CORTEXA_JOB_ID" \
  --header "Authorization: Bearer $CORTEXA_JWT"
```

| Field | Description |
| - | - |
| `job_id` | Work started by your question |
| `status` | Job state; an answer is final when this is `succeeded` |
| `answer` | Generated answer, which may be null before completion |
| `message_status` | Associated message state, when available |
| `failure_code` | Failure detail, when available |

Continue polling while the work is pending. Stop on `failed` or `cancelled` and
handle the failure. The generic [job endpoint](/developers/jobs.md) also exposes status, but
use this session-specific endpoint to retrieve the answer.

## Provide context

Add relevant material to [session context](/developers/context.md) before asking. Answers use
that session and its prior partner replies; unshared visits and internal Cortexa
conversations are outside this scope.

Display the answer for clinician review. To include it in a note, save a
[document edit](/developers/documents.md#save-an-edit).

## Troubleshooting

An unrelated job ID or a job belonging to another session/grant returns `404`.
When the submission response is lost, retry the same message and idempotency key.
Do not submit a new question on every polling interval.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.