Appearance
REST API
The REST API lives at https://api.plancount.ai/api/v1. It speaks JSON, except for file uploads (multipart) and downloads (the file itself). A machine-readable description of every endpoint is at /api/v1/openapi.json (OpenAPI 3.1, no key needed).
All examples on this page use https://api.plancount.ai/api/v1 as the base and pc_live_YOUR_KEY as the key.
Authentication
Send the key as a bearer token on every request:
bash
curl https://api.plancount.ai/api/v1/me -H "Authorization: Bearer pc_live_YOUR_KEY"json
{"userId":"8db9747b-2186-44a1-b174-762f07d64078","workspace":{"type":"personal"},"scopes":["read","upload","edit"],"keyPrefix":"pc_live_AbCd"}A token from a connected app (see MCP Server) works the same way. A missing, wrong, expired or revoked key is 401 INVALID_API_KEY. A key without the scope an endpoint needs is 403 INSUFFICIENT_SCOPE. Scopes and workspaces are explained in the overview.
Every project, drawing and export belongs to the key's workspace. Anything outside it is 404 PROJECT_NOT_FOUND, never 403.
Coordinates
Everything that has a position, on every endpoint, uses the same page units:
- The unit is a PDF point at scale 1 (1/72 inch), with the page's rotation already applied. A page's size is the
widthandheightthe API reports for it. - The origin
(0, 0)is the top-left corner of the page as you see it. xgrows to the right andygrows downward.
(0,0) ──────────────► x
│ ┌───────────────────────────┐
│ │ L1 at x=100, y=85 │
│ │ │
▼ │ ● (600, 300) │
y │ │
└───────────────────────────┘
(width, height) = (842, 595)Boxes (symbols, annotations, legends) are given by their top-left corner x, y plus width and height. Symbols also report their centre, and you place and move them by centre.
Page images
GET .../pages/{page}/image?dpi=N draws the page at N dpi. The answer headers give the mapping:
| Header | Meaning |
|---|---|
X-Page-Width, X-Page-Height | The page size in page units |
X-Scale | Pixels per page unit, which is dpi / 72 |
A pixel (px, py) in the image is the page point (px / scale, py / scale). So at dpi=144 (scale 2), pixel (1200, 600) is the page point (600, 300). This holds on rotated pages too.
Errors
Every error has the same shape:
json
{"error":{"code":"PROJECT_NOT_FOUND","message":"Project not found"}}details is added when there is more to say. Branch on code, not on message. The codes a caller can meet:
Request and access
| Status | Code | Meaning |
|---|---|---|
| 400 | INVALID_REQUEST | The body, query or multipart form is not valid. details.issues lists each problem |
| 401 | INVALID_API_KEY | Missing, invalid, expired or revoked key, or a team key whose owner lost their seat |
| 403 | INSUFFICIENT_SCOPE | The key lacks the scope the endpoint needs. details.required names it |
| 403 | PDF_COUNT, STORAGE, PROJECTS | The plan's limits. details holds current, max and tier |
| 404 | PROJECT_NOT_FOUND | No such project in the key's workspace |
| 404 | PDF_NOT_FOUND, PAGE_NOT_FOUND | The drawing is not in the project, or the page is outside the drawing |
| 404 | EXPORT_NOT_FOUND | No such export in this project |
| 404 | NOT_FOUND | No such endpoint |
| 413 | FILE_TOO_LARGE, PAYLOAD_TOO_LARGE | The upload or the JSON body is over the size limit |
| 429 | RATE_LIMITED | Over 120 requests a minute for this key, or too many failed key attempts from your address. Wait for Retry-After seconds |
| 500 | INTERNAL_ERROR | Something went wrong on our side. Nothing in the message is for you to act on |
Credits
| Status | Code | Meaning |
|---|---|---|
| 402 | INSUFFICIENT_CREDITS | Not enough credits. details has required, available and buyCreditsUrl |
| 402 | MAX_CREDITS_EXCEEDED | The price is more than the max_credits you sent. Nothing was charged. details has required and maxCredits |
| 402 | KEY_DAILY_LIMIT_EXCEEDED | The key's daily limit would be passed. details has limit, used, held, required and nextReleaseAt |
Uploads, drawings and projects
| Status | Code | Meaning |
|---|---|---|
| 400 | INVALID_PDF | The file is not a PDF, or cannot be read, or needs a password. Nothing is charged |
| 400 | INVALID_PAGE_SELECTION | The pages field is not valid, or names a page past the end of the file |
| 400 | CONFIRMATION_REQUIRED | A delete without confirm repeating the id |
| 400 | LAST_PDF | You cannot remove a project's only drawing |
| 400 | INVALID_ORDER | A reorder must list every drawing of the project exactly once |
| 400 | PROJECT_HAS_NO_PDFS | The project has no drawings (to duplicate or export) |
| 403 | DELETE_NOT_ALLOWED | A team's policy does not let this member delete the project |
| 409 | IDEMPOTENT_REQUEST_IN_PROGRESS | The same Idempotency-Key is still being processed. Wait, then send the same request again |
| 409 | UPLOAD_CHARGE_MISMATCH | A retried upload had been charged a different price. It was refunded. Send it again |
| 422 | IDEMPOTENCY_KEY_REUSED | This Idempotency-Key was used within 24 hours for a different request |
| 422 | PDF_PROCESSING_FAILED | A stored drawing cannot be read right now. details.retryable says whether trying again may help |
| 429 / 503 | PDF_BUSY | The drawing reader is busy (429: your own earlier request is still running). Wait for Retry-After |
Changing project contents
| Status | Code | Meaning |
|---|---|---|
| 409 | VERSION_CONFLICT | The project changed since your expectedVersion. details.currentVersion is the current one. Nothing was applied |
| 422 | VALIDATION_FAILED | One or more operations are invalid. details.ops lists each by index with a code and message. Nothing was applied |
| 422 | STATE_TOO_LARGE | The change would make the project too large to save |
| 422 | SYMBOL_LIMIT_EXCEEDED | The change would add more symbols than a project can hold. details.kind says which measure |
| 422 | REDETECTION_NOT_POSSIBLE | A rule change that needs detection to run again cannot be applied exactly. Nothing was applied. See Rules |
| 422 | REDETECTION_TOO_LARGE | The project is too large to detect again in one request through the API |
The codes inside details.ops are listed with each collection in Project Contents.
Images and exports
| Status | Code | Meaning |
|---|---|---|
| 400 | RENDER_TOO_LARGE | The page image would be too big. details.maxDpi is the largest dpi that fits for this page (null when none does) |
| 422 | RENDER_FAILED | The page could not be drawn. details.retryable and details.reason say why |
| 400 | EXPORT_HAS_NO_PAGES | Every page of the chosen drawings is excluded. Nothing is charged |
| 413 | EXPORT_TOO_LARGE | The drawings are too large to export through the API. Export from the app. Nothing is charged |
| 409 | EXPORT_CHARGE_MISMATCH | A retried export had been charged a different price. It was refunded. Send it again |
| 410 | EXPORT_EXPIRED | The export's 7 days are over |
| 422 | EXPORT_LIMIT_REACHED | The project holds as many unexpired exports as it may. Wait for older ones to expire. Nothing is charged |
| 422 | EXPORT_FILE_UNAVAILABLE | A stored export file could not be read. details.retryable says whether to try again |
| 422 | EXPORT_FAILED | The marked-up PDF could not be made. You are refunded. details.reason is unreadable, memory, output_too_large, timeout or internal, and details.retryable says whether to try again |
| 429 | EXPORT_BUSY | One of your exports is still being made. Wait for Retry-After |
Credits, max_credits and Idempotency-Key
Calls that can spend credits (uploads and exports) accept two safety features.
max_credits caps the price. Send it as a form field on an upload and as a field in the JSON body of an export. If the real price is higher, the call is refused with MAX_CREDITS_EXCEEDED before anything is charged. Always send it from an agent.
Idempotency-Key is a request header (1 to 200 printable characters) that makes a retry safe. If the connection drops and you send the same request with the same key, you get the first answer back and are charged once. The same key with a different request is IDEMPOTENCY_KEY_REUSED. Keys are remembered for 24 hours, after which the same key starts a new request.
A retried upload with a lower max_credits still returns the first answer, because the charge had already happened.
Rate limit
Each key can make 120 requests per minute, across the REST API and the MCP server together. Over the limit, the answer is 429 with code RATE_LIMITED and a Retry-After header. GET /openapi.json needs no key and is limited per IP address instead.
Endpoints
Each endpoint needs the scope shown. Paths are relative to https://api.plancount.ai/api/v1. {id} is a project id and {pdfId} a drawing id.
Account and credits
| Endpoint | Scope | What it does |
|---|---|---|
GET /me | read | Who the key acts as: user, workspace, scopes and key prefix |
GET /credits | read | pool, balance, available (balance minus credits held for work in progress), buyCreditsUrl and the key's daily limit |
GET /credits/transactions?limit=1..100 | read | Recent credit transactions, newest first. On a team workspace, owners and admins see the whole team; other members see only their own uploads and exports |
GET /credits/estimate?operation=upload&pages=N | read | What uploading N pages costs, and whether it is enough. Writes nothing |
GET /openapi.json | none | This API as an OpenAPI 3.1 document |
Projects
| Endpoint | Scope | What it does |
|---|---|---|
GET /projects?limit=1..100&cursor= | read | The workspace's projects, newest first. Page through with nextCursor |
GET /projects/{id} | read | One project with its drawings and each page's size and rotation. Never the symbols. A drawing that cannot be read right now comes back with pageCount: null, pages: null and an error (code, message, retryable), and the rest of the project is answered normally |
POST /projects | upload | Create a project from a PDF (multipart: pdf, name, optional max_credits, pages). Spends credits |
POST /projects/empty | edit | Create a project with no drawings: { "name", "description"?, "drawingProfile"? }. Free. Profiles: LIGHTING, NETWORK, POWER, FIRE, SECURITY |
PATCH /projects/{id} | edit | Change name, description or status (DRAFT, ACTIVE, ARCHIVED) |
POST /projects/{id}/archive, .../unarchive | edit | Archive or restore a project |
POST /projects/{id}/duplicate | edit | Copy a project with its drawings and everything on them: { "name"? }. Free |
DELETE /projects/{id} | edit | Delete a project for good. Body { "confirm": "<the project id>" }. Answers 204 |
Drawings
| Endpoint | Scope | What it does |
|---|---|---|
POST /projects/{id}/pdfs | upload | Add a PDF to a project (multipart, as above). Spends credits |
DELETE /projects/{id}/pdfs/{pdfId} | edit | Remove a drawing and everything placed on it. Body { "confirm": "<the drawing id>" }. Answers 204 |
PUT /projects/{id}/pdfs/order | edit | Reorder drawings: { "pdfIds": [...] }, every drawing once |
GET /projects/{id}/pdfs/{pdfId}/file | read | Download the original PDF |
GET /projects/{id}/pdfs/{pdfId}/pages/{page}/text | read | The page's text with positions: { page, width, height, items: [{ str, x, y, width, height }] } |
GET /projects/{id}/pdfs/{pdfId}/pages/{page}/image?dpi=36..200 | read | The page as a PNG (default 100 dpi). See Page images |
POST /projects/{id}/text-detection | edit | Run detection on drawings that have no detected symbols: { "pdfId"? }. Free |
Uploading
An upload is a multipart form with these fields:
| Field | Required | Meaning |
|---|---|---|
pdf | yes | The file |
name | when creating a project | The project's name |
max_credits | no | Refuse the upload if it would cost more than this many credits |
pages | no | Upload only these pages, for example 1,3,5-7, and pay only for them |
Pages cannot be selected from a PDF that is secured against changes; upload the whole file instead.
Before the file is stored, the server reads it and counts its pages itself. You are charged 1 credit for each page it finds, whatever any client said. A file that cannot be read is refused and costs nothing.
The answer includes textDetection. After a successful upload the server runs the project's text rules on the new drawing, so counts are available at once. { "status": "detected", "symbols": 9 } means it worked. Any other status (not_run or failed, with a reason) means nothing was stored and the app will detect the drawing when it is first opened; you can also try again with POST /projects/{id}/text-detection. The upload is never refunded or failed because of this.
Symbols and counts
| Endpoint | Scope | What it does |
|---|---|---|
GET /projects/{id}/symbols?pdfId=&page=&includeRemoved= | read | { stateVersion, symbols }: every symbol with its id, drawing, page, box, centre, type, label, rule and whether it was placed by hand |
POST /projects/{id}/symbols/batch | edit | { "ops": [...], "expectedVersion"? }. Operations: place, move, remove, restore. All or nothing |
GET /projects/{id}/counts?pdfId=&page= | read | The counts as the app shows them: { stateVersion, total, byLabel, byType } |
The operations:
json
{"op":"place","pdfId":"<drawing id>","page":1,"ruleId":"lighting","center":{"x":600,"y":300},"label":"L9"}
{"op":"move","id":"<symbol id>","center":{"x":130,"y":300}}
{"op":"remove","id":"<symbol id>"}
{"op":"restore","id":"<symbol id>"}placeputs a symbol, centred oncenter, that counts under the ruleruleId. The label is the one you send, else the rule's Plan Label, else the rule's name.removetakes a symbol out of the counts, as erasing it in the app does. The symbol is kept andrestorebrings it back.- The whole symbol box must lie on the page.
A batch holds 1 to 500 operations. For this endpoint, a batch with no operations or more than 500 is 400 INVALID_REQUEST. (The other collections answer 422 VALIDATION_FAILED for the same mistake. See Project Contents.)
counts leaves out removed symbols, hidden labels, excluded pages and symbols inside exclusion zones.
Project contents
Page setup, rules, zones, linear measurement, annotations and legends all follow one list-and-batch pattern. The pattern and each collection are explained in Project Contents.
| Endpoint | Scope | What it does |
|---|---|---|
GET /projects/{id}/page-setup | read | Each drawing's scale and pages (size, rotation, excluded or not), the drawing profile, and hidden labels |
POST /projects/{id}/page-setup/batch | edit | Exclude or include pages, set or clear scales, hide or show labels |
GET /projects/{id}/rules | read | Detection rules and the drawing profile |
POST /projects/{id}/rules/batch | edit | Create, change, enable, disable and delete rules; set the drawing profile |
GET /projects/{id}/zones?pdfId=&page= | read | Zones with their measured areas |
POST /projects/{id}/zones/batch | edit | Create, change and delete zones |
GET /projects/{id}/linear?pdfId=&page= | read | Linear rules, lines and rings with measured lengths |
POST /projects/{id}/linear/batch | edit | Create, change and delete linear rules, lines and rings |
GET /projects/{id}/annotations?pdfId=&page= | read | Cloud boxes, text notes and highlights |
POST /projects/{id}/annotations/batch | edit | Create, change and delete annotations |
GET /projects/{id}/legends?pdfId= | read | Where each page's legend is placed |
POST /projects/{id}/legends/batch | edit | Set or reset legend placement |
All of these are free.
Takeoff
| Endpoint | Scope | What it does |
|---|---|---|
GET /projects/{id}/takeoff?pdfId=&page= | read | Symbol totals, zones with areas, and line and ring lengths. Free |
page needs pdfId. The answer is the same numbers the app's CSV export computes:
json
{
"stateVersion": 20,
"scope": { "pdfId": "7d205b92-8fe6-4e5b-a5de-d08ad552799d", "page": 1 },
"pdfs": [{ "pdfId": "7d205b92-...", "filename": "level1.pdf", "scale": { "ratio": 100, "unit": "metric", "label": "1:100", "isDefault": false } }],
"symbols": {
"total": 9,
"byType": [{ "type": "LIGHTING", "count": 8 }, { "type": "LIGHTING_CONTROL", "count": 1 }],
"byLabel": [{ "label": "L1", "type": "LIGHTING", "ruleId": "lighting", "ruleName": "Lighting (L#)", "count": 1 }],
"byPage": [{ "pdfId": "7d205b92-...", "page": 1, "total": 9 }]
},
"zones": [
{ "id": "16cmj1av8", "name": "Line A", "type": "INCLUSION", "pdfId": "7d205b92-...", "page": 1,
"area": { "squareMeters": 16.93, "value": 16.93, "unit": "m2" },
"symbols": { "total": 3, "byLabel": [{ "label": "L1", "type": "LIGHTING", "count": 1 }] } },
{ "id": "r756rvtsg", "name": "Office", "type": "AREA", "pdfId": "7d205b92-...", "page": 1,
"area": { "squareMeters": 31.11, "value": 31.11, "unit": "m2" }, "symbols": null },
{ "id": "186olp4bg", "name": "Plant room", "type": "EXCLUSION", "pdfId": "7d205b92-...", "page": 1,
"area": null, "symbols": null }
],
"linear": {
"rules": [
{ "ruleId": "linear-1795783725374-2k0co", "name": "LED strip", "symbol": "LED", "isRingRule": false,
"displayMode": "length", "unitLength": 5, "totalLengthMeters": 14.11, "unitsNeeded": 3,
"pathCount": 1, "ringCount": 0, "byPdf": [{ "pdfId": "7d205b92-...", "totalLengthMeters": 14.11, "unitsNeeded": 3, "pathCount": 1, "ringCount": 0 }] }
],
"paths": []
}
}(Numbers are rounded and ids shortened here; paths is shortened to empty. Each entry in paths is one line or ring with its identifier, lengthMeters, units and, for rings, diameterMeters.)
- Inclusion zones list the symbols inside them and never change the totals. Exclusion zones have no area or symbols listed because they remove symbols from every total. Area zones only measure.
- Lengths and areas use each drawing's own scale, else 1:100 metric.
- Each drawing's totals are reported separately under
byPdf, and a rule'sunitsNeededis the sum across drawings.
Exports
| Endpoint | Scope | What it does |
|---|---|---|
GET /projects/{id}/exports/estimate?format=&pdfId=&pdfIds= | read | The price of an export, as create would charge it. Writes nothing |
POST /projects/{id}/exports | upload | Make an export. May spend credits |
GET /projects/{id}/exports | read | Exports you can still download, newest first |
GET /projects/{id}/exports/{exportId}/file | read | Download an export. Free |
The three kinds of export
These match the app's own buttons. Pick one by what you send:
| You send | Same as in the app | Priced on |
|---|---|---|
{ "format": "csv", "pdfId": "..." } | The takeoff CSV of one drawing | 1 credit |
{ "format": "pdf", "pdfId": "..." } | Export: marked-up PDF of one drawing | 1 credit for each page that has at least one counted symbol; free when no page has one |
{ "format": "pdf", "pdfIds": [...] } with two or more drawings, or { "format": "pdf" } for every drawing of a project with several | Export All: marked-up PDF of several drawings in one file, pages in the order sent (project order when none are named) | 1 credit for each page that is not excluded |
An export that covers exactly one drawing is priced like pdfId: that is pdfIds naming one drawing, or no pdfIds on a project with one drawing. Sending both pdfId and pdfIds is 400 INVALID_REQUEST. A CSV needs exactly one pdfId.
On a workspace whose plan includes unlimited exports, every export is free, and the estimate says so with "unlimitedExports": true.
The marked-up PDF is made on the server from the project as it is now, with the same symbols, zones, annotations, lines, rings and legend as the app's export.
Estimate, then export
bash
curl -s "https://api.plancount.ai/api/v1/projects/$PROJECT/exports/estimate?format=pdf&pdfId=$PDF" \
-H "Authorization: Bearer pc_live_YOUR_KEY"json
{"format":"pdf","pages":1,"credits":1,"unlimitedExports":false,"available":18,"sufficient":true,"keyDailyLimit":{"limit":null,"used":2,"held":0,"remaining":null,"nextReleaseAt":"2026-11-28T12:47:57.773Z"}}sufficient says whether available credits cover it, and the key's daily limit allows it. The export call takes the same body plus max_credits, with Idempotency-Key as a header:
json
{"format":"pdf","pdfId":"7d205b92-8fe6-4e5b-a5de-d08ad552799d","max_credits":2}The answer is 201:
json
{"export":{"id":"ae7c1d85-0c71-5111-8b4a-2a7311df6ea2","format":"pdf","pdfIds":["7d205b92-..."],"stateVersion":4,"pages":1,"sizeBytes":3428,"filename":"takeoff_level1.pdf","createdAt":"2026-11-27T12:48:27.454Z","expiresAt":"2026-12-04T12:48:27.454Z","downloadUrl":"/api/v1/projects/983f904f-.../exports/ae7c1d85-.../file"},"credits":{"charged":1,"balance":17}}Things to know:
- The price follows the project. If the project changes between the estimate and the export, the export is priced on the project as it is when you make it.
- Retry safely. Send the same request with the same
Idempotency-Keyafter a dropped connection and you get the first export back and are charged once. For 24 hours that key always returns that first export, even if the project has changed since. To export the project as it is now, use a new key. - Failure refunds. If the file cannot be made, the credits are returned and you get an
EXPORT_FAILEDor similar error. - Download for 7 days. The file stays available until
expiresAt. Downloading again is free. After that the export is410 EXPORT_EXPIREDand then disappears from the list. Make a new export to get a fresh file. - A paid-for export is recorded even if your connection drops while it is being made. Look for it in
GET /exportsbefore making it again. - One marked-up PDF export per user is made at a time (
EXPORT_BUSYotherwise).
Changing the same project from several places
Every change to the project's contents (symbols, pages, rules, zones, measurements, annotations, legends) raises its stateVersion by 1. Renaming the project does not. Adding a drawing does only when symbols are detected on the new drawing. Every list endpoint returns it, and every batch takes an optional expectedVersion. Open browser tabs of the same project pick up API changes within about 10 seconds while the tab is visible, once the user is not in the middle of an edit, and merge them in without losing the user's work. See Project Contents.
