# Create a document

> POST /v1/documents creates a document, the named agreement that versions are published under, and returns the document object: parameters, examples and errors.

Source: https://esigncomply.com/docs/api/documents/create-a-document

Last updated November 26, 2026

In the Esign Comply API, `POST /v1/documents` creates a document, the named agreement that versions are published under, and returns the document object. Call it from your server once for each agreement, such as your terms of service, before you publish its first version.

`POST /v1/documents` · 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/documents \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: create-terms-of-service" \
  -d '{
    "name": "Terms of Service",
    "type": "terms"
  }'
```

### Node SDK

```ts
import { EsignComply } from "esigncomply";

const esc = new EsignComply(process.env.ESIGNCOMPLY_API_KEY);

const { data, error } = await esc.documents.create(
  { name: "Terms of Service", type: "terms" },
  { idempotencyKey: "create-terms-of-service" },
);
```

The two samples send the same `Idempotency-Key` with bodies that differ in whitespace. Run one of them, or change the key: the same key with different bytes in the body answers `409` [`idempotency_conflict`](https://esigncomply.com/docs/api/errors.md#idempotency_conflict).

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 `...`.

## Parameters

### Body fields

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | string, 1 to 200 characters | Yes | The title signers see. The notice text in your assent region must contain it ([CR-02](https://esigncomply.com/docs/conformance.md#cr-02)). |
| `type` | string, 1 to 40 characters | Yes | A value from the table above. |
| `metadata` | object | No | Your own key-value pairs. |

`warnings` lists request fields the API did not recognize, as `unknown_field:<path>`. They are ignored, not rejected.

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 Document object.

```json
{
  "object": "document",
  "id": "doc_8Hq2",
  "livemode": false,
  "name": "Terms of Service",
  "type": "terms",
  "metadata": {},
  "archived": false,
  "created_at": "2026-11-26T00:15:40.359Z",
  "warnings": []
}
```

### Response fields

| Field | Type | Description |
|---|---|---|
| `object` | string |  |
| `id` | string |  |
| `livemode` | boolean |  |
| `name` | string |  |
| `type` | string |  |
| `metadata` | object |  |
| `archived` | boolean |  |
| `created_at` | datetime |  |
| `current_version` | string |  |
| `warnings` | array of string |  |

## Errors

| Code | HTTP | When |
|---|---|---|
| [`invalid_request`](https://esigncomply.com/docs/api/errors.md#invalid_request) | 400 | When `name` or `type` is missing or the wrong type. |
| [`insufficient_permission`](https://esigncomply.com/docs/api/errors.md#insufficient_permission) | 403 | For a `read_only` key. |

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), [`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/documents

### Which credential does POST /v1/documents 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/documents 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/documents 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/documents 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/documents?

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/documents?

Yes: esc.documents.create() in the esigncomply package. It resolves to { data, error } and does not throw.

## Related

- [Documents](https://esigncomply.com/docs/api/documents.md): the overview of the resource and all of its operations.
- [List documents](https://esigncomply.com/docs/api/documents/list-documents.md): `GET /v1/documents`
- [Retrieve a document](https://esigncomply.com/docs/api/documents/retrieve-a-document.md): `GET /v1/documents/{id}`
- [Update a document](https://esigncomply.com/docs/api/documents/update-a-document.md): `PATCH /v1/documents/{id}`
- [Publish a document version](https://esigncomply.com/docs/api/documents/publish-a-document-version.md): `POST /v1/documents/{id}/versions`
- [Re-acceptance of a new version](https://esigncomply.com/docs/guides/reacceptance.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.
