Connect to the API
Your software and your AI agent use the same REST API: upload a document, start an analysis, and collect the structured JSON result. Every request needs an API key.
Connect your software
Your application or backend sends documents and analysis requests to AnchorGrid and uses the results it gets back. These four requests are all you need, and they follow the same pattern for every analysis. The examples use door detection.
What you need
requests, or Node 18+.https://api.anchorgrid.aiSet your API key
Every request carries your key in a header called
X-API-Key. Save it as an environment variable so it stays out of your code. The examples below read it fromANCHORGRID_API_KEY.export ANCHORGRID_API_KEY="your_api_key"Keep keys on your serverCall the API from your backend, not from a browser or mobile app, and never commit keys to source control.Upload your PDF
Send the PDF to the documents endpoint. AnchorGrid stores it and returns a
document_id, which you'll pass to any analysis.curl -X POST https://api.anchorgrid.ai/v1/documents \ -H "X-API-Key: $ANCHORGRID_API_KEY" \ -F "file=@drawings.pdf"You get back a
document_id. It stays valid for your plan's retention window.Start an analysis
Pass the
document_idto an analysis endpoint, here door detection. Analyses run asynchronously, so the API answers right away with 202 Accepted and a job to check on. Usepage_numbersto scan only certain pages; each page scanned counts as one element detection.curl -X POST https://api.anchorgrid.ai/v1/drawings/detection/doors \ -H "X-API-Key: $ANCHORGRID_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "document_id": "<document_id>", "page_numbers": [1, 2, 3] }'{ "job_id": "<uuid>", "poll_url": "/v1/jobs/<uuid>" }Shows the two documented fields; the live response may include more.
Check your results
Ask for the job until its
statusiscompleteorfailed. When it's complete, the detections are inresult.doors. Prefer not to poll? Add awebhook_urlto step 3 and the completed job is sent to you.curl https://api.anchorgrid.ai/v1/jobs/<job_id> \ -H "X-API-Key: $ANCHORGRID_API_KEY"{ "status": "complete", "model": "door-detector", "result": { "doors": [ … ] } }The fields inside each door aren't listed here yet, so they're shown as …
Examples use plain HTTP: cURL, Python requests and JavaScript fetch(Node 18+). They aren't an AnchorGrid SDK, and the 5-second wait is just an example.
Connect your AI agent
An AI agent uses AnchorGrid through a tool your developers set up. The tool runs in your own environment, calls the same REST API as above, and hands the structured JSON back to the agent. The agent never needs to see your API key.
- Your AI agentdecides a document needs analysis and calls the tool
- Your toolruns on your server and holds the API key in its configuration
- AnchorGrid APIuploads the document, runs the analysis and returns JSON
Set it up
- Store the API key securely. Put it in your server's environment or your agent platform's secret settings. The tool sends it in the
X-API-Keyheader, like any other request. Don't paste it into an AI conversation or a prompt. - Give the agent tools that wrap the API. One tool per action works well: upload a document (
POST /v1/documents), start an analysis (for examplePOST /v1/drawings/detection/doors), and check a job (GET /v1/jobs/{job_id}). The requests are the same as in Connect your software. - Handle the wait for results. Analyses are asynchronous. Have the tool check the job until it's
completeorfailed, or usewebhook_urland pass the result to the agent when it arrives. - Return the result to the agent. Give the agent the job's
resultJSON so it can answer questions or take the next step in your workflow.
These docs don't describe an AnchorGrid SDK, MCP server or ready-made agent connector. Agents connect through the REST API described here, using whatever tool or function-calling setup your agent platform supports.
Where to go next
The same requests work for every analysis.