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

# Upload a drawn signature

POST https://sandbox-api.toden.co/api/kyc/upload/signature
Content-Type: application/json

Stores a signature the applicant drew on screen, for a supporting document that asks for one. You send the strokes as JSON, the image is drawn for you, and it is stored as a `supporting_document` upload. The returned `mediaId` is referenced in a verification exactly like an uploaded file, and is discarded after 30 minutes if it is never referenced.

A hosted verification session token is also accepted in place of an API key. An optional `X-Myaza-Device-Id` header (at most 64 characters) records which device made the capture.

Errors carry a stable code in `error` and a sentence written for the applicant in `message`.

**Error codes**

| `error` | Status | Meaning |
|---|---|---|
| `invalid_signature` | 400 | The body is not a readable signature, the pad size is outside 50 to 4000, or the signature has too many strokes or points. |
| `signature_empty` | 422 | The strokes are too short to be a signature, for example a single tap. |
| `signature_not_saved` | 500 | The signature could not be stored. Try again. |
| `Missing or invalid Authorization header` | 401 | No bearer credential was sent. |
| `Invalid API key` | 401 | The key is unknown or revoked. |
| `environment_mismatch` | 403 | The key belongs to an environment this host does not serve. |
| `origin_not_allowed` | 403 | The request origin is not on the publishable key allowlist. |
| `ip_not_allowed` | 403 | The caller address is not on the secret key allowlist. |
| `organization_suspended` | 403 | The organisation is suspended. |
| `business_not_approved` | 403 | A production key was used before the business was approved. |

Accepts a publishable (`pk_`) or secret (`sk_`) key.

Reference: https://docs.toden.co/api-reference/verification/media/upload-signature

## 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.

## Servers

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

## Request

### Body (application/json)

This endpoint expects an UploadSignatureRequest.

- `strokes` (list of list of UploadSignatureRequestStrokesItemsItems, required) — The strokes, in the order drawn. Each stroke is the list of points the pen passed through. At most 200 strokes and 20,000 points in total.
- `width` (double, required) — The width of the signing pad the points were drawn on.
- `height` (double, required) — The height of the signing pad the points were drawn on.
- `sessionId` (string, optional) — The resumable session this signature belongs to, so the image is kept for the life of that session rather than the default 30 minutes.

## Response

### 200

The signature was stored.

- `mediaId` (string, required) — The identifier to reference in `mediaIds` when creating a verification.

## 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.

### 500 Internal Server Error

An unexpected error occurred.

- `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.

## Types

### UploadSignatureRequestStrokesItemsItems

One point, in the coordinates of the signing pad.

- `x` (double, required) — Horizontal position.
- `y` (double, required) — Vertical position.

## Examples

**Request**

```json
{
  "strokes": [
    [
      {
        "x": 40,
        "y": 120
      },
      {
        "x": 90,
        "y": 60
      },
      {
        "x": 150,
        "y": 130
      },
      {
        "x": 220,
        "y": 70
      },
      {
        "x": 300,
        "y": 125
      }
    ]
  ],
  "width": 600,
  "height": 200
}
```

**Response**

```json
{
  "mediaId": "med_01j9x2k4m8"
}
```

**SDK Code**

```python
import requests

url = "https://sandbox-api.toden.co/api/kyc/upload/signature"

payload = {
    "strokes": [[
            {
                "x": 40,
                "y": 120
            },
            {
                "x": 90,
                "y": 60
            },
            {
                "x": 150,
                "y": 130
            },
            {
                "x": 220,
                "y": 70
            },
            {
                "x": 300,
                "y": 125
            }
        ]],
    "width": 600,
    "height": 200
}
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/kyc/upload/signature';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"strokes":[[{"x":40,"y":120},{"x":90,"y":60},{"x":150,"y":130},{"x":220,"y":70},{"x":300,"y":125}]],"width":600,"height":200}'
};

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/kyc/upload/signature"

	payload := strings.NewReader("{\n  \"strokes\": [\n    [\n      {\n        \"x\": 40,\n        \"y\": 120\n      },\n      {\n        \"x\": 90,\n        \"y\": 60\n      },\n      {\n        \"x\": 150,\n        \"y\": 130\n      },\n      {\n        \"x\": 220,\n        \"y\": 70\n      },\n      {\n        \"x\": 300,\n        \"y\": 125\n      }\n    ]\n  ],\n  \"width\": 600,\n  \"height\": 200\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/kyc/upload/signature")

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  \"strokes\": [\n    [\n      {\n        \"x\": 40,\n        \"y\": 120\n      },\n      {\n        \"x\": 90,\n        \"y\": 60\n      },\n      {\n        \"x\": 150,\n        \"y\": 130\n      },\n      {\n        \"x\": 220,\n        \"y\": 70\n      },\n      {\n        \"x\": 300,\n        \"y\": 125\n      }\n    ]\n  ],\n  \"width\": 600,\n  \"height\": 200\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/kyc/upload/signature")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"strokes\": [\n    [\n      {\n        \"x\": 40,\n        \"y\": 120\n      },\n      {\n        \"x\": 90,\n        \"y\": 60\n      },\n      {\n        \"x\": 150,\n        \"y\": 130\n      },\n      {\n        \"x\": 220,\n        \"y\": 70\n      },\n      {\n        \"x\": 300,\n        \"y\": 125\n      }\n    ]\n  ],\n  \"width\": 600,\n  \"height\": 200\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sandbox-api.toden.co/api/kyc/upload/signature', [
  'body' => '{
  "strokes": [
    [
      {
        "x": 40,
        "y": 120
      },
      {
        "x": 90,
        "y": 60
      },
      {
        "x": 150,
        "y": 130
      },
      {
        "x": 220,
        "y": 70
      },
      {
        "x": 300,
        "y": 125
      }
    ]
  ],
  "width": 600,
  "height": 200
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://sandbox-api.toden.co/api/kyc/upload/signature");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"strokes\": [\n    [\n      {\n        \"x\": 40,\n        \"y\": 120\n      },\n      {\n        \"x\": 90,\n        \"y\": 60\n      },\n      {\n        \"x\": 150,\n        \"y\": 130\n      },\n      {\n        \"x\": 220,\n        \"y\": 70\n      },\n      {\n        \"x\": 300,\n        \"y\": 125\n      }\n    ]\n  ],\n  \"width\": 600,\n  \"height\": 200\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "strokes": [[
      [
        "x": 40,
        "y": 120
      ],
      [
        "x": 90,
        "y": 60
      ],
      [
        "x": 150,
        "y": 130
      ],
      [
        "x": 220,
        "y": 70
      ],
      [
        "x": 300,
        "y": 125
      ]
    ]],
  "width": 600,
  "height": 200
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox-api.toden.co/api/kyc/upload/signature")! 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()
```