Batches and webhooks

Available in the API
Send many names in one call, poll or wait for a signed webhook, then page through the results in input order. Each item gets the body the matching sync endpoint returns, without its id.

Available in the API for transliterate, variants (standard mode), normalise and match. Webhook endpoints are available for every event below.

What it is for

Nightly reconciliation, a back-file of records, a list to expand before screening: work you do not want to run as thousands of sync calls. A batch takes the items in one request, runs them through the same steps as the sync endpoints and keeps the results, encrypted, until you collect them.

Create a batch

Create a batch

curl https://api.arabinames.assentify.com/v1/batches \
  -H "Authorization: Bearer $ARABINAMES_KEY" \
  -H "Idempotency-Key: nightly-2026-11-30" \
  -H "Content-Type: application/json" \
  -d '{"operation":"transliterate","defaults":{"target_script":"latn","max_results":2},"items":[{"custom_id":"row-1","text":"حسين"},{"custom_id":"row-2","text":"محمد الخوري"}],"result_retention_days":7,"metadata":{"job":"nightly"}}'
Response 202
{
  "id": "bt_example",
  "object": "batch",
  "operation": "transliterate",
  "status": "queued",
  "counts": {
    "total": 2,
    "succeeded": 0,
    "failed": 0,
    "cancelled": 0
  },
  "units": 0,
  "metadata": {
    "job": "nightly"
  },
  "created_at": "2026-11-30T09:00:00.000Z",
  "started_at": null,
  "completed_at": null,
  "results_expire_at": null,
  "links": {
    "self": "/v1/batches/bt_example",
    "results": "/v1/batches/bt_example/results"
  }
}

The gateway's answer, with ids and times replaced.

FieldTypeMeaning
operationstringtransliterate, variants, normalise or match.
items[]arrayEach item is the sync request body plus a custom_id (1 to 64 characters, unique in the batch). Fields an item sets win over defaults.
defaultsobjectFields applied to every item, for example target_script or hints.
webhook_urlstringOptional HTTPS URL for this batch's events, in addition to your registered endpoints. Deliveries to it are signed with the batch webhook secret.
result_retention_daysinteger1 to 30, default 7. How long results are kept after the batch ends.
metadataobjectUp to 10 string keys and values of up to 200 characters, returned on the batch. Never put personal data here.

The answer is 202 with the batch in queued. Send an Idempotency-Key: a retry with the same key and body within 24 hours returns the same batch instead of a second one, and a different body with that key is 409 idempotency_conflict. POST /v1/batch is an alias of POST /v1/batches.

Validation

Every item is checked before anything is stored, against its operation's schema and the input safety rules. One bad item refuses the whole batch with 422 batch_invalid; errors[] gives the index, custom_id, code and field of each, never the text.

One bad item refuses the whole batch

curl https://api.arabinames.assentify.com/v1/batches \
  -H "Authorization: Bearer $ARABINAMES_KEY" \
  -H "Content-Type: application/json" \
  -d '{"operation":"transliterate","items":[{"custom_id":"row-1","text":"حسين"},{"custom_id":"row-2","text":"   "}]}'
Response 422
{
  "type": "https://arabinames.assentify.com/docs/errors#batch_invalid",
  "title": "Batch invalid",
  "status": 422,
  "code": "batch_invalid",
  "detail": "1 of 2 items are invalid. Fix them and resubmit the batch.",
  "request_id": "req_example",
  "doc_url": "https://arabinames.assentify.com/docs/errors#batch_invalid",
  "errors": [
    {
      "index": 1,
      "custom_id": "row-2",
      "code": "empty_after_normalisation",
      "param": "text"
    }
  ]
}

The gateway's answer, with its request id replaced. Errors bill zero units.

  • More items than your plan allows is 422 validation_error on items.
  • A duplicate custom_id is a validation_error on that item.
  • Too many batches running at once is 429 concurrency_limited with Retry-After: 10.
PlanItems per batchBatches running at once
Free1001
Developer1,0002
Growth1,0005
Scale1,00010
EnterpriseUp to 10,00020

Lifecycle

Poll the batch

curl https://api.arabinames.assentify.com/v1/batches/bt_example \
  -H "Authorization: Bearer $ARABINAMES_KEY"
Response 200
{
  "id": "bt_example",
  "object": "batch",
  "operation": "transliterate",
  "status": "completed",
  "counts": {
    "total": 2,
    "succeeded": 2,
    "failed": 0,
    "cancelled": 0
  },
  "units": 2,
  "metadata": {
    "job": "nightly"
  },
  "created_at": "2026-11-30T09:00:00.000Z",
  "started_at": "2026-11-30T09:00:01.000Z",
  "completed_at": "2026-11-30T09:00:02.000Z",
  "results_expire_at": "2026-12-07T09:00:02.000Z",
  "links": {
    "self": "/v1/batches/bt_example",
    "results": "/v1/batches/bt_example/results"
  }
}

