documentId and AfterCare’s AI returns an answer drawn directly from your discharge paperwork, together with the exact line numbers in the document where the answer was found. Every response is grounded in the document you uploaded — the API never invents information.
Endpoint
Request body
string
required
The question you want to ask about your document. Must be between 1 and 1,000 characters after trimming whitespace.
string (UUID)
required
The UUID of the document to query. The document must belong to the authenticated user.
Response — 200 OK
The API returns a JSON object with the answer, a confidence score, and the source location within the document.string
The answer to your question, phrased in plain language and derived from the document text.
number
An integer between 0 and 100 expressing how confident the AI is in the answer, based on the clarity and completeness of the source text.
object
The location in the document from which the answer was derived.
Example response
Error responses
AfterCare uses aStructuredAiError shape for all AI-related failures. Every error response includes a code, a human-readable message, and a retryable flag.
StructuredAiError shape
400 Bad Request
Returned whenquestion is missing or empty, or when documentId is not a valid UUID.
404 Not Found
Returned when the document does not exist or does not belong to the authenticated user.422 Unprocessable Entity
Returned when the AI pipeline completes but the output fails validation — for example, when the model returns a malformed or unsafe response. Theretryable field will be false. Do not retry a 422 automatically; inspect the code and surface the message to the user.
422 example
503 Service Unavailable
Returned when the AI provider is unreachable, suffering an outage, or has not been configured in this environment.503 example
When you receive a 503 with
"retryable": true, wait a short interval (start with two to five seconds) and retry the request. A 503 with "retryable": false indicates a configuration problem that cannot be resolved by retrying.