Authentication#
Rokh accepts two types of authentication:
| Type | Who uses it | How |
|---|---|---|
| API key | Your server | The Authorization: Bearer <key> header on each request |
| Panel session | A person in the vendor panel | A session cookie after POST /api/vendor/login |
Use an API key for all calls from your server. Use the panel session only in the vendor panel.
API keys#
An API key starts with rk_live_. Rokh shows the full key one time only, when you make it. Rokh keeps only a hash of the key. If you lose a key, make a new key and revoke the old key.
An API key acts as your vendor account. It can do all the operations of the vendor API, with these exceptions:
- It cannot make or revoke API keys.
- It cannot change the panel password.
For these operations, sign in to the vendor panel.
Make an API key#
- Sign in to the vendor panel at
https://rokh.id/vendor. - Open Developers.
- In API keys, type a name for the key. Use the name of the server that uses the key.
- Click Make a key.
- Copy the key. Put it in the secret store of your server.
You can also make a key with the API, from a panel session:
POST /api/vendor/panel/api-keys
Content-Type: application/json
{"label": "payments server"}
The response has the status 201 and the key in api_key.secret:
{"api_key": {"id": "6f1c…", "label": "payments server", "prefix": "rk_live_PPYM",
"created_at": "2026-10-12T08:30:00+00:00", "last_used_at": null, "revoked_at": null,
"active": true, "secret": "rk_live_PPYM…"}}
Use an API key#
Send the key in the Authorization header of each request:
curl https://rokh.id/api/vendor/requests -H "Authorization: Bearer $ROKH_API_KEY"
When a request has an Authorization header, Rokh uses only that header. Rokh does not use a session cookie on the same request. A wrong, revoked or incorrect key always gives the status 401.
See your keys#
GET /api/vendor/panel/api-keys gives the list of your keys. The list shows the name, the first 12 characters (prefix), the date of the last use and the status of each key. The list never shows a full key.
Rokh records the time of the last use. It updates this time at most one time each minute.
Revoke an API key#
- Sign in to the vendor panel.
- Open Developers.
- In API keys, find the key. Click Revoke.
You can also send DELETE /api/vendor/panel/api-keys/{key_id} from a panel session. Rokh refuses the key immediately. You cannot make a revoked key active again.
Warning: If a person who must not have a key knows the key, revoke the key immediately. Then make a new key.
Security rules#
- Keep API keys on your server only.
- Do not put an API key in a web page, a mobile app or a source code repository.
- Use one key for each server. Then you can revoke one key without a stop of other servers.
- Do not send API keys in a URL. Send them only in the
Authorizationheader. - The vendor API does not accept calls from web pages of other sites (no CORS). Your server must call the API.
- Rokh accepts HTTPS only.
Panel session#
The vendor panel uses a session cookie. Do not use the panel session from your server.
| Endpoint | Body | Result |
|---|---|---|
POST /api/vendor/login |
{"username": "…", "password": "…"} |
Sets the session cookie |
POST /api/vendor/logout |
none | Ends the session |
GET /api/vendor/session |
none | {"authenticated": true, "vendor": {…}} or {"authenticated": false, "vendor": null} |
Rokh limits the number of sign-in attempts from one address. Too many attempts give the status 429 for a short time.
Errors of authentication#
| Status | Cause | What to do |
|---|---|---|
401 |
No key, a wrong key, a revoked key or a disabled vendor account | Examine the key. Make a new key if necessary. |
403 |
An API key on an operation that needs the panel session | Sign in to the panel for this operation. |
404 |
The request belongs to a different vendor | Use the key of the vendor that made the request. |