Batches and webhooks
Available in the APIAvailable 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"}}'{
"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.
| Field | Type | Meaning |
|---|---|---|
| operation | string | transliterate, variants, normalise or match. |
| items[] | array | Each 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. |
| defaults | object | Fields applied to every item, for example target_script or hints. |
| webhook_url | string | Optional 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_days | integer | 1 to 30, default 7. How long results are kept after the batch ends. |
| metadata | object | Up 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":" "}]}'{
"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_erroronitems. - A duplicate
custom_idis avalidation_erroron that item. - Too many batches running at once is
429 concurrency_limitedwithRetry-After: 10.
| Plan | Items per batch | Batches running at once |
|---|---|---|
| Free | 100 | 1 |
| Developer | 1,000 | 2 |
| Growth | 1,000 | 5 |
| Scale | 1,000 | 10 |
| Enterprise | Up to 10,000 | 20 |
Lifecycle
Poll the batch
curl https://api.arabinames.assentify.com/v1/batches/bt_example \
-H "Authorization: Bearer $ARABINAMES_KEY"{
"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.
| Status | Meaning |
|---|---|
queued | Accepted, waiting for a worker. Paid plans are picked before Free, then oldest first. |
running | Items are processed in chunks of 50. An item that times out at the engine is retried twice. |
completed | Every item succeeded. |
completed_with_errors | Done; some items failed. Each failed item carries its error code. |
cancelling | Cancel requested while running; the worker stops at the next chunk. |
cancelled | Stopped. Items not processed are marked cancelled. |
failed | The batch could not finish within 24 hours; remaining items are failed with internal_error. |
expired | results_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"{
"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.
limitis 1 to 100 (default 20); passnext_cursorback ascursorwhilehas_moreis true. status=succeededorstatus=failedfilters the list.- A succeeded item has
result: the sync response body without itsid. A failed item haserror.codeand, where it applies,error.param. A cancelled item has neither. - After
results_expire_atthe call answers410 batch_results_expired. Abatch.results_expiringevent 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"}'{
"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:managescope. 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. urlmust 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.eventstakes event types, a group such asbatch.*, or*for everything.- The
secretis shown once, here and on rotation. Store it in your secret manager. - Manage with
GET,PATCHandDELETE /v1/webhook-endpoints/{id}.POST .../rotate-secretissues a new secret; the old one keeps signing for 24 hours, so deliveries carry twov1=values meanwhile.POST .../testqueues a test event.GET .../deliveriesshows 30 days of attempts (status codes and timings, no bodies) andPOST .../deliveries/{delivery_id}/replaysends 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"{
"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/rotateissues a new secret and returns it once. The previous secret keeps signing for 24 hours, so deliveries carry twov1=values meanwhile;previous_secret_valid_untilsays until when.GET /v1/batch-webhook-secretreturns the dates (created_at,shown_at,previous_secret_valid_until), never the secret.- Both need a key with the
webhooks:managescope and bill nothing. Store the secret in your secret manager; it never appears in our logs.
Events
| Event | data |
|---|---|
batch.completed | batch_id, operation, status, counts, units, results_expire_at, results |
batch.failed | batch_id, code, counts |
batch.cancelled | batch_id, counts, units |
batch.results_expiring | batch_id, results_expire_at (sent 24 hours before) |
usage.threshold_reached | plan, threshold (80 or 100), units_used, included, period_start |
spend_cap.reached | plan, cap_usd, threshold (50 or 100), overage_usd, period_start |
key.expiring | key_id, name, last4, expires_at, window_days |
key.revoked | key_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.
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
POSTwith a JSON body{ id, type, created_at, data }and the headersAssentify-Webhook-Id,Assentify-Webhook-Timestamp(Unix seconds) andAssentify-Signature. - Any
2xxwithin 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, thenPATCHit withstatus: "enabled". - Use the event
idto 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.