The gateway's answer, with ids and times replaced.

StatusMeaning
queuedAccepted, waiting for a worker. Paid plans are picked before Free, then oldest first.
runningItems are processed in chunks of 50. An item that times out at the engine is retried twice.
completedEvery item succeeded.
completed_with_errorsDone; some items failed. Each failed item carries its error code.
cancellingCancel requested while running; the worker stops at the next chunk.
cancelledStopped. Items not processed are marked cancelled.
failedThe batch could not finish within 24 hours; remaining items are failed with internal_error.
expiredresults_expire_at has passed and the results are deleted.

Inputs are deleted when the batch ends or is cancelled, and in any case 24 hours after creation. GET /v1/batches lists your batches newest first, for the calling key's environment, with limit and cursor.

Results

Read the results, in input order

curl https://api.arabinames.assentify.com/v1/batches/bt_example/results?limit=2 \
  -H "Authorization: Bearer $ARABINAMES_KEY"
Response 200
{
  "object": "list",
  "data": [
    {
      "custom_id": "row-1",
      "status": "succeeded",
      "result": {
        "object": "transliteration",
        "source_script": "arab",
        "target_script": "latn",
        "results": [
          {
            "text": "Hussein",
            "rank": 1
          },
          {
            "text": "Hussain",
            "rank": 2
          }
        ],
        "tokens": null,
        "hints": {
          "dialect": "auto",
          "orthography": "auto",
          "source": "default",
          "applied": "none"
        },
        "warnings": [],
        "engine_version": "mock-1",
        "units": 1
      }
    },
    {
      "custom_id": "row-2",
      "status": "succeeded",
      "result": {
        "object": "transliteration",
        "source_script": "arab",
        "target_script": "latn",
        "results": [
          {
            "text": "Mohamad El Khoury",
            "rank": 1
          },
          {
            "text": "Mohammed El Khoury",
            "rank": 2
          }
        ],
        "tokens": null,
        "hints": {
          "dialect": "auto",
          "orthography": "auto",
          "source": "default",
          "applied": "none"
        },
        "warnings": [],
        "engine_version": "mock-1",
        "units": 1
      }
    }
  ],
  "has_more": false,
  "next_cursor": null
}

Fixture spellings (engine_version mock-1), which is what a test key returns. A live key returns the engine's spellings in the same fields and bills the units shown; a test key bills 0.

  • Results come in input order. limit is 1 to 100 (default 20); pass next_cursor back as cursor while has_more is true.
  • status=succeeded or status=failed filters the list.
  • A succeeded item has result: the sync response body without its id. A failed item has error.code and, where it applies, error.param. A cancelled item has neither.
  • After results_expire_at the call answers 410 batch_results_expired. A batch.results_expiring event goes out 24 hours before.

Cancel

POST /v1/batches/{id}/cancel. A queued batch becomes cancelled at once. A running batch becomes cancelling and stops after the chunk in progress; items already done keep their results and units. A batch that has ended answers 409 batch_not_cancellable.

Webhook endpoints

Register a webhook endpoint

curl https://api.arabinames.assentify.com/v1/webhook-endpoints \
  -H "Authorization: Bearer $ARABINAMES_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://hooks.example.com/arabinames","events":["batch.*"],"description":"Batch results"}'
Response 201
{
  "id": "wh_example",
  "object": "webhook_endpoint",
  "url": "https://hooks.example.com/arabinames",
  "events": [
    "batch.*"
  ],
  "description": "Batch results",
  "status": "enabled",
  "disabled_reason": null,
  "failing_since": null,
  "previous_secret_valid_until": null,
  "created_at": "2026-11-30T09:00:00.000Z",
  "secret": "whsec_example"
}

The gateway's answer, with ids and times replaced.

  • Needs a key with the webhooks:manage scope. It is not in the default scopes: tick it in the scope list when you create the key on the console's API keys screen. Owners and admins can grant it.
  • url must be HTTPS on a public address. The host is resolved and refused when it points at a private, loopback, link-local or metadata address, and the check runs again before every delivery.
  • events takes event types, a group such as batch.*, or * for everything.
  • The secret is shown once, here and on rotation. Store it in your secret manager.
  • Manage with GET, PATCH and DELETE /v1/webhook-endpoints/{id}. POST .../rotate-secret issues a new secret; the old one keeps signing for 24 hours, so deliveries carry two v1= values meanwhile. POST .../test queues a test event. GET .../deliveries shows 30 days of attempts (status codes and timings, no bodies) and POST .../deliveries/{delivery_id}/replay sends one again.

Batch webhook secret

Events sent to a batch's own webhook_url are signed with one secret per account, the batch webhook secret. Registered endpoints keep their own secrets. Verify these deliveries exactly as below, with this secret.

