RKH

Webhooks#

A webhook is a message from Rokh to your server. Rokh sends it when a request changes. Then you do not have to read each request again and again.

Events#

Event Rokh sends it when
request.started The customer starts the steps.
request.completed The report is ready. The request has the status submitted.
request.revoked You revoked the request.
request.expired The link reached expires_at before the end of the steps. Rokh sends it a few minutes after the expiry.
request.vendor_input_changed A person set or removed the flag for incorrect values. request.vendor_input has the new flag. Refer to The flag for incorrect values.
request.tags_changed A person added or removed a tag. request.tags has the tags. Refer to Tags.
ping You sent a test from the panel or with POST /api/vendor/panel/webhook/test.

Rokh sends each event one time for each request. There are two exceptions. When Rokh checks a finished request again and the result changes, Rokh sends request.completed again. Refer to A corrected result. Rokh sends request.vendor_input_changed one time for each change of the flag, and request.tags_changed one time for each tag that a person adds or removes.

The request object of each message has vendor_input, the flag for incorrect values, with person but without history. It also has tags, the tags of the request.

Set your webhook#

Each vendor account has one webhook address.

  1. Sign in to the vendor panel.
  2. Open Developers.
  3. In Webhooks, type the address of your server. Select the events.
  4. Click Save webhook.
  5. Copy the signing secret. Rokh shows it one time only.

You can also use the API:

PUT /api/vendor/panel/webhook
Authorization: Bearer rk_live_…
Content-Type: application/json

{"url": "https://api.example.com/rokh/webhook",
 "events": ["request.started", "request.completed", "request.revoked", "request.expired"],
 "enabled": true}
Field Rules
url An HTTPS address on the public internet, at most 500 characters. It cannot contain a user name, a password or a fragment. Its host must not resolve to a private address.
events A list of events. If you do not send it, Rokh keeps the saved events. A new webhook gets ["request.completed"].
enabled true or false. Default: true. Use false to stop the messages for a time. Rokh then also stops the retries of messages that it did not deliver.
rotate_secret true makes a new signing secret. The old secret stops immediately.

The response has the signing secret in webhook.secret only at the first save and after rotate_secret. Keep the secret on your server.

Endpoint Effect
GET /api/vendor/panel/webhook The settings and the last 50 deliveries
PUT /api/vendor/panel/webhook Save the settings
DELETE /api/vendor/panel/webhook Remove the webhook
POST /api/vendor/panel/webhook/test Send a ping now. The response has the result of the delivery.

The message#

Rokh sends POST with a JSON body:

{
  "event": "request.completed",
  "sent_at": "2026-10-12T09:41:07.512334+00:00",
  "request": {
    "id": "e501bbf9363c46e38c7a030b8bce9d4c",
    "customer_label": "order-10493",
    "status": "submitted",
    "decision": "pass",
    "score": 100.0,
    "decision_reasons": [],
    "selected_document_type": "passport",
    "created_at": "2026-10-12T09:30:02.104558+00:00",
    "started_at": "2026-10-12T09:36:09.574092+00:00",
    "submitted_at": "2026-10-12T09:40:43.881202+00:00",
    "expires_at": "2026-10-15T09:30:02.104558+00:00",
    "reissued_from": null
  },
  "panel_url": "https://rokh.id/vendor#/requests/e501bbf9363c46e38c7a030b8bce9d4c"
}

decision, score and decision_reasons are null until the report is ready. The ping message has the fields event, vendor and sent_at only.

A corrected result#

Rokh can check a finished request again, for example after Rokh repairs a fault in a check. A person can also pass a no_pass request manually. When the decision, the score or the reasons change, Rokh sends request.completed again. This message has a new X-Rokh-Delivery and the field correction:

"correction": {
  "rechecked_at": "2026-10-14T00:32:13.975593+00:00",
  "previous": {"decision": "no_pass", "score": 50.0, "decision_reasons": ["document_fail"]},
  "kind": "recheck",
  "initiated_by": "rokh"
}
Field Contents
correction.rechecked_at The time when Rokh started the new check, or the time of the manual decision
correction.previous The decision, the score and the reasons that you had before the change
correction.kind recheck: a new automatic check. manual_decision: a person passed the request. manual_decision_withdrawn: a person withdrew a manual pass. See Pass a request manually.
correction.initiated_by rokh: the Rokh operations team made the change. vendor: you made it, in the panel or with the API.

The field request has the new result. Read the new report with GET /api/vendor/requests/{id}/report.json. If your system did an action for the previous result, compare the two results. Then decide what to do. When a new check gives the same result, Rokh does not send a message. A message without correction is the first result.

The message has these headers:

Header Contents
X-Rokh-Event The event
X-Rokh-Delivery The identifier of the delivery. It stays the same in each retry.
X-Rokh-Signature sha256= and the HMAC-SHA256 of the body, in hexadecimal
User-Agent Rokh-Webhooks/1.0
Content-Type application/json

Verify the signature#

Calculate the HMAC-SHA256 of the raw body with your signing secret. Compare it with the value in X-Rokh-Signature. Use a comparison that takes the same time for all values. If the values are different, refuse the message.

Python:

import hashlib, hmac

def valid(secret: str, raw_body: bytes, header: str) -> bool:
    expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, header or "")

Node.js:

const crypto = require('crypto');

function valid(secret, rawBody, header) {
  const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
  const a = Buffer.from(expected), b = Buffer.from(header || '');
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

PHP:

function valid(string $secret, string $rawBody, string $header): bool {
    $expected = 'sha256=' . hash_hmac('sha256', $rawBody, $secret);
    return hash_equals($expected, $header);
}

Warning: Use the raw body. If your framework reads the JSON and writes it again, the bytes change and the signature is not correct.

Answer a message#

Retries#

If your server does not answer with 2xx in 10 seconds, Rokh sends the message again:

Attempt Time after the attempt before
2 30 seconds
3 2 minutes
4 10 minutes
5 1 hour
6 6 hours
7 24 hours

After the seventh attempt, Rokh stops. The retries continue for about 31 hours after the first attempt. The list of deliveries (GET /api/vendor/panel/webhook) shows each attempt, the status code and the error.

A retry goes to the address in your settings at the time of the retry. If you change the address, the retries go to the new address.

Make sure that your server receives messages#

  1. Save the webhook.
  2. Click Send a test in the panel, or send POST /api/vendor/panel/webhook/test.
  3. Examine the delivery in the list. ok is 1 when your server answered with 2xx.

Rokh vendor API. The text follows ASD-STE100 Simplified Technical English.