Skip to content

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 width and height the API reports for it.
  • The origin (0, 0) is the top-left corner of the page as you see it.
  • x grows to the right and y grows 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:

HeaderMeaning
X-Page-Width, X-Page-HeightThe page size in page units
X-ScalePixels 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 ​

StatusCodeMeaning
400INVALID_REQUESTThe body, query or multipart form is not valid. details.issues lists each problem
401INVALID_API_KEYMissing, invalid, expired or revoked key, or a team key whose owner lost their seat
403INSUFFICIENT_SCOPEThe key lacks the scope the endpoint needs. details.required names it
403PDF_COUNT, STORAGE, PROJECTSThe plan's limits. details holds current, max and tier
404PROJECT_NOT_FOUNDNo such project in the key's workspace
404PDF_NOT_FOUND, PAGE_NOT_FOUNDThe drawing is not in the project, or the page is outside the drawing
404EXPORT_NOT_FOUNDNo such export in this project
404NOT_FOUNDNo such endpoint
413FILE_TOO_LARGE, PAYLOAD_TOO_LARGEThe upload or the JSON body is over the size limit
429RATE_LIMITEDOver 120 requests a minute for this key, or too many failed key attempts from your address. Wait for Retry-After seconds
500INTERNAL_ERRORSomething went wrong on our side. Nothing in the message is for you to act on

Credits ​

StatusCodeMeaning
402INSUFFICIENT_CREDITSNot enough credits. details has required, available and buyCreditsUrl
402MAX_CREDITS_EXCEEDEDThe price is more than the max_credits you sent. Nothing was charged. details has required and maxCredits
402KEY_DAILY_LIMIT_EXCEEDEDThe key's daily limit would be passed. details has limit, used, held, required and nextReleaseAt

Uploads, drawings and projects ​

StatusCodeMeaning
400INVALID_PDFThe file is not a PDF, or cannot be read, or needs a password. Nothing is charged
400INVALID_PAGE_SELECTIONThe pages field is not valid, or names a page past the end of the file
400CONFIRMATION_REQUIREDA delete without confirm repeating the id
400LAST_PDFYou cannot remove a project's only drawing
400INVALID_ORDERA reorder must list every drawing of the project exactly once
400PROJECT_HAS_NO_PDFSThe project has no drawings (to duplicate or export)
403DELETE_NOT_ALLOWEDA team's policy does not let this member delete the project
409IDEMPOTENT_REQUEST_IN_PROGRESSThe same Idempotency-Key is still being processed. Wait, then send the same request again
409UPLOAD_CHARGE_MISMATCHA retried upload had been charged a different price. It was refunded. Send it again
422IDEMPOTENCY_KEY_REUSEDThis Idempotency-Key was used within 24 hours for a different request
422PDF_PROCESSING_FAILEDA stored drawing cannot be read right now. details.retryable says whether trying again may help
429 / 503PDF_BUSYThe drawing reader is busy (429: your own earlier request is still running). Wait for Retry-After

Changing project contents ​

StatusCodeMeaning
409VERSION_CONFLICTThe project changed since your expectedVersion. details.currentVersion is the current one. Nothing was applied
422VALIDATION_FAILEDOne or more operations are invalid. details.ops lists each by index with a code and message. Nothing was applied
422STATE_TOO_LARGEThe change would make the project too large to save
422SYMBOL_LIMIT_EXCEEDEDThe change would add more symbols than a project can hold. details.kind says which measure
422REDETECTION_NOT_POSSIBLEA rule change that needs detection to run again cannot be applied exactly. Nothing was applied. See Rules
422REDETECTION_TOO_LARGEThe 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 ​

StatusCodeMeaning
400RENDER_TOO_LARGEThe page image would be too big. details.maxDpi is the largest dpi that fits for this page (null when none does)
422RENDER_FAILEDThe page could not be drawn. details.retryable and details.reason say why
400EXPORT_HAS_NO_PAGESEvery page of the chosen drawings is excluded. Nothing is charged
413EXPORT_TOO_LARGEThe drawings are too large to export through the API. Export from the app. Nothing is charged
409EXPORT_CHARGE_MISMATCHA retried export had been charged a different price. It was refunded. Send it again
410EXPORT_EXPIREDThe export's 7 days are over
422EXPORT_LIMIT_REACHEDThe project holds as many unexpired exports as it may. Wait for older ones to expire. Nothing is charged
422EXPORT_FILE_UNAVAILABLEA stored export file could not be read. details.retryable says whether to try again
422EXPORT_FAILEDThe 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
429EXPORT_BUSYOne 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 ​

EndpointScopeWhat it does
GET /mereadWho the key acts as: user, workspace, scopes and key prefix
GET /creditsreadpool, balance, available (balance minus credits held for work in progress), buyCreditsUrl and the key's daily limit
GET /credits/transactions?limit=1..100readRecent 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=NreadWhat uploading N pages costs, and whether it is enough. Writes nothing
GET /openapi.jsonnoneThis API as an OpenAPI 3.1 document

