RKH

Requests#

A request is one verification of one customer. You make the request on your server. Rokh gives you a customer link. The customer opens the link and does the steps. Then Rokh makes a report.

Make a request#

POST /api/vendor/requests
Authorization: Bearer rk_live_…
Idempotency-Key: order-10493
Content-Type: application/json
{
  "customer_label": "order-10493",
  "expires_in_hours": 72,
  "return_url": "https://www.example.com/kyc/done?order=10493",
  "expected_fields": {
    "full_name": "سارا محمدی",
    "birthday": "1372/05/14",
    "birthday_calendar": "jalali",
    "national_id": "0012345679"
  },
  "flow_policy": {
    "allowed_document_types": ["smart_id", "passport"],
    "name_match_mode": "full_name",
    "accepted_name_spellings": ["Sara Mohammadi"],
    "movement": "adaptive",
    "attempt_limit": 3,
    "declaration_sentences": ["اینجانب سارا محمدی با کد ملی 0012345679 متعهد می‌شوم که این حساب متعلق به من است."],
    "held_document_sensitivity": "standard",
    "branding": {"label": "Example shop"}
  }
}

The response has the status 201 and the request record. Give customer_url to your customer.

Fields of the body#

Field Type Necessary Rules
customer_label string yes Your reference for the customer, for example an order number. 1 to 120 characters. Rokh shows it in the panel and sends it back in reports and webhooks.
expires_in_hours integer no The time until the customer link stops, in whole hours. 1 to 168. Default: 24.
issuer_country string no "IR". Default: "IR".
expected_fields object no The identity that you expect. Rokh verifies only the fields that you send. See Expected identity.
flow_policy object yes The steps and the rules of the verification. See Request policy.
return_url string no The address in your site for the customer after the last step. See Your own site.

Rokh refuses a field that it does not know, also a field with a spelling error. The response then has the status 400 and names the field.

Idempotency-Key#

A network error can stop your request before you receive the response. If you send the request again, Rokh can make a second request. To prevent this, send an Idempotency-Key header.

Expected identity#

Send the identity that you expect in expected_fields. Send only the fields that you know. The report tells you which fields Rokh verified.

Field Rules
full_name The given name and the family name, in the script of the document. Use Persian script for Iranian documents.
first_name The given name only. Use it with "name_match_mode": "first_name".
given_names, surname The given name and the family name as two fields.
birthday The date of birth as YYYY/MM/DD. It cannot be in the future.
birthday_calendar jalali or gregorian. It is necessary when you send birthday. Rokh does not guess the calendar.
national_id The ten digits of the Iranian national code. Keep the zeros at the start. The control digit must be correct.
document_number The number of the document, for example a passport number.

Each value has at most 120 characters.

Note: If you send national_id, the customer must use a document that shows the national code. The smart national ID card (smart_id) always shows it. If the document does not show the code, the national code check is inconclusive and the decision is no_pass.

Request policy#

flow_policy sets the steps and the rules. Rokh keeps the policy with the request. Nobody can change the policy after you make the request. The customer cannot change it.

Key Values Default Effect
allowed_document_types A list of smart_id, passport, booklet, driving_licence All four The documents that the customer can choose. booklet is the شناسنامه.
name_match_mode full_name or first_name full_name Compare the full name, or the given name only.
accepted_name_spellings Up to 10 strings, 1 to 120 characters each none More spellings that you accept, in Persian or Latin script. Rokh does not make spellings automatically.
movement adaptive or always adaptive always: every customer turns the head. adaptive: Rokh asks for a head turn when it needs more evidence.
attempt_limit 1 to 10 3 The number of attempts for each step. Only an attempt that the customer sends for checks counts.
declaration_sentences Up to 8 sentences in Persian script, 1 to 1000 characters each none The customer reads these sentences aloud with the document in the hand. No sentence: no declaration step.
held_document_sensitivity strict, standard, relaxed, report_only standard How strictly Rokh examines the document in the hand during the declaration. report_only: Rokh reports the result to you but never asks the customer to try again.
branding {"label": "…", "declaration_explainer": ["onyx"]} none label: at most 120 characters. The customer sees the display name of your account. Rokh uses this label only if the account has no display name. declaration_explainer: see Declaration illustration.
network An object, see Network settings see below How network and device observations count.
scoring An object, see Score settings see below The points of each finding in the score.

