> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.withverifa.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.withverifa.com/_mcp/server.

# Upload a document to a session

POST https://api.withverifa.com/api/v1/sessions/{session_id}/documents
Content-Type: multipart/form-data

Upload a document image (ID front, ID back, or selfie) to a session via
the API. This enables document submission from native mobile apps or
custom UIs without using the hosted capture flow.

If a document of the same type already exists, it is replaced (idempotent).
If the session was in `pending` status, it transitions to `capturing`.

**Required scope:** `documents:write`


Reference: https://docs.withverifa.com/api-reference/documents/upload-session-document

## Authentication

- `X-API-Key` header (required) — Organization API key. Keys are prefixed with `vk_live_` (production) or `vk_sandbox_` (sandbox).

## Request

### Path parameters

- `session_id` (string, required) — Session ID (`ses_*`).

### Headers

- `Verifa-Version` (date, optional) — API version date string (e.g. `2026-02-01`). If omitted, the version pinned to your API key is used.

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required) — The document image file (JPEG, PNG, WebP, or PDF). Max 10MB.
- `document_type` (enum, required) — The type of document being uploaded.
- `poa_document_type` (enum, optional) — Proof-of-address document subtype. Optional, but strongly recommended when `document_type` is `proof_of_address`: without it the check cannot apply the per-type recency window and falls back to the policy default.
- `poa_document_date` (date, optional) — Date printed on the proof-of-address document (`YYYY-MM-DD`). Compared against the date OCR reads off the document — a disagreement larger than the policy's `date_match_tolerance_days` raises a `date_mismatch` reason.
- `poa_issuing_country` (string, optional) — Country that issued the proof-of-address document. Optional; defaults to the country of the ID document on the session. Drives country-aware address normalisation, PO-box detection, and any per-country recency override in the policy.

## Response

### 201

Document uploaded successfully.

- `id` (string, required) — Public ID of the uploaded document.
- `session_id` (string, required) — Public ID of the session.
- `document_type` (enum, required) — The type of document uploaded.
  - Allowed values: `id_front`, `id_back`, `selfie`
- `mime_type` (string, required) — MIME type of the uploaded file.
- `file_size_bytes` (integer, required) — Size of the uploaded file in bytes.
- `created_at` (datetime, required) — When the document was uploaded.

## Errors

### 400 Bad Request Error

Invalid request parameters.

- `error` (string, required) — Short error code.
- `status_code` (integer, required) — HTTP status code.
- `detail` (string, optional) — Human-readable error description.

### 401 Unauthorized Error

Missing or invalid API key.

- `error` (string, required) — Short error code.
- `status_code` (integer, required) — HTTP status code.
- `detail` (string, optional) — Human-readable error description.

### 404 Not Found Error

Resource not found.

- `error` (string, required) — Short error code.
- `status_code` (integer, required) — HTTP status code.
- `detail` (string, optional) — Human-readable error description.

### 422 Unprocessable Entity Error

Request validation failed.

- `error` (string, required) — Short error code.
- `status_code` (integer, required) — HTTP status code.
- `detail` (string, optional) — Human-readable error description.

## Examples

**Request**

```json
{
  "file": "<file: string>",
  "document_type": "id_front"
}
```

**Response**

```json
{
  "id": "doc_abc123",
  "session_id": "ses_abc123",
  "document_type": "id_front",
  "mime_type": "image/jpeg",
  "file_size_bytes": 245760,
  "created_at": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api.withverifa.com/api/v1/sessions/session_id/documents"

files = { "file": "open('string', 'rb')" }
payload = {
    "document_type": "id_front",
    "poa_document_type": ,
    "poa_document_date": ,
    "poa_issuing_country": 
}
headers = {"X-API-Key": "<apiKey>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.withverifa.com/api/v1/sessions/session_id/documents';
const form = new FormData();
form.append('file', 'string');
form.append('document_type', 'id_front');
form.append('poa_document_type', '');
form.append('poa_document_date', '');
form.append('poa_issuing_country', '');

const options = {method: 'POST', headers: {'X-API-Key': '<apiKey>'}};

options.body = form;

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://api.withverifa.com/api/v1/sessions/session_id/documents"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_type\"\r\n\r\nid_front\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_document_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_document_date\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_issuing_country\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")

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

	req.Header.Add("X-API-Key", "<apiKey>")

	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://api.withverifa.com/api/v1/sessions/session_id/documents")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<apiKey>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_type\"\r\n\r\nid_front\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_document_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_document_date\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_issuing_country\"\r\n\r\n\r\n-----011000010111000001101001--\r\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://api.withverifa.com/api/v1/sessions/session_id/documents")
  .header("X-API-Key", "<apiKey>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_type\"\r\n\r\nid_front\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_document_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_document_date\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_issuing_country\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.withverifa.com/api/v1/sessions/session_id/documents', [
  'multipart' => [
    [
        'name' => 'file',
        'filename' => 'string',
        'contents' => null
    ],
    [
        'name' => 'document_type',
        'contents' => 'id_front'
    ]
  ]
  'headers' => [
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.withverifa.com/api/v1/sessions/session_id/documents");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_type\"\r\n\r\nid_front\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_document_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_document_date\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"poa_issuing_country\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["X-API-Key": "<apiKey>"]
let parameters = [
  [
    "name": "file",
    "fileName": "string"
  ],
  [
    "name": "document_type",
    "value": "id_front"
  ],
  [
    "name": "poa_document_type",
    "value": 
  ],
  [
    "name": "poa_document_date",
    "value": 
  ],
  [
    "name": "poa_issuing_country",
    "value": 
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.withverifa.com/api/v1/sessions/session_id/documents")! 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()
```