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

# Update document metadata

PATCH https://api.withverifa.com/api/v1/documents/{document_id}
Content-Type: application/json

Update mutable metadata on a document such as classification,
linked session or identity, and custom metadata.

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


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

## Authentication

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

## Request

### Path parameters

- `document_id` (string, required) — Document ID (`doc_*`).

### 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 (application/json)

This endpoint expects an object.

- `classification` (string, optional) — Updated document classification.
- `identity_id` (string, optional, nullable) — Identity ID to link or unlink.
- `session_id` (string, optional, nullable) — Session ID to link or unlink.
- `metadata` (map from string to any, optional) — Arbitrary key-value metadata.
- `status` (enum, optional) — Manually set document status.
  - Allowed values: `pending`, `processing`, `completed`, `failed`

## Response

### 200

Document updated.

- `id` (string, required) — Document ID (`doc_*`).
- `document_type` (enum, required)
  - Allowed values: `id_front`, `id_back`, `selfie`, `proof_of_address`, `other`
- `status` (enum, required)
  - Allowed values: `pending`, `processing`, `completed`, `failed`, `redacted`
- `created_at` (datetime, required)
- `org_id` (string, optional) — Organization ID.
- `session_id` (string, optional, nullable) — Associated session ID, if any.
- `identity_id` (string, optional, nullable) — Associated identity ID, if any.
- `classification` (string, optional, nullable) — Detected or assigned document classification (e.g. passport, drivers_license).
- `mime_type` (string, optional, nullable) — MIME type of the uploaded file.
- `file_size_bytes` (integer, optional, nullable) — File size in bytes.
- `original_filename` (string, optional, nullable) — Original filename at upload time.
- `page_count` (integer, optional, nullable) — Number of pages (for multi-page documents).
- `metadata` (map from string to any, optional) — Arbitrary key-value metadata.
- `upload_source` (string, optional, nullable) — How the document was uploaded (api, capture, dashboard).
- `download_url` (string, optional, nullable) — HMAC-signed download URL (when available).
- `preview_url` (string, optional, nullable) — Server-side JPEG preview URL for page 1. Works for both PDFs (rendered via PyMuPDF) and images. Same HMAC signature as download_url. Null for redacted documents.
- `extracted_fields` (map from string to any, optional, nullable) — Structured field extraction produced by Verifa's document extractor. Populated when the document's matched `document_type` has non-empty `extraction_hints`. Each key is one of the field names from the type's `extraction_hints`, and each value is either the extracted string or `null` if the field was not visible in the document. `null` until the verification pipeline has run.
- `extracted_fields_confidence` (map from string to double, optional, nullable) — Per-field token-presence confidence (0.0-1.0) for the corresponding entries in `extracted_fields`. Computed by checking whether each extracted value's tokens actually appear in the underlying OCR text. Values below ~0.5 are likely hallucinations and should be flagged for reviewer attention. `null` until extraction has run.
- `updated_at` (datetime, optional, nullable)

## 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
{}
```

**Response**

```json
{
  "id": "string",
  "document_type": "id_front",
  "status": "pending",
  "created_at": "2024-01-15T09:30:00Z",
  "org_id": "string",
  "session_id": "string",
  "identity_id": "string",
  "classification": "string",
  "mime_type": "string",
  "file_size_bytes": 1,
  "original_filename": "string",
  "page_count": 1,
  "metadata": {},
  "upload_source": "string",
  "download_url": "string",
  "preview_url": "string",
  "extracted_fields": {
    "insurer_name": "Acme Insurance",
    "policy_number": "POL-12345678",
    "vin": "1HGBH41JXMN109186",
    "expiry_date": "2027-01-15"
  },
  "extracted_fields_confidence": {
    "insurer_name": 0.997,
    "policy_number": 0.981,
    "vin": 0.95,
    "expiry_date": 0.997
  },
  "updated_at": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

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

payload = {}
headers = {
    "X-API-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.withverifa.com/api/v1/documents/document_id';
const options = {
  method: 'PATCH',
  headers: {'X-API-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{}'
};

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/documents/document_id"

	payload := strings.NewReader("{}")

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

	req.Header.Add("X-API-Key", "<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://api.withverifa.com/api/v1/documents/document_id")

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

request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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.patch("https://api.withverifa.com/api/v1/documents/document_id")
  .header("X-API-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.withverifa.com/api/v1/documents/document_id', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.withverifa.com/api/v1/documents/document_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.withverifa.com/api/v1/documents/document_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```