The total time of the steps is 20 minutes from the start. You cannot change this time in the request. Your rules and thresholds can change it.

Declaration illustration#

Before the declaration step, the customer sees an animated illustration. A person holds the document under the chin, and the sentence fills word by word. The illustration shows the document that the customer selected.

Set branding.declaration_explainer to one or two of these values: alternate, sand, pearl, indigo, onyx. If you send two values, the customer sees the two illustrations side by side, in the order that you send them. In alternate, the people of indigo and pearl show in turn in one illustration, in this order. Send alternate only as the single value. To see the illustrations, open the Settings page of the vendor panel.

If the request has no value, Rokh uses the value in your account (PATCH /api/vendor/profile). If your account has no value, Rokh uses its default illustration, alternate. This setting changes only the instructions page. It does not change the checks or the result.

Network settings#

flow_policy.network sets how network observations count.

Key Values Default Effect
ip_country any or iran_only any iran_only: a customer with a non-Iranian IP address cannot start. The customer sees a message that tells them to turn off a VPN.
foreign_ip_points 0 to 100 10 Points that a non-Iranian IP address takes from the network score.
hosting_ip_points 0 to 100 10 Points for a network of a data centre, a server company or a VPN.
tor_points 0 to 100 20 Points for a Tor exit node.
address_change_points 0 to 100 15 Points when the IP address changes during a recording.
risk_can_fail true or false true true: a high combined risk (60 points or more from two groups) fails the step. false: Rokh only reports it.

A foreign IP address or a VPN alone never fails a step.

Score settings#

flow_policy.scoring sets the points of each finding. The score starts at 100. Each finding takes its points. The score is never less than 0.

Key Values Default Points for
failed_check_points 0 to 100 40 Each required check that failed, and each required step without a result
inconclusive_check_points 0 to 100 15 Each required check that is inconclusive
fraud_flag_points 0 to 100 25 Each fraud flag
network_and_device true or false true true: each network and device observation takes its points from flow_policy.network

Use 0 to ignore a type of finding. A network observation or a fraud flag that occurs in more than one step counts one time. The score never changes the decision.

Rules and thresholds#

Rokh decides each check with rules: thresholds, switches for exception rules, lists of letters and lists of words. Each rule has a default value. Rokh's operations desk can change the values for all vendors. Rokh can also give your account the page Rules and thresholds in the vendor panel. On that page you can change the values for your account. Each rule shows a description, an example and the effect of a lower or higher value.

The request record#

POST /api/vendor/requests, GET /api/vendor/requests/{id} and POST /api/vendor/requests/{id}/revoke return the request record:

Field Contents
id The identifier of the request (32 hexadecimal characters)
customer_url The customer link. Give it to the customer. Do not show it to other persons.
customer_label Your reference
status The status. See Status.
raw_status The stored status. It is pending or in_progress when status is expired.
created_at, expires_at, submitted_at Times. submitted_at is null until the end of the steps.
expected_fields The identity that you sent
flow_policy The policy that Rokh keeps, with all defaults
selected_document_type The document that the customer chose, or null
return_url The return address that you sent, or null
live_sessions, media, captures The sessions, the recordings and the photos of the request
report The report after the end of the steps, or null. See Results and evidence.
vendor_id Your vendor identifier
manual_field_review, document_type, require_back, issuer_country Fields for compatibility. You can ignore them.

Status#

status Meaning
pending The customer has not started.
in_progress The customer started the steps.
processing All steps are complete. Rokh does the last checks.
submitted Rokh has finished. The report is ready.
revoked You revoked the link.
expired The link reached expires_at before the end of the steps.

