The PharmaDocs AI REST API lets you integrate pharmaceutical document generation into your LIMS, ERP, or custom workflows. Authenticate with an API key and access your projects and documents programmatically.
Availability: API access is available on the Pro and Enterprise plans. Upgrade your plan to generate API keys.
POST /api/v1/projects with your STP as multipart/form-data. We parse it and run AI extraction for you, and return a project_id. The whole flow is headless — no dashboard step required. (Projects created in the dashboard also work.)POST /api/v1/generate with that project_id and a doc_type (Protocol, Report, or Calculation Sheet for AMV / RS, plus PV, Stability, Forced Degradation). Add an optional params object to configure the output.file_url directly; it is a public HTTPS link to the generated .docx (or .xlsx for calculation sheets), no auth header needed for the file itself.GET /api/v1/projects and GET /api/v1/documents.# 1. Upload an STP -> get a project_id (AI extraction runs automatically)
curl -X POST "https://pharmadocsai.com/api/v1/projects" \
-H "Authorization: Bearer sk_pd_your_api_key_here" \
-F "file=@/path/to/STP.pdf" -F "project_type=amv"
# -> { "success": true, "data": { "project_id": "3fa8...afa6", ... } }
# 2. Generate a document for that project (e.g. the AMV calculation sheet)
curl -X POST "https://pharmadocsai.com/api/v1/generate" \
-H "Authorization: Bearer sk_pd_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{ "project_id": "3fa8...afa6", "doc_type": "amv-calc" }'
# -> { "success": true, "data": { "file_url": "https://.../AMV_CALC_...xlsx" } }
# 3. Download the file (public link, no auth header needed)
curl -L -o AMV_Calculation_Sheet.xlsx "https://.../AMV_CALC_...xlsx"All API requests must include an Authorization header with a Bearer token. Generate your API key from the API Keys section of your dashboard.
API keys are prefixed with sk_pd_ (followed by 40 hex characters) and are tied to a specific company account. Keep your key secret — treat it like a password. Revoke and regenerate it from your dashboard if compromised.
Use server-side only. Call the API from your backend — never embed your sk_pd_ key in browser/front-end JavaScript or a mobile app, where it would be exposed to end users. Your front-end should call your own server, which then calls the PharmaDocs AI API. (The API does not send CORS headers, so direct browser calls are blocked by design.)
All errors return a JSON body with a { "success": false, "error": "message" } shape.
| HTTP Status | Meaning |
|---|---|
| 200 OK | Request succeeded |
| 201 Created | Resource created successfully |
| 400 Bad Request | Missing or invalid parameters in the request body |
| 401 Unauthorized | Missing or invalid API key |
| 402 Payment Required | Monthly document quota exhausted — upgrade your plan |
| 403 Forbidden | Your plan does not include API access (Pro/Enterprise only) |
| 404 Not Found | Resource does not exist or belongs to a different account |
| 422 Unprocessable | Could not process — e.g. project has no extracted data yet, or the STP could not be read by AI |
| 429 Too Many Requests | Daily request rate limit exceeded |
| 500 Internal Error | Server-side error — retry or contact support |
| Plan | Limit | Window |
|---|---|---|
| Free | No API access | — |
| Pro | 500 requests | Per day (UTC) |
| Enterprise | 100,000 requests | Per day (UTC) |
Only successful (2xx) requests count toward the daily limit; the window resets at 00:00 UTC. Document generation also counts against your monthly document quota (the same quota as the dashboard — e.g. 200/month on Pro). When the daily request cap is hit you receive 429; when the monthly document quota is exhausted, 402.
All endpoints require a valid API key passed as a Bearer token.
/api/v1/projectsAuth RequiredList all projects belonging to your account.
| Name | Type | In | Description |
|---|---|---|---|
| page | integer | query | Page number (default: 1) |
| limit | integer | query | Items per page, max 100 (default: 20) |
/api/v1/projectsAuth RequiredCreate a project by uploading an STP. We parse the file and run AI extraction automatically, then return a project_id you can pass straight to Generate. This makes the whole flow headless — no dashboard step needed. Send the file as multipart/form-data.
| Name | Type | In | Description |
|---|---|---|---|
| file | file | form-data | The STP document — PDF or DOCX (scanned images allowed if OCR is enabled). Max size per your plan/platform limit. |
| project_type | string | form-data | Optional. amv (default) | pp | stability | rs — the workflow this project feeds. |
| product_name | string | form-data | Optional. Falls back to the AI-extracted product name, then the filename. |
| product_id | string | form-data | Optional. Your internal product reference. |
/api/v1/projects/{id}Auth RequiredGet a single project with its AI-extracted fields and list of generated documents.
| Name | Type | In | Description |
|---|---|---|---|
| id | string (uuid) | path | Project UUID returned from List Projects |
/api/v1/documentsAuth RequiredList generated documents. Optionally filter by project or document type. The doc_type filter uses the STORED upper-snake form (e.g. AMV_PROTOCOL), not the lower-hyphen value used by the Generate endpoint.
| Name | Type | In | Description |
|---|---|---|---|
| project_id | string (uuid) | query | Filter by project UUID |
| doc_type | string | query | Filter by stored type: AMV_PROTOCOL, AMV_REPORT, AMV_RS_PROTOCOL, … (upper-snake) |
| page | integer | query | Page number (default: 1) |
| limit | integer | query | Items per page, max 100 (default: 20) |
/api/v1/generateAuth RequiredGenerate a document for an existing project. Create the project first with POST /api/v1/projects (uploads + extracts the STP), or use one created in the dashboard. Counts against your monthly document quota. Returns a public file_url you can download directly.
| Name | Type | In | Description |
|---|---|---|---|
| project_id | string (uuid) | body | UUID of the project to generate from |
| doc_type | string | body | See the Document Types section for all 16 values (lower-hyphen). STP-based types (amv-*, pp-*, stability-study, force-degradation*) use the project’s extracted data. Form-driven types (apqr, change-control, cleaning-validation, deviation-report, method-transfer) are built entirely from params. Calc types return .xlsx; all others .docx. |
| params | object | body | Optional for STP-based docs (documentNumber, validationCharacteristics[], referenceArea, populateWithExampleData, … — same shape the dashboard sends). REQUIRED for form-driven docs (apqr/change-control/etc.): pass the document’s fields here since there is no STP to draw from. |
Use these values for the doc_type field in the Generate endpoint.
| Value | Name | Description |
|---|---|---|
| amv-protocol | AMV Protocol | Analytical Method Validation Protocol |
| amv-report | AMV Report | Analytical Method Validation Report |
| amv-calc | AMV Calculation Sheet | Analytical Method Validation calculation workbook (returns .xlsx) |
| amv-rs-protocol | AMV RS Protocol | Related Substances AMV Protocol |
| amv-rs-report | AMV RS Report | Related Substances AMV Report |
| amv-rs-calc | AMV RS Calculation Sheet | Related Substances AMV calculation workbook (returns .xlsx) |
| pp-protocol | PP Protocol | Process Validation Protocol |
| pp-report | PP Report | Process Validation Report |
| stability-study | Stability Study | ICH Stability Study Document |
| force-degradation | Forced Degradation | Stress Testing / Forced Degradation Protocol |
| force-degradation-report | Forced Degradation Report | Forced Degradation study Report |
| apqr | APQR | Annual Product Quality Review (form-driven — pass fields in params) |
| change-control | Change Control | Change Control record (form-driven — pass fields in params) |
| cleaning-validation | Cleaning Validation | Cleaning Validation Protocol (form-driven — pass fields in params) |
| deviation-report | Deviation Report | Deviation / CAPA Report (form-driven — pass fields in params) |
| method-transfer | Method Transfer | Analytical Method Transfer Protocol (form-driven — pass fields in params) |
If you have questions about the API, encounter an unexpected error, or want to request a new feature, reach out to our team.