Documentation

API Documentation

Detect signatures in images and PDFs with a single REST endpoint.

Machine-readable contract: OpenAPI 3.1. Official packages are coming soon. Call the API directly with the fetch, requests, and curl examples.

Authentication
Secure your API requests with an API key.

All API requests require authentication using an API key. Include your API key in the request header x-api-key.

Header
x-api-key: your_api_key_here

Endpoints

/api/detect
POST
Detect signatures in an image or a PDF. Send exactly one source field. An image costs 1 credit. A PDF costs 1 credit per page. A cached document costs 0.

Parameters

imageUrlstringImage URL. A PDF at this URL is detected automatically.
imageBase64stringImage base64, raw or data URL. PDF magic bytes (%PDF) are detected automatically.
pdfUrlstringhttp(s) URL of a PDF.
pdfBase64stringPDF base64, raw or data:application/pdf;base64,...
thresholdnumberOptional image confidence cutoff from 0 to 1. Defaults to 0.1. PDFs stay at 0.1.

Provide exactly one of the four fields. Image responses are unchanged from the original API.

Image request

{
  "imageUrl": "https://example.com/document.jpg"
}

Image response

{
  "success": true,
  "result": {
    "detections": [
      {
        "bbox": { "x1": 321.23, "y1": 373.39, "x2": 647.21, "y2": 501.68 },
        "confidence": 0.192,
        "class": 0,
        "class_name": "signature"
      }
    ],
    "count": 1,
    "confidenceThreshold": 0.1
  },
  "creditsRemaining": 9999,
  "detectionId": "clxxxx..."
}

detectionId is omitted when the result could not be stored. cached is present and true when the result was served from cache and no credit was spent. Images default to a confidence threshold of 0.1 and accept an optional threshold. PDFs use 0.1.

PDF documents
Each page is rasterized and detected separately. Results are grouped by page.

PDF request

{
  "pdfUrl": "https://example.com/contract.pdf"
}

Or send pdfBase64. Sending the same bytes as imageUrl or imageBase64 also works: the server checks the %PDF header and Content-Type.

PDF response

{
  "success": true,
  "documentType": "pdf",
  "signed": true,
  "count": 1,
  "pageCount": 2,
  "confidenceThreshold": 0.1,
  "pages": [
    {
      "page": 1,
      "width": 1275,
      "height": 1650,
      "detections": [
        {
          "bbox": { "x1": 120.5, "y1": 980.2, "x2": 460.8, "y2": 1104.0 },
          "confidence": 0.91,
          "class": 0,
          "class_name": "signature"
        }
      ],
      "count": 1
    }
  ],
  "creditsUsed": 2,
  "creditsRemaining": 98,
  "detectionId": "clxxxx..."
}

signed is true when count (signatures on all pages) is greater than zero.

page is 1-based. width and height are pixels of the raster sent to the model. Each box is detections[].bbox in that pixel space, with confidence.

pages, count, and creditsUsed are top-level. A 5-page PDF costs 5 credits.

Pages are rendered at 150 DPI. The longest side is capped at 2000 pixels, so a US Letter page is 1275×1650.

The balance is checked against the page count before any page is rasterized or detected. If there are not enough credits, the API returns 402 and does not process or charge any page.

A repeated document is served from cache and costs 0 credits (cached: true). The cache is the whole file, the same as images, so a cached PDF is not charged again.

Errors
400Missing field, invalid PDF, encrypted PDF, or more than 20 pages.
401Missing or invalid API key.
402Not enough credits for the image, or for every page of the PDF. needsPurchase is true.
413PDF is larger than 20 MB.
503The detection service did not respond. Credits are refunded.
504Download or processing timed out. Credits are refunded.

SDKs

Official clients
Python and Node packages are coming soon. They are not published on PyPI or npm yet.

Call POST /api/detect directly. The code examples use fetch, requests, and curl for images and PDFs.

Code Examples

Images

const response = await fetch('https://signature-detector.com/api/detect', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'your_api_key_here'
  },
  body: JSON.stringify({
    imageUrl: 'https://example.com/document.jpg',
    threshold: 0.1
  })
});

const data = await response.json();
console.log('Signatures found:', data.result.count);

PDFs

import { readFile } from 'node:fs/promises'

const pdfBase64 = (await readFile('contract.pdf')).toString('base64')

const response = await fetch('https://signature-detector.com/api/detect', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'your_api_key_here'
  },
  body: JSON.stringify({ pdfBase64 })
})

const data = await response.json()
if (!response.ok) {
  throw new Error(data.error)
}

console.log(data.signed ? 'Signed' : 'Unsigned', data.count, 'signatures')
console.log('credits used', data.creditsUsed)
for (const page of data.pages) {
  for (const hit of page.detections) {
    console.log(
      'page', page.page,
      hit.confidence.toFixed(2),
      hit.bbox
    )
  }
}