Rotate the batch webhook secret (the new secret is shown once)

curl -X POST https://api.arabinames.assentify.com/v1/batch-webhook-secret/rotate \
  -H "Authorization: Bearer $ARABINAMES_KEY"
Response 200
{
  "object": "batch_webhook_secret",
  "created_at": "2026-11-30T09:00:00.000Z",
  "shown_at": "2026-11-30T09:00:00.000Z",
  "previous_secret_valid_until": null,
  "secret": "whsec_example"
}

The gateway's answer, with ids and times replaced.

  • The secret is shown once. In the console, the account owner can show the current secret once on the Webhooks screen; after that, only a rotation gives a new one.
  • POST /v1/batch-webhook-secret/rotate issues a new secret and returns it once. The previous secret keeps signing for 24 hours, so deliveries carry two v1= values meanwhile; previous_secret_valid_until says until when.
  • GET /v1/batch-webhook-secret returns the dates (created_at, shown_at, previous_secret_valid_until), never the secret.
  • Both need a key with the webhooks:manage scope and bill nothing. Store the secret in your secret manager; it never appears in our logs.

Events

Eventdata
batch.completedbatch_id, operation, status, counts, units, results_expire_at, results
batch.failedbatch_id, code, counts
batch.cancelledbatch_id, counts, units
batch.results_expiringbatch_id, results_expire_at (sent 24 hours before)
usage.threshold_reachedplan, threshold (80 or 100), units_used, included, period_start
spend_cap.reachedplan, cap_usd, threshold (50 or 100), overage_usd, period_start
key.expiringkey_id, name, last4, expires_at, window_days
key.revokedkey_id, reason (user, leak_report or abuse)

Payloads carry ids and counts only, never names. A batch event links to the results; fetch them with your API key.

The batch.completed event your endpoint receives
Assentify-Webhook-Id: ev_example
Assentify-Webhook-Timestamp: 1796029200
Assentify-Signature: v1=example

{
  "id": "ev_example",
  "type": "batch.completed",
  "created_at": "2026-11-30T09:00:02.000Z",
  "data": {
    "batch_id": "bt_example",
    "operation": "normalise",
    "status": "completed",
    "counts": {
      "total": 1,
      "succeeded": 1,
      "failed": 0,
      "cancelled": 0
    },
    "units": 1,
    "results_expire_at": "2026-12-07T09:00:02.000Z",
    "results": "/v1/batches/bt_example/results"
  }
}

What the gateway delivered for a one-item batch, with ids, times and the signature replaced.

Delivery and retries

  • Each event is a POST with a JSON body { id, type, created_at, data } and the headers Assentify-Webhook-Id, Assentify-Webhook-Timestamp (Unix seconds) and Assentify-Signature.
  • Any 2xx within 10 seconds acknowledges it. Anything else is retried, up to 8 attempts, after 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours and 14 hours.
  • An endpoint that fails every delivery for 3 days is disabled (disabled_reason: "failing") and the account owner gets an email. Fix it, then PATCH it with status: "enabled".
  • Use the event id to drop duplicates: a replay or a retry after a lost acknowledgement sends the same event again.

Verify signatures

Use the endpoint's secret for a registered endpoint, and the batch webhook secret for a batch's own webhook_url. Compute HMAC-SHA256 of timestamp + "." + raw body with your secret, hex encode it, prefix v1= and compare it in constant time with each comma-separated value of Assentify-Signature. Refuse timestamps more than 5 minutes from your clock. Verify the raw bytes, before any JSON parsing.

import { createHmac, timingSafeEqual } from 'node:crypto'

// headers: request headers with lower-case names. rawBody: the body exactly as received.
function verify(secret, headers, rawBody) {
  const ts = headers['assentify-webhook-timestamp'] ?? ''
  if (!/^\d+$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false
  const expected = Buffer.from('v1=' + createHmac('sha256', secret).update(ts + '.' + rawBody).digest('hex'))
  return (headers['assentify-signature'] ?? '').split(',').some((value) => {
    const given = Buffer.from(value.trim())
    return given.length === expected.length && timingSafeEqual(given, expected)
  })
}

Errors

At creation: batch_invalid, validation_error, concurrency_limited, plan_feature_unavailable, payload_too_large (over 2 MB), idempotency_conflict. Later: batch_not_cancellable, batch_results_expired, not_found. Per item: the sync endpoint's codes, plus quota_exceeded when a Free account runs out of units mid-batch and spend_cap_reached when a paid account's overage reaches its spend cap.

Limits and units

  • Creating, reading, listing and cancelling bill nothing. Each succeeded item bills what its sync call would; failed and cancelled items bill nothing. Test keys bill nothing.
  • The create call counts toward your requests per second; the items do not.
  • The body may be up to 2 MB.
  • Batch units count toward the same monthly allowance as sync calls. See rate limits and quotas.