---
title: "Create an upload URL"
description: "Get a signed, single-use URL to PUT a PDF, DOCX or PNG file to, up to your account's maximum document size, then use the upload in an envelope."
canonical: "https://signatureapi.com/docs/api/resources/uploads/create-url"
source: "https://signatureapi.com/docs/api/resources/uploads/create-url.md"
last_verified_api_version: "1.18.1"
---

# Create an upload URL

Get a signed, single-use URL to PUT a PDF, DOCX or PNG file to, up to your account's maximum document size, then use the upload in an envelope.

_Last verified against API version 1.18.1._

Upload a file from your server in two requests: describe the file to get a signed upload URL, then PUT the file's bytes to that URL. The result is a temporary [upload](https://signatureapi.com/docs/api/resources/uploads/object) that you use as a document's `url`.

Use this for files larger than 4.5 MB, up to your account's maximum document size (10 MB by default). For smaller files, [Create an upload](https://signatureapi.com/docs/api/resources/uploads/create) is simpler: one call, at most 4.5 MB per request. Any API key works, test or live: uploads belong to your account, not to a mode.

## How it works

- The API checks `media_type` and `size` against your account's limits when you request the upload URL, before you send any bytes.
- Requesting an upload URL creates nothing: the PUT creates the upload. An upload URL you don't use expires after five minutes.
- The PUT must carry the `size` and SHA-256 you declared. Bytes that don't match are refused.

## How to upload a file

1. **Request an upload URL**

   Read the file and compute its size in bytes and the SHA-256 of its bytes, as 64 lowercase hexadecimal characters. Send them with the file's `media_type` to `POST /v1/upload-urls`.

   The response has an `upload_url` to send the bytes to, the `reference` the upload will have, and `expires_in`, the seconds left to use `upload_url` (300).

2. **PUT the bytes**

   Send a `PUT` request to `upload_url` before it expires. The body is the raw file bytes, exactly the ones you described, not a multipart form. Set these headers:

   | Header                 | Value                                                  |
   | ---------------------- | ------------------------------------------------------ |
   | `Content-Type`         | The `media_type` you sent                              |
   | `Content-Length`       | The `size` you sent (most HTTP clients set it for you) |
   | `x-amz-content-sha256` | The `sha256` you sent                                  |

   The PUT needs no API key: the signed URL carries the authorization. A `2xx` response means the file is stored and the upload exists. If the PUT fails, request a new upload URL and try again.

