Submit a drawing
#!/usr/bin/env bashset -euo pipefailAPI=https://api.speccapture.comAUTH="Authorization: Bearer $SPECCAPTURE_API_KEY"
DRAWING=bracket.pdf # the drawing to send: a PDF, TIFF, PNG, JPEG, BMP or WebP
job=$(curl -sS --fail-with-body "$API/v1/extractions" \ -H "$AUTH" \ -H "Idempotency-Key: $(openssl rand -hex 16)" \ -F "file=@$DRAWING") || { echo "$job" >&2; exit 1; }jq -r '"Job \(.jobId) is \(.status): \(.sheetCount) sheets, \(.credits.reserved) credits reserved"' <<<"$job"using System.Text.Json;
using HttpClient http = new() { BaseAddress = new Uri("https://api.speccapture.com") };http.DefaultRequestHeaders.Authorization = new("Bearer", Environment.GetEnvironmentVariable("SPECCAPTURE_API_KEY"));
string drawing = args[0]; // the drawing to send: a PDF, TIFF, PNG, JPEG, BMP or WebP
using MultipartFormDataContent form = new() { { new StreamContent(File.OpenRead(drawing)), "file", Path.GetFileName(drawing) } };JsonElement job = await Json(await Call(HttpMethod.Post, "/v1/extractions", form, Guid.NewGuid().ToString()));Console.WriteLine($"Job {job.GetProperty("jobId")} is {job.GetProperty("status")}: {job.GetProperty("sheetCount")} sheets, {job.GetProperty("credits").GetProperty("reserved")} credits reserved");
// Sends a request; stops with the problem's code and detail if the API refuses it.async Task<HttpResponseMessage> Call(HttpMethod method, string path, HttpContent? body = null, string? idempotencyKey = null) { using HttpRequestMessage request = new(method, path) { Content = body }; if (idempotencyKey is not null) request.Headers.Add("Idempotency-Key", idempotencyKey); HttpResponseMessage response = await http.SendAsync(request); if (!response.IsSuccessStatusCode) { JsonElement problem = await Json(response); string? detail = (problem.TryGetProperty("detail", out JsonElement text) ? text : problem.GetProperty("title")).GetString(); Console.Error.WriteLine($"{(int)response.StatusCode} {problem.GetProperty("code")}: {detail}"); Environment.Exit(1); } return response;}
// Reads an answer as JSON.static async Task<JsonElement> Json(HttpResponseMessage response) => JsonDocument.Parse(await response.Content.ReadAsStringAsync()).RootElement;import osimport sysimport uuid
import requests
API = "https://api.speccapture.com"session = requests.Session()session.headers["Authorization"] = f"Bearer {os.environ['SPECCAPTURE_API_KEY']}"
def call(method, path, **kwargs): """Send a request; stop with the problem's code and detail if the API refuses it.""" response = session.request(method, API + path, **kwargs) if not response.ok: problem = response.json() sys.exit(f"{response.status_code} {problem['code']}: {problem.get('detail', problem['title'])}") return response
drawing = sys.argv[1] # the drawing to send: a PDF, TIFF, PNG, JPEG, BMP or WebP
with open(drawing, "rb") as file: job = call( "POST", "/v1/extractions", files={"file": file}, headers={"Idempotency-Key": str(uuid.uuid4())}, ).json()print(f"Job {job['jobId']} is {job['status']}: {job['sheetCount']} sheets, {job['credits']['reserved']} credits reserved")import { openAsBlob } from "node:fs";import { basename } from "node:path";import { randomUUID } from "node:crypto";
const API = "https://api.speccapture.com";const headers = { Authorization: `Bearer ${process.env.SPECCAPTURE_API_KEY}` };
const [drawing] = process.argv.slice(2); // the drawing to send: a PDF, TIFF, PNG, JPEG, BMP or WebP
const form = new FormData();form.append("file", await openAsBlob(drawing), basename(drawing));const job = await call("POST", "/v1/extractions", { body: form, headers: { "Idempotency-Key": randomUUID() },}).then((response) => response.json());console.log(`Job ${job.jobId} is ${job.status}: ${job.sheetCount} sheets, ${job.credits.reserved} credits reserved`);
// Sends a request; stops with the problem's code and detail if the API refuses it.async function call(method, path, init = {}) { const response = await fetch(API + path, { ...init, method, headers: { ...headers, ...init.headers } }); if (!response.ok) { const problem = await response.json(); console.error(`${response.status} ${problem.code}: ${problem.detail ?? problem.title}`); process.exit(1); } return response;}Accepts one PDF, TIFF, PNG, JPEG, BMP or WebP as multipart/form-data, in a part named ‘file’, reserves 4 credits per sheet and answers 202 with the job. One drawing a request: a form with a second ‘file’ part is refused whole with 400 invalid_request, so send each drawing in a request of its own. Optional form fields templateId (drawing, or an id from GET /v1/templates) and templateVersion choose which fields the job keeps, under which names and in which order; left out, the workspace’s default template. Every template reads the drawing the same way. An id the workspace does not have is 422 template_not_found, before anything is reserved. Send an Idempotency-Key to make retries safe: the same key with a different file or template is 409.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Makes a retry safe: any unique string of 1 to 255 printable ASCII characters without spaces, such as a UUID. For 24 hours the same key with the same file answers with the job its first request made, marked Idempotent-Replayed: true; with a different file or template it is 409 idempotency_key_reused.
Request Bodyrequired
Section titled “Request Bodyrequired”The drawing, as multipart/form-data: one part named ‘file’, one drawing a request.
object
A PDF, TIFF, PNG, JPEG, BMP or WebP, recognized from its bytes. Each page is a sheet; each sheet reserves 4 credits.
Optional: the template the job is delivered with - drawing (the standard template: every field but the sizes and counts and the material form) or a template id from GET /v1/templates. Left out, the workspace’s default.
Optional: a published version of templateId; its newest when left out.
Responses
Section titled “Responses”Accepted
One uploaded file and the extraction of its sheets: the answer of POST /v1/extractions and GET /v1/extractions/{jobId}, and the job of every extraction webhook event.
object
The job’s id: what every other request about it names.
Where the job is.
The uploaded file’s name, as it was sent.
The uploaded file’s size, in bytes.
SHA-256 of the file’s bytes, lowercase hex.
The template the job is delivered with: the id of one of the workspace’s own templates (from GET /v1/templates), or drawing - the standard template, every field but the sizes and counts and the material form - for a job sent with drawing or read before the workspace had a template of its own. Every template reads the drawing the same way; it decides which values the job keeps, what each is called and in what order.
The version of the template the job keeps for good: 1 for drawing.
The pages counted when the file was accepted; each is read, and billed, on its own.
What the job reserved, spent, refunded and still holds.
object
What each sheet of this job costs, fixed when it was accepted.
Reserved when the file was accepted: its sheets times perSheet.
Spent on sheets that were read.
Returned for sheets, or a whole file, that could not be read, and for sheets skipped.
Still reserved for sheets not yet finished, and for sheets held because they do not look like drawings.
How many of its sheets are read, how many failed, and how many need a person to look.
object
Sheets read so far.
Sheets that could not be read, their credits refunded.
Read sheets with at least one value waiting for a person to look.
Sheets held because their page does not look like a drawing, waiting to be read anyway or skipped. Left out of the answer when there are none.
Held sheets that were skipped, their credits refunded. Left out of the answer when there are none.
One entry per sheet, in page order: present from the start, each waiting until the file is split.
One sheet of a job, as the job lists it: where it stands, and where its values are.
object
1 for the file’s first page.
Where the sheet is.
Whether a read sheet’s values can be used as delivered.
autoAccepted: Every value cleared the confidence threshold and nothing asked for a person’s look - a value the drawing does not print among them, settled as not printed (notPrinted), and a company name not found (notFound).needsReview: At least one value, or the sheet as a whole, needs a person to look.reviewed: A person has accepted or corrected every value that needed it.
The version of SpecCapture’s reading engine (ev1-...) that read the sheet; null until it has been read.
When the sheet was read, or failed; null until then.
Where the sheet’s values are: GET /v1/extractions/{jobId}/sheets/{sheetNumber}.
True when the sheet’s own export-control marking (titleBlock.exportControlMarking) names an export control: controlledMarking says which. SpecCapture takes no export-controlled drawings, so the workspace is warned to delete it unless it is sure it is not controlled. A flag only: the sheet was read, and nothing about its values or review changes.
The control the marking names: Distribution Statement B to Distribution Statement F (or the old Distribution Statement X), ITAR, EAR, CUI, NOFORN, FOUO or export-restricted (a warning that the drawing’s export is restricted); null when markedControlled is false.
The decision to keep a drawing that has a sheet marked export-controlled: the workspace’s owner or an admin said, in the dashboard, that it is not controlled and may stay. It stands for the whole document, and once made it is not made again. A sheet so kept may be shared outside the workspace again.
object
When it was kept.
Who kept it, as the workspace’s people list names them; null once they have left the workspace.
Why it may stay, in the words of the person who kept it.
While the sheet is held: where to POST to read it anyway, its held credits spent once it is read. Left out otherwise.
While the sheet is held: where to POST to skip it, its credits refunded. Left out otherwise.
When the file was accepted.
When anything about the job last changed.
When its last sheet finished, or the job failed; null until then.
Why the job failed, in words for a person; null unless status is failed.
Always false: there are no test keys and no test mode, so every job reads its drawing and is charged for it.
When the workspace’s retention period removed the drawing - the uploaded file, its page images and every value’s box - so every box is null from then on and a view link is refused; null while the drawing is kept. The values, their review and the exports stay.
What the workspace calls the job’s template now (“ERP import”); null for drawing.
Examples
The new job: 8 credits reserved for its 2 sheets, waiting to be split
{ "jobId": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "status": "queued", "fileName": "bracket.pdf", "fileSizeBytes": 482113, "fileSha256": "5c7e180a7bc5a50d1300976a9400df057e7324a7e416eddfaeacec87967fed9f", "templateId": "c2b8f3a1-7e5d-4c9a-8f6b-1a2d3e4f5a6b", "templateVersion": 3, "sheetCount": 2, "credits": { "perSheet": 4, "reserved": 8, "spent": 0, "refunded": 0, "held": 8 }, "progress": { "sheetsCompleted": 0, "sheetsFailed": 0, "sheetsNeedingReview": 0 }, "sheets": [ { "sheetNumber": 1, "status": "queued", "reviewState": null, "engineVersion": null, "completedAt": null, "resultUrl": "/v1/extractions/7c9e6679-7425-40de-944b-e07fc1f90ae7/sheets/1", "markedControlled": false, "controlledMarking": null, "controlledKept": null }, { "sheetNumber": 2, "status": "queued", "reviewState": null, "engineVersion": null, "completedAt": null, "resultUrl": "/v1/extractions/7c9e6679-7425-40de-944b-e07fc1f90ae7/sheets/2", "markedControlled": false, "controlledMarking": null, "controlledKept": null } ], "createdAt": "2026-10-14T09:30:12+00:00", "updatedAt": "2026-10-14T09:30:12+00:00", "completedAt": null, "failureReason": null, "testMode": false, "drawingPurgedAt": null, "templateName": "ERP import"}Bad Request: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
The request has no file.
{ "type": "https://speccapture.com/docs/api/errors#file_missing", "title": "The request has no file.", "status": 400, "detail": "The form has no part named 'file'. Send the drawing as -F \"file=@drawing.pdf\".", "instance": "/v1/extractions", "code": "file_missing", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}The Idempotency-Key header is not valid.
{ "type": "https://speccapture.com/docs/api/errors#invalid_idempotency_key", "title": "The Idempotency-Key header is not valid.", "status": 400, "detail": "An Idempotency-Key is 1 to 255 printable ASCII characters without spaces; a UUID is a good choice.", "instance": "/v1/extractions", "code": "invalid_idempotency_key", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}Unauthorized: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
The API key is not valid.
{ "type": "https://speccapture.com/docs/api/errors#api_key_invalid", "title": "The API key is not valid.", "status": 401, "detail": "This key is unknown, revoked or expired, as every key of a workspace is once its deletion has been asked for. Create a new key in the dashboard (API keys).", "instance": "/v1/extractions", "code": "api_key_invalid", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}Payment Required: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
Not enough credits.
{ "type": "https://speccapture.com/docs/api/errors#not_enough_credits", "title": "Not enough credits.", "status": 402, "detail": "This file has 2 sheets, which needs 8 credits (4 a sheet), and the workspace has 5 available. Nothing was stored or reserved; add credits and send it again.", "instance": "/v1/extractions", "code": "not_enough_credits", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", "sheetCount": 2, "creditsNeeded": 8, "creditsAvailable": 5, "sheetsRemaining": 1, "upgradeUrl": "https://app.speccapture.com/billing"}The free trial has ended, and the workspace has no credits.
{ "type": "https://speccapture.com/docs/api/errors#trial_ended", "title": "The free trial has ended, and the workspace has no credits.", "status": 402, "detail": "The workspace's free trial has ended and its credits ended with it, so it takes no new drawings until it has more. Nothing was stored or reserved; upgradeUrl says how to get credits.", "instance": "/v1/extractions", "code": "trial_ended", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", "trialEndedAt": "2026-10-12T14:02:41+00:00", "upgradeUrl": "https://app.speccapture.com/billing"}Conflict: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
This Idempotency-Key was used for a different request.
{ "type": "https://speccapture.com/docs/api/errors#idempotency_key_reused", "title": "This Idempotency-Key was used for a different request.", "status": 409, "detail": "This Idempotency-Key was used in the last 24 hours for a different file or template. Send a new key for a new request.", "instance": "/v1/extractions", "code": "idempotency_key_reused", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}The first request with this Idempotency-Key is still being handled.
{ "type": "https://speccapture.com/docs/api/errors#idempotency_key_in_progress", "title": "The first request with this Idempotency-Key is still being handled.", "status": 409, "detail": "A request with this Idempotency-Key and this file is still being handled. Send it again in a moment to get its job.", "instance": "/v1/extractions", "code": "idempotency_key_in_progress", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", "retryAfterSeconds": 1}Payload Too Large: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
The file is too large.
{ "type": "https://speccapture.com/docs/api/errors#file_too_large", "title": "The file is too large.", "status": 413, "detail": "This file is larger than the 50 MB limit. Export the drawing at a lower resolution, or split it into smaller files.", "instance": "/v1/extractions", "code": "file_too_large", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", "maximumFileSizeMegabytes": 50}Unsupported Media Type: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
The request body is not a media type this endpoint takes.
{ "type": "https://speccapture.com/docs/api/errors#unsupported_media_type", "title": "The request body is not a media type this endpoint takes.", "status": 415, "detail": "Send the drawing as multipart/form-data with the file in a part named 'file'.", "instance": "/v1/extractions", "code": "unsupported_media_type", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}Unprocessable Entity: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
The file is not a drawing we can read (PDF, TIFF, PNG, JPEG, BMP or WebP).
{ "type": "https://speccapture.com/docs/api/errors#not_a_drawing", "title": "The file is not a drawing we can read (PDF, TIFF, PNG, JPEG, BMP or WebP).", "status": 422, "detail": "This isn't a PDF, TIFF, PNG, JPEG, BMP or WebP file. Export the drawing in one of those formats and upload it again.", "instance": "/v1/extractions", "code": "not_a_drawing", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}The file has too many sheets.
{ "type": "https://speccapture.com/docs/api/errors#too_many_sheets", "title": "The file has too many sheets.", "status": 422, "detail": "This file has 212 sheets, and one upload can hold up to 200. Split it into smaller files and upload each one.", "instance": "/v1/extractions", "code": "too_many_sheets", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", "maximumSheetsPerFile": 200}The workspace has no such template, or no such version of it.
{ "type": "https://speccapture.com/docs/api/errors#template_not_found", "title": "The workspace has no such template, or no such version of it.", "status": 422, "detail": "Your workspace has no such template, or no such version of it. Choose one of your templates, or the standard one, and send it again.", "instance": "/v1/extractions", "code": "template_not_found", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}Too Many Requests: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
Too many requests.
{ "type": "https://speccapture.com/docs/api/errors#rate_limited", "title": "Too many requests.", "status": 429, "detail": "This key may make 120 requests a minute: up to 120 at once, then one more every 0.5 seconds as the allowance refills. Try again in 1 second.", "instance": "/v1/extractions", "code": "rate_limited", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", "retryAfterSeconds": 1, "upgradeUrl": "https://app.speccapture.com/billing"}Service Unavailable: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
The file could not be stored.
{ "type": "https://speccapture.com/docs/api/errors#storage_unavailable", "title": "The file could not be stored.", "status": 503, "detail": "The file could not be stored. The credits reserved for it are returned within minutes; please send it again.", "instance": "/v1/extractions", "code": "storage_unavailable", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", "retryAfterSeconds": 5, "jobWithoutFileId": "1b4e28ba-2fa1-41d2-883f-0016d3cca427"}