Projects ​

EndpointScopeWhat it does
GET /projects?limit=1..100&cursor=readThe workspace's projects, newest first. Page through with nextCursor
GET /projects/{id}readOne 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 /projectsuploadCreate a project from a PDF (multipart: pdf, name, optional max_credits, pages). Spends credits
POST /projects/emptyeditCreate a project with no drawings: { "name", "description"?, "drawingProfile"? }. Free. Profiles: LIGHTING, NETWORK, POWER, FIRE, SECURITY
PATCH /projects/{id}editChange name, description or status (DRAFT, ACTIVE, ARCHIVED)
POST /projects/{id}/archive, .../unarchiveeditArchive or restore a project
POST /projects/{id}/duplicateeditCopy a project with its drawings and everything on them: { "name"? }. Free
DELETE /projects/{id}editDelete a project for good. Body { "confirm": "<the project id>" }. Answers 204

Drawings ​

EndpointScopeWhat it does
POST /projects/{id}/pdfsuploadAdd a PDF to a project (multipart, as above). Spends credits
DELETE /projects/{id}/pdfs/{pdfId}editRemove a drawing and everything placed on it. Body { "confirm": "<the drawing id>" }. Answers 204
PUT /projects/{id}/pdfs/ordereditReorder drawings: { "pdfIds": [...] }, every drawing once
GET /projects/{id}/pdfs/{pdfId}/filereadDownload the original PDF
GET /projects/{id}/pdfs/{pdfId}/pages/{page}/textreadThe page's text with positions: { page, width, height, items: [{ str, x, y, width, height }] }
GET /projects/{id}/pdfs/{pdfId}/pages/{page}/image?dpi=36..200readThe page as a PNG (default 100 dpi). See Page images
POST /projects/{id}/text-detectioneditRun detection on drawings that have no detected symbols: { "pdfId"? }. Free

Uploading ​

An upload is a multipart form with these fields:

FieldRequiredMeaning
pdfyesThe file
namewhen creating a projectThe project's name
max_creditsnoRefuse the upload if it would cost more than this many credits
pagesnoUpload 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 ​

EndpointScopeWhat 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/batchedit{ "ops": [...], "expectedVersion"? }. Operations: place, move, remove, restore. All or nothing
GET /projects/{id}/counts?pdfId=&page=readThe 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>"}
  • place puts a symbol, centred on center, that counts under the rule ruleId. The label is the one you send, else the rule's Plan Label, else the rule's name.
  • remove takes a symbol out of the counts, as erasing it in the app does. The symbol is kept and restore brings 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.

EndpointScopeWhat it does
GET /projects/{id}/page-setupreadEach drawing's scale and pages (size, rotation, excluded or not), the drawing profile, and hidden labels
POST /projects/{id}/page-setup/batcheditExclude or include pages, set or clear scales, hide or show labels
GET /projects/{id}/rulesreadDetection rules and the drawing profile
POST /projects/{id}/rules/batcheditCreate, change, enable, disable and delete rules; set the drawing profile
GET /projects/{id}/zones?pdfId=&page=readZones with their measured areas
POST /projects/{id}/zones/batcheditCreate, change and delete zones
GET /projects/{id}/linear?pdfId=&page=readLinear rules, lines and rings with measured lengths
POST /projects/{id}/linear/batcheditCreate, change and delete linear rules, lines and rings
GET /projects/{id}/annotations?pdfId=&page=readCloud boxes, text notes and highlights
POST /projects/{id}/annotations/batcheditCreate, change and delete annotations
GET /projects/{id}/legends?pdfId=readWhere each page's legend is placed
POST /projects/{id}/legends/batcheditSet or reset legend placement

All of these are free.

Takeoff ​

EndpointScopeWhat it does
GET /projects/{id}/takeoff?pdfId=&page=readSymbol 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's unitsNeeded is the sum across drawings.

Exports ​

EndpointScopeWhat it does
GET /projects/{id}/exports/estimate?format=&pdfId=&pdfIds=readThe price of an export, as create would charge it. Writes nothing
POST /projects/{id}/exportsuploadMake an export. May spend credits
GET /projects/{id}/exportsreadExports you can still download, newest first
GET /projects/{id}/exports/{exportId}/filereadDownload an export. Free

The three kinds of export ​

These match the app's own buttons. Pick one by what you send:

You sendSame as in the appPriced on
{ "format": "csv", "pdfId": "..." }The takeoff CSV of one drawing1 credit
{ "format": "pdf", "pdfId": "..." }Export: marked-up PDF of one drawing1 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 severalExport 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-Key after 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_FAILED or similar error.
  • Download for 7 days. The file stays available until expiresAt. Downloading again is free. After that the export is 410 EXPORT_EXPIRED and 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 /exports before making it again.
  • One marked-up PDF export per user is made at a time (EXPORT_BUSY otherwise).

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.

Plan Count User Guide