3. **Use the upload in an envelope**

   Pass `reference` as the `url` of a [document](https://signatureapi.com/docs/api/resources/documents/object) when you [create an envelope](https://signatureapi.com/docs/api/resources/envelopes/create):

   ```json Document in the create envelope request
   {
     "url": "https://api.signatureapi.com/v1/uploads/upl_3JJz6t1o8A5YjX5VpnX27Z",
     "format": "pdf"
   }
   ```

```bash cURL
FILE=contract.pdf
SIZE=$(wc -c < "$FILE" | tr -d ' ')
SHA256=$(shasum -a 256 "$FILE" | cut -d ' ' -f 1)

RESPONSE=$(curl -s -X POST https://api.signatureapi.com/v1/upload-urls \
  -H "X-API-Key: $SIGNATUREAPI_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"media_type\": \"application/pdf\", \"size\": $SIZE, \"sha256\": \"$SHA256\"}")

curl -X PUT "$(echo "$RESPONSE" | jq -r .upload_url)" \
  -H "Content-Type: application/pdf" \
  -H "x-amz-content-sha256: $SHA256" \
  --data-binary "@$FILE"

echo "$RESPONSE" | jq -r .reference
```

```typescript TypeScript
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";

const bytes = await readFile("contract.pdf");
const sha256 = createHash("sha256").update(bytes).digest("hex");

const response = await fetch("https://api.signatureapi.com/v1/upload-urls", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.SIGNATUREAPI_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ media_type: "application/pdf", size: bytes.length, sha256 }),
});
const { upload_url, reference } = await response.json();

const put = await fetch(upload_url, {
  method: "PUT",
  headers: { "Content-Type": "application/pdf", "x-amz-content-sha256": sha256 },
  body: bytes,
});
if (!put.ok) throw new Error(`Upload failed: ${put.status} ${await put.text()}`);

console.log(reference); // the document url
```

```python Python
import hashlib
import os

import requests

with open("contract.pdf", "rb") as f:
    data = f.read()
sha256 = hashlib.sha256(data).hexdigest()

response = requests.post(
    "https://api.signatureapi.com/v1/upload-urls",
    headers={"X-API-Key": os.environ["SIGNATUREAPI_KEY"]},
    json={"media_type": "application/pdf", "size": len(data), "sha256": sha256},
)
upload = response.json()

put = requests.put(
    upload["upload_url"],
    headers={"Content-Type": "application/pdf", "x-amz-content-sha256": sha256},
    data=data,
)
put.raise_for_status()

print(upload["reference"])  # the document url
```

> **Warning:** Request upload URLs from your server, not from the browser. The request needs your API key, which must never be exposed to the client.

## Body Parameters

- `media_type` (`string`, required)

  The media type of the file.

  Values: `application/pdf`, `application/vnd.openxmlformats-officedocument.wordprocessingml.document`, `image/png`

  Example: `"application/pdf"`

- `size` (`integer`, required, minimum 1)

  The size of the file in bytes, up to the account's maximum [document](https://signatureapi.com/docs/api/resources/documents/object) size.

  Example: `102400`

- `sha256` (`string`, required, pattern ^[a-f0-9]{64}$)

  The SHA-256 hash of the file bytes, as 64 lowercase hexadecimal characters.

  Example: `"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"`

## Returns

Returns a `200 OK` status code and the upload URL on success, or an [error](https://signatureapi.com/docs/api/errors) otherwise. A `size` over your account's maximum document size returns a [validation-error](https://signatureapi.com/docs/v1/errors/validation-error).

- `upload_url` (`string`, format uri)

  The signed, single-use URL to PUT the file bytes to, with `content-type`, `content-length` and `x-amz-content-sha256` (the declared SHA-256), before it expires.

  Example: `"https://uploads.signatureapi.com/v1/uploads/upl_1sAAaVfabdt0esVjmSTmLA?token=example-signed-token"`

- `reference` (`string`, format uri)

  The upload's URL. It can be used as a [document](https://signatureapi.com/docs/api/resources/documents/object) `url` once the PUT lands.

  Example: `"https://api.signatureapi.com/v1/uploads/upl_3joO7lxE8HVhOZmkCHFCxK"`

- `expires_in` (`integer`, minimum 1)

  The number of seconds until `upload_url` expires.

  Example: `300`

Once the PUT succeeds, `reference` works anywhere a document URL is accepted, and [Retrieve an upload](https://signatureapi.com/docs/api/resources/uploads/get) returns it. The upload is temporary and is deleted 24 hours after the PUT. To keep it for reuse across envelopes, [store the upload](https://signatureapi.com/docs/api/resources/uploads/store) with the upload ID, the last path segment of `reference`.

## Errors on the PUT

The PUT is refused, and nothing is stored, when:

- `Content-Type`, `Content-Length` or `x-amz-content-sha256` is missing (`400`).
- `Content-Type` or `x-amz-content-sha256` differs from what you declared, or the body is larger than the declared `size` (`422`, [upload-claim-mismatch](https://signatureapi.com/docs/v1/errors/upload-claim-mismatch)).
- `upload_url` has expired (`422`, [expired-upload-token](https://signatureapi.com/docs/v1/errors/expired-upload-token)).
- `upload_url` was changed after the API returned it (`422`, [invalid-upload-token](https://signatureapi.com/docs/v1/errors/invalid-upload-token)).
- The upload id already exists with different claims (`409`, [upload-idempotency-conflict](https://signatureapi.com/docs/v1/errors/upload-idempotency-conflict)).

The body itself is also checked: bytes whose SHA-256 differs from `x-amz-content-sha256` are refused with a `400`.

Request a new upload URL for each new attempt.

### Example: PDF file

Declare the file's media type, size in bytes and SHA-256, then PUT the bytes to upload_url.

```http
POST /v1/upload-urls HTTP/1.1
Host: api.signatureapi.com
X-API-Key: YOUR_API_KEY
Content-Type: application/json

{
  "media_type": "application/pdf",
  "size": 102400,
  "sha256": "4f1c8a7e92b3d05a6e8c1f4b7d2a9053c6e8b1d4f7a20935c8e1b4d7a0f36c92"
}
```

Response 200 OK:

```json
{
  "upload_url": "https://uploads.signatureapi.com/v1/uploads/upl_3JJz6t1o8A5YjX5VpnX27Z?token=example-signed-token",
  "reference": "https://api.signatureapi.com/v1/uploads/upl_3JJz6t1o8A5YjX5VpnX27Z",
  "expires_in": 300
}
```

Response 422 Unprocessable Content:

```json
{
  "type": "https://signatureapi.com/docs/v1/errors/validation-error",
  "title": "Validation Error",
  "status": 422,
  "errors": [
    "size must be a maximum of 10 MB."
  ]
}
```

Errors that any request can return (authentication, rate limits, server errors) are on the [Errors](https://signatureapi.com/docs/api/errors) and [Authentication](https://signatureapi.com/docs/api/authentication) pages.
