Skip to content

Create Webhook

POST /v1/webhooks

Register a webhook URL to receive POST requests when extraction events occur. Each user can have up to 10 active webhooks.

Try it

Test this endpoint interactively in the Swagger UI.

Authorization required

Include your API key in the Authorization header.

Request

Headers

HeaderValueRequired
AuthorizationBearer <token>Yes
Content-Typeapplication/jsonYes

Body

FieldTypeRequiredDescription
urlstringYesHTTPS endpoint that will receive webhook POST requests.
eventsstring[]YesEvents to subscribe to. At least one required. Values: "extraction.completed", "extraction.failed".

Code Examples

bash
curl -X POST https://api.docmap.io/v1/webhooks \
  -H "Authorization: Bearer dm_live_abc123def456ghi789jkl012mno345" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-app.com/webhooks/docmap",
    "events": ["extraction.completed", "extraction.failed"]
  }'
typescript
const apiKey = process.env.DOCMAP_API_KEY

const response = await fetch('https://api.docmap.io/v1/webhooks', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://your-app.com/webhooks/docmap',
    events: ['extraction.completed', 'extraction.failed'],
  }),
})

const { data } = await response.json()

// IMPORTANT: Store the signing secret immediately — it cannot be retrieved later
console.log('Signing Secret:', data.secret)
console.log('Webhook ID:', data.webhook.id)
python
import requests

api_key = "dm_live_abc123def456ghi789jkl012mno345"

response = requests.post(
    "https://api.docmap.io/v1/webhooks",
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    json={
        "url": "https://your-app.com/webhooks/docmap",
        "events": ["extraction.completed", "extraction.failed"],
    },
)

data = response.json()["data"]

# IMPORTANT: Store the signing secret immediately — it cannot be retrieved later
print(f"Signing Secret: {data['secret']}")
print(f"Webhook ID: {data['webhook']['id']}")

Response

Status: 200 OK

The response body is wrapped in a data object.

WARNING

The signing secret is only returned in this response. Store it securely immediately -- it cannot be retrieved later. You need it to verify webhook signatures.

Fields

FieldTypeDescription
secretstringHMAC-SHA256 signing secret (64 hex characters). Only shown once.
webhookobjectWebhook metadata object (see below).

webhook object:

FieldTypeDescription
idstringUnique identifier for the webhook.
userIdstringID of the user who owns the webhook.
urlstringThe registered endpoint URL.
eventsstring[]Events the webhook is subscribed to.
activebooleanWhether the webhook is active. Always true for a newly created webhook.
createdAtstringISO 8601 timestamp of when the webhook was created.

Example

json
{
  "data": {
    "secret": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2",
    "webhook": {
      "id": "webhook-abc123def456",
      "userId": "uid_a1b2c3d4e5f6",
      "url": "https://your-app.com/webhooks/docmap",
      "events": ["extraction.completed", "extraction.failed"],
      "active": true,
      "createdAt": "2025-01-15T10:00:00.000Z"
    }
  }
}

Errors

StatusCodeDescription
400MAX_WEBHOOKS_REACHEDYou have reached the maximum of 10 active webhooks. Delete an existing webhook before creating a new one.
401UNAUTHORIZEDMissing, invalid, or expired API key / token.

DocMap API Documentation