> This page is for API Reference.

> Sarvam Voice Agents (Samvaad) is a voice AI agent platform for Indian languages: build, test and deploy AI calling agents on your own phone numbers, from ₹3 a minute. Start here: https://docs.sarvam.ai/voice-agents/why-voice-agents.
> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt. For a section index, append `/llms.txt` to any section URL (for example https://docs.sarvam.ai/voice-agents/llms.txt).
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Parse Document

POST https://api.sarvam.ai/doc-ai/v1/job/parse
Content-Type: multipart/form-data

Creates and starts a parse job from files or pre-uploaded handles. Parse converts documents into structured HTML, Markdown, or JSON while preserving layout.

**Input:** Exactly one of `file` and `upload_ids` must be provided. Use `POST /doc-ai/v1/job/upload` to obtain upload IDs.

**Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until a terminal status (`completed`, `partially_completed`, `failed`, `rejected`), then fetch output via the results or download-url endpoints.

Parse JSON results include blocks with text, tag and bounding box.

Reference: https://docs.sarvam.ai/api-reference/doc-ai/job/parse

## Authentication

- `api-subscription-key` header (required) — API Key authentication via header

## Request

### Body (multipart/form-data)

This endpoint expects a multipart form with multiple files.

- `file` (files, optional) — Document file(s) to parse. Repeatable multipart part. Exactly one of `file` and `upload_ids` must be provided.
- `upload_ids` (string, optional) — Comma-separated upload IDs returned by `POST /doc-ai/v1/job/upload`. Exactly one of `file` and `upload_ids` must be provided.
- `language` (string, optional) — Language of the document in BCP-47 format (e.g. `hi-IN`, `en-IN`). Defaults to Indic: when omitted, the document is processed as an Indic-language document. To process an English document, set `language` to `en-IN`. Sarvam Vision supports 22 Indian languages plus English; see the [Sarvam Vision model page](/api/getting-started/models/sarvam-vision) for the full list.
- `content_type` (enum, optional) — Nature of the document content.
- `model` (string, optional) — Model to use for digitisation.

## Response

### 201

Created

- `job_id` (string, required) — The unique identifier of the job.
- `status` (string, required) — Current status of the job.
- `run_id` (string, required) — The unique identifier of the job run.

## Errors

### 400 Bad Request Error

Invalid request or schema

- `type` (string, optional, default: about:blank) — A URI reference to human-readable documentation for the error.
- `title` (string, optional) — A short, human-readable summary of the problem type.
- `status` (integer, optional) — HTTP status code.
- `detail` (string, optional) — A human-readable explanation specific to this occurrence of the problem.
- `instance` (string, optional) — A URI reference that identifies the specific occurrence of the problem.
- `errors` (list of DocAIErrorDetail, optional, nullable) — Optional list of individual error details.

### 402 Payment Required Error

Billing or entitlement error

- `type` (string, optional, default: about:blank) — A URI reference to human-readable documentation for the error.
- `title` (string, optional) — A short, human-readable summary of the problem type.
- `status` (integer, optional) — HTTP status code.
- `detail` (string, optional) — A human-readable explanation specific to this occurrence of the problem.
- `instance` (string, optional) — A URI reference that identifies the specific occurrence of the problem.
- `errors` (list of DocAIErrorDetail, optional, nullable) — Optional list of individual error details.

### 403 Forbidden Error

Forbidden

- `type` (string, optional, default: about:blank) — A URI reference to human-readable documentation for the error.
- `title` (string, optional) — A short, human-readable summary of the problem type.
- `status` (integer, optional) — HTTP status code.
- `detail` (string, optional) — A human-readable explanation specific to this occurrence of the problem.
- `instance` (string, optional) — A URI reference that identifies the specific occurrence of the problem.
- `errors` (list of DocAIErrorDetail, optional, nullable) — Optional list of individual error details.

### 413 Content Too Large Error

File too large

- `type` (string, optional, default: about:blank) — A URI reference to human-readable documentation for the error.
- `title` (string, optional) — A short, human-readable summary of the problem type.
- `status` (integer, optional) — HTTP status code.
- `detail` (string, optional) — A human-readable explanation specific to this occurrence of the problem.
- `instance` (string, optional) — A URI reference that identifies the specific occurrence of the problem.
- `errors` (list of DocAIErrorDetail, optional, nullable) — Optional list of individual error details.

### 429 Too Many Requests Error

Rate or admission limit exceeded

- `type` (string, optional, default: about:blank) — A URI reference to human-readable documentation for the error.
- `title` (string, optional) — A short, human-readable summary of the problem type.
- `status` (integer, optional) — HTTP status code.
- `detail` (string, optional) — A human-readable explanation specific to this occurrence of the problem.
- `instance` (string, optional) — A URI reference that identifies the specific occurrence of the problem.
- `errors` (list of DocAIErrorDetail, optional, nullable) — Optional list of individual error details.

### 503 Service Unavailable Error

Billing unavailable

- `type` (string, optional, default: about:blank) — A URI reference to human-readable documentation for the error.
- `title` (string, optional) — A short, human-readable summary of the problem type.
- `status` (integer, optional) — HTTP status code.
- `detail` (string, optional) — A human-readable explanation specific to this occurrence of the problem.
- `instance` (string, optional) — A URI reference that identifies the specific occurrence of the problem.
- `errors` (list of DocAIErrorDetail, optional, nullable) — Optional list of individual error details.

## Types

### DocAIErrorDetail

- `location` (string, optional) — Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id'.
- `message` (string, optional) — Error message text.
- `value` (any, optional) — The value at the given location.

## Examples

**Request**

```json
{
  "file": []
}
```

**Response**

```json
{
  "job_id": "string",
  "status": "string",
  "run_id": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.sarvam.ai/doc-ai/v1/job/parse"

payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"upload_ids\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
    "api-subscription-key": "<apiSubscriptionKey>",
    "Content-Type": "multipart/form-data; boundary=---011000010111000001101001"
}

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

print(response.json())
```

```javascript
const url = 'https://api.sarvam.ai/doc-ai/v1/job/parse';
const form = new FormData();
form.append('content_type', '');
form.append('language', '');
form.append('model', '');
form.append('upload_ids', '');

const options = {method: 'POST', headers: {'api-subscription-key': '<apiSubscriptionKey>'}};

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.sarvam.ai/doc-ai/v1/job/parse"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"upload_ids\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")

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

	req.Header.Add("api-subscription-key", "<apiSubscriptionKey>")

	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.sarvam.ai/doc-ai/v1/job/parse")

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

request = Net::HTTP::Post.new(url)
request["api-subscription-key"] = '<apiSubscriptionKey>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"upload_ids\"\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.sarvam.ai/doc-ai/v1/job/parse")
  .header("api-subscription-key", "<apiSubscriptionKey>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"upload_ids\"\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.sarvam.ai/doc-ai/v1/job/parse', [
  'headers' => [
    'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001',
    'api-subscription-key' => '<apiSubscriptionKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.sarvam.ai/doc-ai/v1/job/parse");
var request = new RestRequest(Method.POST);
request.AddHeader("api-subscription-key", "<apiSubscriptionKey>");
request.AddHeader("Content-Type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content_type\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"upload_ids\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["api-subscription-key": "<apiSubscriptionKey>"]
let parameters = [
  [
    "name": "content_type",
    "value": 
  ],
  [
    "name": "language",
    "value": 
  ],
  [
    "name": "model",
    "value": 
  ],
  [
    "name": "upload_ids",
    "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.sarvam.ai/doc-ai/v1/job/parse")! 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()
```