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

# Generate from a custom prompt

> Create a private document template and generate its response from a consultation.

Generate a document from your own instructions, such as a patient-friendly
summary. The request creates a private template and generates its first document.

Requires `scribe:generate`, custom-template and generation entitlements, and a
session with clinical input.

## Send the instructions

`POST /sessions/{session_id}/client-customised-template/response`

```bash theme={null}
curl --request POST "$CORTEXA_API_BASE/sessions/$CORTEXA_SESSION_ID/client-customised-template/response" \
  --header "Authorization: Bearer $CORTEXA_JWT" \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: visit-001-patient-instructions-1' \
  --data '{"name":"Patient instructions","prompt":"Summarize the documented management plan in plain language. Use headings for next steps and follow-up. Do not add facts that are absent from the consultation.","output_language_code":"en"}'
```

| Field | Required | Description |
| - | - | - |
| `name` | Yes | Name for the new template; 1–255 characters |
| `prompt` | Yes | Instructions for the output; 1–20,000 characters |
| `output_language_code` | No | Requested output language |

For typed questions and answer options, use [structured forms](/developers/structured-responses.md).

## Retrieve the response

Example `202` receipt:

```json theme={null}
{
  "job_id": "job_example",
  "job_ids": ["job_example"],
  "status": "queued",
  "document_ids": ["document_example"]
}
```

[Poll the returned jobs](/developers/jobs.md), then retrieve the documents. Use `rendered_text`
for display; the `content` structure depends on the generated template.

## Reuse and retry

Retry a lost response with the same idempotency key and unchanged request. That
replays the original result without creating another template or document.
A new operation creates a new private template. For repeated use of an existing
template, [select it](/developers/templates.md) and use the normal note or document workflow.

Present the result for clinician review before sharing it or writing it into your EHR.


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