{
	"info": {
		"_postman_id": "documenter-api-v1",
		"name": "DOCumenter API v1",
		"description": "Public Developer API for medical documentation, transcription, and TARDOC billing.\n\n## Setup\n\n1. Open the collection's **Variables** tab and set `api_key` to the sandbox or live key you received from dev@documenter.ch.\n2. (Live keys only) Set `x_user_token` to a physician JWT (institution mode) or pairing code like `DOC-A7K2M3P9` (partner mode). Quick-evaluation sandbox keys ignore this; partner-parity sandbox keys require one of the fixed DOC-SBX* pairing codes. The physician creates the pairing code on their Profile page; the first /v1/process submit binds it to your vendor org, and a code left unused for 7 days after creation is deactivated.\n3. The three sample files referenced by the multipart requests can be downloaded individually from <https://api.documenter.ch/developers/samples/> — after downloading, edit the request body, switch the file rows from `text` back to `file`, and select your local copy.\n   - `Consultation.ogg` (831 KB) — French primary-care audio recording\n   - `lettre_urgences.pdf` (referral letter from emergency department)\n   - `Rapport_cardio_2025.pdf` (cardiology report)\n\n## Quick start\n\nOpen `Document mode (text → report)` and click **Send**. You'll get a `job_id` back. Open `Poll job` and click **Send** — Postman will substitute `{{job_id}}` from the previous response automatically (the test script extracts it).\n\nEvery response includes an `X-Request-Id` header. Quote it in support tickets.\n",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"auth": {
		"type": "bearer",
		"bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }]
	},
	"variable": [
		{ "key": "base_url", "value": "https://api.documenter.ch", "type": "string" },
		{ "key": "api_key", "value": "doc_test_REPLACE_ME", "type": "string" },
		{ "key": "x_user_token", "value": "", "type": "string" },
		{ "key": "job_id", "value": "", "type": "string" },
		{ "key": "intent_id", "value": "", "type": "string" }
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					"// Conditionally attach X-User-Token only when set (sandbox keys don't need it).",
					"const tok = pm.collectionVariables.get('x_user_token');",
					"if (tok) pm.request.headers.upsert({ key: 'X-User-Token', value: tok });"
				]
			}
		}
	],
	"item": [
		{
			"name": "Document mode (text → report)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.job_id) pm.collectionVariables.set('job_id', json.job_id);",
							"pm.test('202 Accepted', () => pm.response.to.have.status(202));"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{ "key": "Content-Type", "value": "application/json" },
					{ "key": "Idempotency-Key", "value": "{{$guid}}" }
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"mode\": \"document\",\n  \"content\": \"Patient de 45 ans. Cephalees frontales bilaterales depuis 2 semaines. TA 130/85. Examen neurologique normal. Paracetamol 1g x3/jour.\",\n  \"locale\": \"fr\",\n  \"output_format\": \"markdown\"\n}"
				},
				"url": "{{base_url}}/v1/process"
			}
		},
		{
			"name": "Structured JSON output (text → canonical sections)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.job_id) pm.collectionVariables.set('job_id', json.job_id);",
							"pm.test('202 Accepted', () => pm.response.to.have.status(202));"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [{ "key": "Content-Type", "value": "application/json" }],
				"description": "With output_format json, the generation result is the locked envelope {schema_version, output_mode, sections:[{key,title,parent,content}], extracted_at}. Section keys are canonical snake_case machine keys (diagnostic, anamnese, ...) — or your organisation's own EHR field names when a field map is configured in the developer console.",
				"body": {
					"mode": "raw",
					"raw": "{\n  \"mode\": \"document\",\n  \"content\": \"Patiente de 52 ans. Toux seche et fatigue depuis 10 jours. Auscultation pulmonaire claire, pas de fievre. Hydratation et repos conseilles, controle si persistance.\",\n  \"locale\": \"fr\",\n  \"output_format\": \"json\"\n  // Optional: uncomment to have the full result POSTed to your endpoint instead of polling (https only).\n  // , \"webhook_url\": \"https://example.com/documenter-webhook\"\n}",
					"options": { "raw": { "language": "json" } }
				},
				"url": "{{base_url}}/v1/process"
			}
		},
		{
			"name": "Poll job (job_id auto-filled from previous response)",
			"request": {
				"method": "GET",
				"url": "{{base_url}}/v1/process/{{job_id}}"
			}
		},
		{
			"name": "Audio + TARDOC (multipart upload)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.job_id) pm.collectionVariables.set('job_id', json.job_id);"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "files",
							"type": "text",
							"value": "<switch to 'file' and select Consultation.ogg from /developers/samples/>"
						},
						{ "key": "tardoc", "type": "text", "value": "true" },
						{ "key": "mode", "type": "text", "value": "document" },
						{ "key": "locale", "type": "text", "value": "fr" },
						{ "key": "output_format", "type": "text", "value": "html" }
					]
				},
				"url": "{{base_url}}/v1/process/upload"
			}
		},
		{
			"name": "Transcript only (audio to transcript, no note)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.job_id) pm.collectionVariables.set('job_id', json.job_id);"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"description": "Transcript mode: submit audio, get back a speaker-labeled transcript with extracted medications — no report is generated. Poll {{job_id}} with 'Poll job'; results.transcription.text holds the transcript.",
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "files",
							"type": "text",
							"value": "<switch to 'file' and select Consultation.ogg from /developers/samples/>"
						},
						{ "key": "mode", "type": "text", "value": "transcript" },
						{ "key": "locale", "type": "text", "value": "fr" }
					]
				},
				"url": "{{base_url}}/v1/process/upload"
			}
		},
		{
			"name": "Two PDFs + clinical notes (multipart upload)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.job_id) pm.collectionVariables.set('job_id', json.job_id);"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"body": {
					"mode": "formdata",
					"formdata": [
						{ "key": "files", "type": "text", "value": "<switch to 'file' and select lettre_urgences.pdf>" },
						{ "key": "files", "type": "text", "value": "<switch to 'file' and select Rapport_cardio_2025.pdf>" },
						{
							"key": "text",
							"type": "text",
							"value": "Synthese: lettre d'urgences + rapport cardiologique. Generer un resume."
						},
						{ "key": "mode", "type": "text", "value": "document" },
						{ "key": "locale", "type": "text", "value": "fr" }
					]
				},
				"url": "{{base_url}}/v1/process/upload"
			}
		},
		{
			"name": "Rename mode (document → suggested filename)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.job_id) pm.collectionVariables.set('job_id', json.job_id);"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"description": "Rename mode: extracts patient, date and document type and suggests a filename. Poll {{job_id}} with 'Poll job'; results.renaming.suggestions[] holds one record per document.",
				"body": {
					"mode": "formdata",
					"formdata": [
						{ "key": "files", "type": "text", "value": "<switch to 'file' and select lettre_urgences.pdf>" },
						{ "key": "mode", "type": "text", "value": "rename" },
						{ "key": "locale", "type": "text", "value": "fr" }
					]
				},
				"url": "{{base_url}}/v1/process/upload"
			}
		},
		{
			"name": "Form mode (blank form + consultation → filled form)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.job_id) pm.collectionVariables.set('job_id', json.job_id);"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"description": "Form mode (requires ia-ssistant: capabilities.form_fill on GET /v1/entitlements). The blank form goes in its own `form` part: a PDF AcroForm or a Word form with native controls. A PDF without fillable fields is accepted, then the job ends with DOC_FORM_006. Poll {{job_id}}; results.form carries the filled document (base64) and every field.",
				"body": {
					"mode": "formdata",
					"formdata": [
						{ "key": "mode", "type": "text", "value": "form" },
						{ "key": "form", "type": "text", "value": "<switch to 'file' and select your blank fillable PDF or .docx form>" },
						{
							"key": "text",
							"type": "text",
							"value": "Patient de 40 ans. Chute le 01.09.2026, douleur du poignet droit. Radiographie: fracture du radius distal. Immobilisation par platre 6 semaines."
						},
						{ "key": "locale", "type": "text", "value": "fr" }
					]
				},
				"url": "{{base_url}}/v1/process/upload"
			}
		},
		{
			"name": "Chat mode (medical Q&A)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.job_id) pm.collectionVariables.set('job_id', json.job_id);"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [{ "key": "Content-Type", "value": "application/json" }],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"mode\": \"chat\",\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"Quels diagnostics differentiels pour des cephalees frontales bilaterales chroniques?\"}\n  ],\n  \"locale\": \"fr\"\n}"
				},
				"url": "{{base_url}}/v1/process"
			}
		},
		{
			"name": "Entitlements (what this physician's plan allows)",
			"request": {
				"method": "GET",
				"url": "{{base_url}}/v1/entitlements"
			}
		},
		{
			"name": "Section keys (the canonical mapping contract)",
			"request": {
				"method": "GET",
				"url": "{{base_url}}/v1/section-keys"
			}
		},
		{
			"name": "List available prompts",
			"request": {
				"method": "GET",
				"url": "{{base_url}}/v1/prompts"
			}
		},
		{
			"name": "Cancel job (idempotent)",
			"request": {
				"method": "DELETE",
				"url": "{{base_url}}/v1/process/{{job_id}}"
			}
		},
		{
			"name": "Signup intent: create (onboard a doctor)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"const json = pm.response.json();",
							"if (json.intent_id) pm.collectionVariables.set('intent_id', json.intent_id);"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"description": "Organisations enabled for signup intents only (otherwise 403 DOC_SIGNUP_001). API key only — X-User-Token is not needed and is ignored. 201 with a signup_url to send the doctor to; a sandbox key returns an already-completed intent with the sandbox pairing code. Calling again for the same email returns 200 with a rotated link. Budget: 10 requests/minute per key.",
				"header": [{ "key": "Content-Type", "value": "application/json" }],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"email\": \"dr.exemple@example.com\",\n  \"first_name\": \"Camille\",\n  \"last_name\": \"Exemple\",\n  \"external_ref\": \"ehr-user-0001\"\n}"
				},
				"url": "{{base_url}}/v1/partner/signup-intents"
			}
		},
		{
			"name": "Signup intent: status (intent_id auto-filled)",
			"request": {
				"method": "GET",
				"description": "status is open, completed, delivered or expired. pairing_code is present only during the hour after completion.",
				"url": "{{base_url}}/v1/partner/signup-intents/{{intent_id}}"
			}
		}
	]
}
