# Create a file

> POST /v1/files starts a file upload by declaring the name, size and SHA-256, and returns the file ID with an upload URL: parameters, tested examples and errors.

Source: https://esigncomply.com/docs/api/supplements/create-a-file

Last updated November 26, 2026

In the Esign Comply API, `POST /v1/files` starts a file upload by declaring the name, size and SHA-256, and returns the file ID with an upload URL. Call it from your server before you `PUT` the bytes and reference the file in a supplement.

`POST /v1/files` · API version `2026-11-21`

## Authentication

Send a secret key in the `Authorization` header: `Bearer $ESIGNCOMPLY_API_KEY`. The key needs `full_access` or `recording_access` permission. Test keys and live keys both work, and each reads and writes the objects of its own environment. Call it from your server: a secret key never goes to a browser. Keys and permissions are described under [Authentication](https://esigncomply.com/docs/api.md#authentication).

## Request example

### cURL

```bash
curl https://esigncomply.com/v1/files \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "renewal-notice.eml",
    "size": 237,
    "content_type": "message/rfc822",
    "sha256": "f96e3ce7bb168d8bfb92cacceece9d9f778e27e04118e2fb90d9436e704100cb"
  }'
```

This request ran against the API on November 26, 2026, and the response below is what came back. IDs are example values, and long values are shortened with `...`.

## What it does

Text and JSON travel in the supplement call. Files go from your server straight to storage in three steps:

1. `POST /v1/files` with the name, size and SHA-256 of the file. The response carries `id` and an `upload_url` on a path used only for that file. The URL is valid for 2 hours.
2. `PUT` the bytes to `upload_url`. An upload never overwrites an existing object.
3. Reference the file ID in `files` on `POST /v1/supplements`. Esign Comply reads the stored object, recomputes the hash and copies the file to write-once storage. A file is sealed when a supplement references it. A file not referenced within 7 days is deleted.

## Parameters

### Body fields

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | string | Yes | File name, up to 255 characters. Executable extensions are refused. |
| `size` | integer | Yes | Size in bytes. Must equal the bytes you upload. |
| `content_type` | string | No | Media type, stored as sent. |
| `sha256` | string | Yes | SHA-256 of the bytes in lower-case hexadecimal, with or without the `sha256:` prefix. |

For a file larger than 6 MB the response also carries `resumable_url` and `resumable_chunk_bytes` (6 MB chunks). `esc.files.upload()` in the [Node SDK](https://esigncomply.com/docs/sdk/node.md) performs all three steps, including chunked uploads.

Headers: `Idempotency-Key` (optional, up to 255 characters) and `Esign-Comply-Version` (optional, a dated API version). See [API conventions](https://esigncomply.com/docs/api.md).

## Response

`201 Created` with a File object.

```json
{
  "object": "file",
  "id": "fil_dZ8g",
  "livemode": false,
  "name": "renewal-notice.eml",
  "content_type": "message/rfc822",
  "size": 237,
  "sha256": "sha256:f96e3ce7...",
  "status": "pending",
  "supplement": null,
  "created_at": "2026-11-26T00:16:53.772Z",
  "upload_url": "https://storage.example/storage/v1/object/upload/sign/customer_material/dom_4Kx9/test/fil_dZ8g?token=eyJhbG...",
  "upload_method": "PUT",
  "upload_expires_in": 7200
}
```

### Response fields

| Field | Type | Description |
|---|---|---|
| `object` | string |  |
| `id` | string |  |
| `livemode` | boolean |  |
| `name` | string |  |
| `content_type` | string |  |
| `size` | integer |  |
| `sha256` | string |  |
| `status` | string |  |
| `reject_reason` | string |  |
| `supplement` | string |  |
| `created_at` | datetime |  |
| `upload_url` | string |  |
| `upload_method` | string |  |
| `upload_expires_in` | integer |  |
| `resumable_url` | string |  |

## Errors

| Code | HTTP | When |
|---|---|---|
| [`invalid_request`](https://esigncomply.com/docs/api/errors.md#invalid_request) | 400 | The request is malformed: the body is not valid JSON, a known field has the wrong type, a required field is missing, a value is out of range, or a limit was passed (for example `metadata` over 50 keys, `context.extra` over 16 KB, event `data` over 256 KB, an `Idempotency-Key` over 255 characters, an unknown `Esign-Comply-Version`). |
| [`file_type_refused`](https://esigncomply.com/docs/api/errors.md#file_type_refused) | 422 | The name has an executable extension. |
| [`file_too_large`](https://esigncomply.com/docs/api/errors.md#file_too_large) | 422 | `size` exceeds the plan's file limit. |
| [`storage_limit_reached`](https://esigncomply.com/docs/api/errors.md#storage_limit_reached) | 402 | The storage allowance is used up. Text and JSON supplements are still accepted, so a report is never lost for lack of file storage. |

Like every call made with a secret key, it can also return [`missing_api_key`](https://esigncomply.com/docs/api/errors.md#missing_api_key), [`invalid_api_key`](https://esigncomply.com/docs/api/errors.md#invalid_api_key), [`domain_not_verified`](https://esigncomply.com/docs/api/errors.md#domain_not_verified), [`insufficient_permission`](https://esigncomply.com/docs/api/errors.md#insufficient_permission), [`idempotency_conflict`](https://esigncomply.com/docs/api/errors.md#idempotency_conflict), [`region_mismatch`](https://esigncomply.com/docs/api/errors.md#region_mismatch), [`rate_limit_exceeded`](https://esigncomply.com/docs/api/errors.md#rate_limit_exceeded) and [`internal_error`](https://esigncomply.com/docs/api/errors.md#internal_error).

Every error has the same body: `error.type`, `error.code`, `error.message`, `error.doc_url` and `error.request_id`. See [Errors](https://esigncomply.com/docs/api/errors.md).

## Questions about POST /v1/files

### Which credential does POST /v1/files need?

A secret key with full_access or recording_access permission. Send it as a Bearer token in the Authorization header, from your server only. A session client token is refused with insufficient_permission.

### Does POST /v1/files work with a test key?

Yes. It works with test keys and live keys. A test key reads and writes test objects only, and a live key works once the domain is verified.

### Does POST /v1/files count as a signature event?

No. A signature event is counted when a live record is written, by completing a session or by submitting a deferred acceptance. This call writes no record.

### Is POST /v1/files idempotent?

Yes, with an Idempotency-Key header of up to 255 characters. A repeat with the same key and the same bytes in the body returns the original response, with the header Idempotent-Replayed: true. The same key with a different body answers 409 idempotency_conflict.

### What is the rate limit for POST /v1/files?

The limit is counted for each key and depends on the plan: 2 requests per second on Free, 10 on Starter, 50 on Unlimited and 100 on Enterprise. Past the limit the API answers 429 rate_limit_exceeded with a Retry-After header.

### Does the Node SDK have a method for POST /v1/files?

No. Call it over HTTP, or with esc.request() in the esigncomply package, which sends the key and returns { data, error }.

## Related

- [Supplements and files](https://esigncomply.com/docs/api/supplements.md): the overview of the resource and all of its operations.
- [Retrieve a file](https://esigncomply.com/docs/api/supplements/retrieve-a-file.md): `GET /v1/files/{id}`
- [Create a supplement](https://esigncomply.com/docs/api/supplements/create-a-supplement.md): `POST /v1/supplements`
- [List supplements](https://esigncomply.com/docs/api/supplements/list-supplements.md): `GET /v1/supplements`
- [Retrieve a supplement](https://esigncomply.com/docs/api/supplements/retrieve-a-supplement.md): `GET /v1/supplements/{id}`
- [Supplements](https://esigncomply.com/docs/guides/supplements.md)
- [Errors](https://esigncomply.com/docs/api/errors.md): every error code, with what to do.
- [API conventions](https://esigncomply.com/docs/api.md): authentication, idempotency, rate limits and versioning.
