# Create envelope

`POST /v1/accounts/{accountId}/envelopes`

Send several documents to the same signers at once. Each document gets its own assignment and keeps its own status, certificate and downloads; one invitation goes to each signer, through the methods sent for them, for all the documents they are on, from the first of them. A send that fails is recorded on that signer's request (`notification_history`) and doesn't undo the envelope: `200` means the envelope was created, not that every invitation was delivered. The envelope is charged as one document, whatever its documents, each signer's notifications and identity check once for the whole envelope, and each digital-certificate signature on every document it is made on. Every document must be uploaded and processed (`metadata_ready`) with no assignment, and every listed signer must be on at least one document. Each document is signed on its virtual page or, with `collect`, on the fields placed on its pages, as on an assignment; a digital-certificate signer signs only virtual documents, alone on each. Needs the Envelopes feature on the workspace's plan (`403` with code `PlanRestricted` otherwise). A refused request creates and charges nothing; `errors` names every field at fault.

**Authentication:** Bearer access token (`Authorization: Bearer ...`) or API key (`X-Api-Key` header).

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `accountId` | path | string | yes | Workspace account ID. |
| `Idempotency-Key` | header | string | no | Any text, case-sensitive and new for each envelope you mean to create (a UUID, say). Retrying with the same key after a lost response answers the envelope the first request created, and creates and charges nothing, whatever the body says. A key belongs to its workspace and doesn't expire. `409` with code `IdempotencyKeyInUse` if the first request is still running: try again. An empty value counts as no key, as on template documents. |

## Request Body (required)

Fields (`application/json`):

- `name` (string, required) — What the invitation calls what is being signed, in place of a document's name. `<` is refused (`400`).
- `message` (Array) — Optional message sent to every signer; their invitation adds the names of the documents they are on.
- `max_total_credits` (number) — Optional ceiling on what this request may spend, as on an assignment: refused with `409` and code `CreditCeilingExceeded`, nothing created or charged, when the envelope's total credits are above it. A value that is not a number of credits, zero or more, answers `400`; numeric text counts, as a form-encoded body sends it. The estimate ignores it.
- `signers` (array, required) — Every signer of the envelope, once, by id: up to 20. They all sign at once: an envelope takes no `step`.
- `documents` (array, required) — The documents, in the order the envelope lists them: up to 20.

Example:

```json
{
    "name": "Contrato de prestação de serviços",
    "message": "Segue o contrato e seus anexos.",
    "max_total_credits": 1.5,
    "signers": [
        {
            "id": "fa8c140cb49b79f940aab95fddd",
            "verification_method": "Email",
            "notification_methods": [
                "Email"
            ],
            "embedded": true
        }
    ],
    "documents": [
        {
            "id": "615601fab04c0a3147bb1246",
            "method": "virtual",
            "entries": [
                {
                    "page_id": "string",
                    "fields": [
                        {
                            "signer_id": "string",
                            "field_id": "string",
                            "display_settings": {
                                "left": 69,
                                "top": 282,
                                "width": 421,
                                "height": 45.86,
                                "fontFamily": "Arial",
                                "fontSize": 22,
                                "backgroundColor": "#D5EBFF"
                            }
                        }
                    ]
                }
            ],
            "signer_ids": [
                "fa8c140cb49b79f940aab95fddd"
            ],
            "expires_at": "2026-12-31T23:59:59Z",
            "copy_receiver_ids": [
                "cr8c140cb49b79f940aab95fddd"
            ]
        }
    ]
}
```

## Responses

### 200 — The created envelope

```json
{
    "data": {
        "resource": "envelope",
        "id": "1a2f3c4d5e6f708192a3b4c5d6e",
        "name": "Contrato de prestação de serviços",
        "message": "Segue o contrato e seus anexos.",
        "documents": [
            {
                "id": "615601fab04c0a3147bb1246",
                "position": 1,
                "name": "contrato.pdf",
                "status": "pending_signature",
                "artifacts": {
                    "original": "https://api.assinafy.com.br/v1/documents/615601fab04c0a3147bb1246/download/original",
                    "thumbnail": "https://api.assinafy.com.br/v1/documents/615601fab04c0a3147bb1246/thumbnail"
                },
                "signers": [
                    {
                        "id": "fa8c140cb49b79f940aab95fddd",
                        "full_name": "Ana Souza",
                        "email": "ana@example.com",
                        "whatsapp_phone_number": "+5548999990001",
                        "completed": false,
                        "signed_at": "2026-11-06T14:30:00Z"
                    }
                ]
            }
        ],
        "counts": {
            "certificated": 1,
            "pending_signature": 2
        },
        "signing_urls": [
            {
                "signer_id": "string",
                "url": "https://api.assinafy.com.br/v1/sign/doc1?email=joe@example.com",
                "embedded": false
            }
        ],
        "created_at": "2026-11-04T12:00:00Z"
    },
    "status": 200,
    "message": ""
}
```