A request that is submitted has a decision. The decision can be pass or no_pass. If the customer used all attempts of a step, the request is also submitted, with the decision no_pass.

Find requests#

GET /api/vendor/requests gives your requests, the newest first. Each row has the status, the decision, the score and the reasons, but not the full report.

Query parameter Effect
limit The number of rows, 1 to 1000. Default: 1000.
offset The number of rows to skip. Default: 0.
customer_label Only the requests with this reference
status Only the requests with this status: pending, in_progress, processing, submitted, revoked or expired

Example: find the requests of one order.

curl "https://rokh.id/api/vendor/requests?customer_label=order-10493" -H "Authorization: Bearer $ROKH_API_KEY"

Each row has detail_url and report_url. Use them to read the full record and the report.

GET /api/vendor/requests/{id} gives the full record of one request.

Revoke a request#

POST /api/vendor/requests/{id}/revoke stops the customer link. You can revoke a request with the status pending or in_progress. Rokh keeps all evidence that the customer sent before. A revoked link shows a page that tells the customer that the link is not valid.

Reissue a request#

POST /api/vendor/panel/requests/{id}/reissue makes a new request with the same reference, the same expected identity and the same policy.

{"expires_in_hours": 72}

You can reissue a request with the status expired, revoked or submitted. The response has the status 201, the new request in request and the old identifier in reissued_from. The new request has a new customer link. The old request does not change.

Watch a request#

Use webhooks. They tell your server about each change.

If you cannot receive webhooks, read the request from time to time. Do not read it more than one time each 10 seconds. You can also read GET /api/vendor/panel/requests/{id}/version. This small response has version, which changes when the request changes, and poll_ms, the time that Rokh recommends until the next read. When poll_ms is 0, the request does not change again.

Other request operations#

Endpoint Effect
GET /api/vendor/panel/requests/{id}/qr.svg A QR code of the customer link
GET /api/vendor/panel/requests The list of the vendor panel
GET /api/vendor/panel/requests.csv The same list as CSV
GET /api/vendor/panel/requests/{id} The view of one request in the vendor panel
GET, POST /api/vendor/panel/requests/{id}/review Your notes, tags and outcome. Body: {"kind": "note", "value": "…"}. kind is note, tag or outcome. An outcome is confirm, dispute or follow_up.
DELETE /api/vendor/panel/requests/{id}/review/{review_id} Remove a note, a tag or an outcome
POST /api/vendor/requests/{id}/reanalyze Do the automatic checks again on the same evidence. The new report replaces the old report.
POST /api/vendor/requests/{id}/field-review Record your own reading of the printed fields after the end. Body: {"confirmed_from_original": true, "fields": {"full_name": "…", "national_id": "…"}}. This does not change the decision.

Tags#

A tag is a short text on a request, for your team. You or the Rokh operations team add and remove tags with the review endpoints above. Your panel and the Rokh panel show the same tags on the row of the request. The request list, the record of a request and each webhook message have tags, a list of the tag texts, oldest first. When a person adds or removes a tag, your webhook gets the event request.tags_changed.

The panels give these tags for the reason of a failure that a person saw in the evidence. You can also use any other text.

Tag Meaning
glasses The customer wore glasses.
head_cover A hat or a head cover was on the face.
mask The customer wore a mask.
face_not_visible The face was not fully in the frame.
poor_light The light was too low.
blurry The image was not sharp.
document_glare Light reflected on the document.
document_damaged The document had damage or was not legible.
wrong_document The customer showed a different document.
other_person A different person did the steps.
declaration_not_read The customer did not read the declaration correctly.
head_turn_missed The customer did not turn the head as the step told.
possible_fraud The try looks like an attempt to deceive: for example, the customer showed a picture of the document on another screen.

A tag does not change a check, the decision or the score. The customer does not see tags.

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