> 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 full documentation content in one file, see https://docs.sarvam.ai/llms-full.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server. # Create Upload URL POST https://api.sarvam.ai/doc-ai/v1/job/upload Content-Type: application/json Creates a direct-upload handle for a file to be processed later. **Flow:** 1. Call this endpoint with the MIME type you will upload (e.g. `application/pdf`). 2. Upload the file using the returned `method`, `url` and `headers` before `expires_at`. 3. Pass the returned `upload_id` through the `upload_ids` field on a later digitise or extract job request. When `content_type` is set, the upload's `Content-Type` header must match it. Reference: https://docs.sarvam.ai/api-reference/doc-ai/job/upload ## Authentication - `api-subscription-key` header (required) — API Key authentication via header ## Request ### Body (application/json) This endpoint expects a DocAIPresignUploadRequest. - `content_type` (string, optional) — MIME type the client will PUT; when set, the upload's Content-Type header must match. ## Response ### 201 Created - `upload_id` (string, required) — Handle for the uploaded file. Pass it through `upload_ids` on a later digitise or extract job request. - `method` (string, required) — HTTP method to use for the upload (e.g. `PUT`). - `url` (string, required) — Presigned URL to upload the file to. - `expires_at` (string, required) — Timestamp after which the upload URL is no longer valid. - `headers` (map from string to string, optional) — Headers that must be sent with the upload request. ## Errors ### 400 Bad Request Error Invalid request - `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. ### 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 {} ``` **Response** ```json { "upload_id": "string", "method": "string", "url": "string", "expires_at": "string", "headers": {} } ``` **SDK Code** ```python import requests url = "https://api.sarvam.ai/doc-ai/v1/job/upload" payload = {} headers = { "api-subscription-key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.sarvam.ai/doc-ai/v1/job/upload'; const options = { method: 'POST', headers: { 'api-subscription-key': '', '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.sarvam.ai/doc-ai/v1/job/upload" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-subscription-key", "") 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.sarvam.ai/doc-ai/v1/job/upload") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["api-subscription-key"] = '' 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 response = Unirest.post("https://api.sarvam.ai/doc-ai/v1/job/upload") .header("api-subscription-key", "") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('POST', 'https://api.sarvam.ai/doc-ai/v1/job/upload', [ 'body' => '{}', 'headers' => [ 'Content-Type' => 'application/json', 'api-subscription-key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.sarvam.ai/doc-ai/v1/job/upload"); var request = new RestRequest(Method.POST); request.AddHeader("api-subscription-key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "api-subscription-key": "", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.sarvam.ai/doc-ai/v1/job/upload")! 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() ```