### 400 — Refused as sent; nothing was created or charged. Each field at fault is an entry of `errors` (a list refused as a whole is not read item by item), an item of a list named by its index (`documents[1].signer_ids`): `name`; `message` (not text); `signers` and `documents` (missing, empty, not a list, or more than 20 signers or 20 documents; `documents` also when its documents hold more than 2,000 fields between them, a virtual document's being one per signer, or more than 100 copy receivers); `signers[i].id` (missing, listed twice, not a signer of the workspace, or on no document); `signers[i].verification_method` (not a code); `signers[i].notification_methods` (not a list of codes); `signers[i].step` (sent at all); `documents[i].id` (missing, listed twice, or a document that can't take the assignment: not found, not `metadata_ready`, or already assigned); `documents[i].method` (other than `virtual` or `collect`); `documents[i].entries` (missing for `collect`, or not a list of pages with fields naming their `signer_id`); `documents[i].expires_at` (not text, a number or null); `documents[i].signer_ids` (missing, not a list of ids, a signer not listed once in `signers`, for `collect` not exactly the signers on its fields, or a digital-certificate signer on a `collect` document or with another signer). A page or field the assignment doesn't find on a `collect` document, a method code the platform doesn't know, a verification and notification that don't pair, a signer without the e-mail or WhatsApp number their method needs, an `embedded` other than `true`, `false`, `1` or `0` (`null` reads as left out, as on an assignment) or set for a signer verified other than by Bypass, Email or WhatsApp, a balance too low for the envelope, an `expires_at` or `copy_receiver_ids` the assignment refuses, and a document another request assigned or put back into processing meanwhile answer `400` with `message` only, as on an assignment.

```json
{
    "status": 400,
    "message": "This signer is on no document.",
    "errors": [
        {
            "field": "signers[1].id",
            "code": "Invalid",
            "message": "This signer is on no document."
        }
    ]
}
```

### 403 — The workspace's plan lacks the Envelopes feature, or a signer's method or embedded signing the plan lacks (`PlanRestricted`); or an OAuth app's token lacks `documents:write` (`InsufficientScope`). Also a member deactivated in the workspace, a workspace scheduled for deletion, or an OAuth token of another workspace.

```json
{
    "status": 400,
    "code": "PlanRestricted",
    "message": "Bad request.",
    "data": null,
    "errors": [
        {
            "field": "full_name",
            "code": "Required",
            "message": "Full Name cannot be blank."
        }
    ]
}
```

### 404 — The requested resource does not exist.

```json
{
    "status": 400,
    "message": "Bad request.",
    "data": null,
    "code": "PlanRestricted",
    "errors": [
        {
            "field": "full_name",
            "code": "Required",
            "message": "Full Name cannot be blank."
        }
    ]
}
```

### 409 — The envelope costs more than `max_total_credits` (`CreditCeilingExceeded`), or another request with this `Idempotency-Key` is still running (`IdempotencyKeyInUse`).

```json
{
    "status": 400,
    "code": "PlanRestricted",
    "total_credits": 1.5,
    "max_total_credits": 1,
    "message": "Bad request.",
    "data": null,
    "errors": [
        {
            "field": "full_name",
            "code": "Required",
            "message": "Full Name cannot be blank."
        }
    ]
}
```

### 401 — Missing or invalid credentials.

```json
{
    "status": 400,
    "message": "Bad request.",
    "data": null,
    "code": "PlanRestricted",
    "errors": [
        {
            "field": "full_name",
            "code": "Required",
            "message": "Full Name cannot be blank."
        }
    ]
}
```

### 500 — Unexpected server error.

```json
{
    "status": 400,
    "message": "Bad request.",
    "data": null,
    "code": "PlanRestricted",
    "errors": [
        {
            "field": "full_name",
            "code": "Required",
            "message": "Full Name cannot be blank."
        }
    ]
}
```
