> 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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: sarvam
  version: 1.0.0
paths:
  /doc-ai/v1/job/upload:
    post:
      operationId: create_upload_url
      summary: Create Document AI Upload URL
      description: >-
        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.
      tags:
        - docAi
      parameters:
        - name: api-subscription-key
          in: header
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocAIPresignUploadResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocAIErrorModel'
        '402':
          description: Billing or entitlement error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocAIErrorModel'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocAIErrorModel'
        '429':
          description: Rate or admission limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocAIErrorModel'
        '503':
          description: Billing unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocAIErrorModel'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocAIPresignUploadRequest'
servers:
  - url: https://api.sarvam.ai
    description: Production
components:
  schemas:
    DocAIPresignUploadRequest:
      type: object
      properties:
        content_type:
          type: string
          description: >-
            MIME type the client will PUT; when set, the upload's Content-Type
            header must match.
      title: DocAIPresignUploadRequest
    DocAIPresignUploadResponse:
      type: object
      properties:
        upload_id:
          type: string
          description: >-
            Handle for the uploaded file. Pass it through `upload_ids` on a
            later digitise or extract job request.
        method:
          type: string
          description: HTTP method to use for the upload (e.g. `PUT`).
        url:
          type: string
          description: Presigned URL to upload the file to.
        headers:
          type: object
          additionalProperties:
            type: string
          description: Headers that must be sent with the upload request.
        expires_at:
          type: string
          description: Timestamp after which the upload URL is no longer valid.
      required:
        - upload_id
        - method
        - url
        - expires_at
      title: DocAIPresignUploadResponse
    DocAIErrorDetail:
      type: object
      properties:
        location:
          type: string
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'.
        message:
          type: string
          description: Error message text.
        value:
          description: The value at the given location.
      title: DocAIErrorDetail
    DocAIErrorModel:
      type: object
      properties:
        type:
          type: string
          format: uri
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
        title:
          type: string
          description: A short, human-readable summary of the problem type.
        status:
          type: integer
          description: HTTP status code.
        detail:
          type: string
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
        instance:
          type: string
          format: uri
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
        errors:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/DocAIErrorDetail'
          description: Optional list of individual error details.
      title: DocAIErrorModel
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-subscription-key

```

## Examples



**Request**

```json
{}
```

**Response**

```json
{
  "upload_id": "string",
  "method": "string",
  "url": "string",
  "expires_at": "string",
  "headers": {}
}
```

**SDK Code**

```typescript
import { SarvamAIClient } from "sarvamai";

async function main() {
    const client = new SarvamAIClient({
        apiSubscriptionKey: "YOUR_API_KEY_HERE",
    });
    await client.docAi.createUploadUrl({});
}
main();

```

```python
from sarvamai import SarvamAI

client = SarvamAI(
    api_subscription_key="YOUR_API_KEY_HERE",
)

client.doc_ai.create_upload_url()

```

```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", "<apiSubscriptionKey>")
	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"] = '<apiSubscriptionKey>'
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.post("https://api.sarvam.ai/doc-ai/v1/job/upload")
  .header("api-subscription-key", "<apiSubscriptionKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.sarvam.ai/doc-ai/v1/job/upload', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
    'api-subscription-key' => '<apiSubscriptionKey>',
  ],
]);

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", "<apiSubscriptionKey>");
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": "<apiSubscriptionKey>",
  "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()
```