> Toden documentation. For the full index fetch /llms.txt. Every page is available as Markdown by appending .md to its URL. Every endpoint is under /api/v1. Identity verification and Risk Intelligence are separate contracts there with different error shapes; /api/kyc and /api/identity are older prefixes that still answer the same. Never invent an endpoint, field or enum value: read the API reference page for the operation first.

# Issue a biometric user token

POST https://sandbox-api.toden.co/api/v1/user-tokens/biometric
Content-Type: application/json

Issues a short-lived token for one person, bound to your scoped publishable key, so your app can call face re-authentication for that person only. Call it from your server, for the person signed in to your own session. The answer is never cached. Needs the `user_tokens.biometric.write` scope.

A biometric token lets a scoped publishable key call `POST /api/v1/biometric/authenticate` and `GET /api/v1/biometric/status/{externalUserId}` for the person, for up to 5 face checks. It also mounts face re-authentication or face enrolment in the embedded flow (`/session/start`, or `POST /session` without a parent): each mount uses one of the 5, the session is bound to the token, and its `/verify` calls are counted with the person's other face checks, at most 5 per mount. Across all tokens, at most 10 face checks per person are admitted every 15 minutes; the next answers `429 too_many_attempts`.

**Limits.** 30 tokens per person an hour, and an hourly limit for the organisation.

**Error codes**

| `error`                        | Status | Meaning                                                                                       |
| ------------------------------ | ------ | --------------------------------------------------------------------------------------------- |
| `invalid_request`              | 400    | The body failed validation.                                                                   |
| `secret_key_required`          | 403    | A publishable key was used. This endpoint accepts secret keys only.                           |
| `environment_mismatch`         | 403    | The key belongs to an environment this deployment does not serve.                             |
| `ip_not_allowed`               | 403    | The key has an IP allowlist and the calling address is not on it.                             |
| `organization_suspended`       | 403    | The organisation is suspended. The response carries `reason` and `suspendedAt`.               |
| `business_not_approved`        | 403    | A live key was used before the business was approved for production.                          |
| `insufficient_scope`           | 403    | The key does not hold `user_tokens.biometric.write`.                                          |
| `invalid_ttl`                  | 422    | `ttlSeconds` is outside the range for this purpose. It is refused, never shortened.           |
| `invalid_publishable_key`      | 422    | `publishableKeyId` is not a live scoped publishable key of this organisation and environment. |
| `user_token_mint_limited`      | 429    | Too many tokens for this person in the last hour.                                             |
| `rate_limited`                 | 429    | Too many tokens for the organisation in the last hour.                                        |
| `rate_limit_store_unavailable` | 503    | The limit cannot be checked right now. Retry shortly.                                         |

A missing or unknown key answers `401`, where `error` is a short sentence rather than a code.

Requires a secret (`sk_`) key. A publishable key receives `403 secret_key_required`.

Reference: https://docs.toden.co/api-reference/verification/user-tokens/mint-biometric-user-token

## Authentication

- `Authorization` header (bearer token, required) — Send the API key as a Bearer token. Each operation states whether a publishable key is enough or a secret key is required. A scoped publishable key has Verification flow access, the fixed set `flow.run`, `flow.config.read` and `verifications.status.read`; a scoped secret key reaches what its scopes allow.

## Servers

- `https://sandbox-api.toden.co` (Sandbox, default)
- `https://api.toden.co` (Production)

## Request

### Body (application/json)

This endpoint expects an UserTokenMintRequest.

- `externalUserId` (string, required) — Your reference for the person signed in to your own session. The token works only for this person.
- `publishableKeyId` (string, required) — The id of the scoped publishable key your app uses. The token works only with that key and its replacements.
- `ttlSeconds` (integer, optional) — How long the token lasts, from 60 seconds. Presence: default 86400 (24 hours), at most 604800 (7 days). Biometric: default 600 (10 minutes), at most 900 (15 minutes). Never beyond the minting key's own expiry.

## Response

### 201

The token, shown once.

- `object` ("user_token", required) — Always `user_token`.
- `id` (string, required) — The token's public id (`utk_`), for revoking it and for your records. Not a credential.
- `token` (string, required) — The token itself. Shown once and never stored by Toden: pass it to your app and do not log it.
- `purpose` (enum, required) — `presence` or `biometric`.
  - Allowed values: `presence`, `biometric`
- `externalUserId` (string, required) — The person the token works for.
- `expiresAt` (datetime, required) — When the token stops working.
- `maxUses` (integer, required, nullable) — Biometric: 5 face checks. Presence: null, any number of calls until it expires.

## Errors

### 400 Bad Request Error

The request body, query or path was invalid.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 401 Unauthorized Error

The Authorization header is missing, or the API key is unknown or revoked.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 403 Forbidden Error

The key may not call this endpoint, or the organisation may not use this feature.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 422 Unprocessable Entity Error

The request was understood but cannot be processed as sent.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 429 Too Many Requests Error

A rate limit was reached. Retry after a short wait.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 503 Service Unavailable Error

The service is temporarily unavailable.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

## Examples

**Request**

```json
{
  "externalUserId": "user_8f21",
  "publishableKeyId": "cmwpk0a4p0004qw9k2m7f3ba1"
}
```

**Response**

```json
{
  "object": "user_token",
  "id": "utk_91639aeacc0bd7f71d033342285d2775",
  "token": "ut_live_example",
  "purpose": "biometric",
  "externalUserId": "user_8f21",
  "expiresAt": "2026-11-22T10:10:00.000Z",
  "maxUses": 5
}
```

**SDK Code**

```python
import requests

url = "https://sandbox-api.toden.co/api/v1/user-tokens/biometric"

payload = {
    "externalUserId": "user_8f21",
    "publishableKeyId": "cmwpk0a4p0004qw9k2m7f3ba1"
}
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://sandbox-api.toden.co/api/v1/user-tokens/biometric';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"externalUserId":"user_8f21","publishableKeyId":"cmwpk0a4p0004qw9k2m7f3ba1"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://sandbox-api.toden.co/api/v1/user-tokens/biometric"

	payload := strings.NewReader("{\n  \"externalUserId\": \"user_8f21\",\n  \"publishableKeyId\": \"cmwpk0a4p0004qw9k2m7f3ba1\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://sandbox-api.toden.co/api/v1/user-tokens/biometric")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"externalUserId\": \"user_8f21\",\n  \"publishableKeyId\": \"cmwpk0a4p0004qw9k2m7f3ba1\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://sandbox-api.toden.co/api/v1/user-tokens/biometric")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"externalUserId\": \"user_8f21\",\n  \"publishableKeyId\": \"cmwpk0a4p0004qw9k2m7f3ba1\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sandbox-api.toden.co/api/v1/user-tokens/biometric', [
  'body' => '{
  "externalUserId": "user_8f21",
  "publishableKeyId": "cmwpk0a4p0004qw9k2m7f3ba1"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://sandbox-api.toden.co/api/v1/user-tokens/biometric");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"externalUserId\": \"user_8f21\",\n  \"publishableKeyId\": \"cmwpk0a4p0004qw9k2m7f3ba1\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "externalUserId": "user_8f21",
  "publishableKeyId": "cmwpk0a4p0004qw9k2m7f3ba1"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox-api.toden.co/api/v1/user-tokens/biometric")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```