# Add document to envelope

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

Add a document to an open envelope for some of its signers. The document is checked as on creation: a `metadata_ready` document of the workspace with no assignment, signed on its virtual page or, with `collect`, on the fields placed in `entries`, with its own `expires_at` and `copy_receiver_ids`. An envelope holds up to 20 documents. It charges only its digital-certificate signatures, the envelope having paid for its document and its signers' notifications and identity checks when it was sent, and goes last in the envelope's order; a signer whose identity check the envelope approved is verified on it too. Each chosen signer is sent the envelope's invitation again, through the methods and with the link of their first invitation, now listing the new document, even once the document that invitation was sent from is taken out; the other signers hear nothing. The signers are the envelope's own: no one new joins once it was sent. Needs the Envelopes feature on the workspace's plan, as creating does. 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. |
| `envelopeId` | path | string | yes | The envelope ID. |

## Request Body (required)

Fields (`application/json`):

- `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 document costs more on its own. A value that is not a number of credits, zero or more, answers `400`; numeric text counts, as a form-encoded body sends it.
- `id` (string, required) — A `metadata_ready` document of the workspace with no assignment.
- `method` (string) — As on an assignment: `virtual` (the default), signed on its virtual page, or `collect`, signed on the fields placed in `entries`.
- `entries` (array) — Required for `collect`, as on an assignment: the fields placed on each page of the document. Its signers are the ones on its fields, exactly its `signer_ids`.
- `signer_ids` (array, required) — The signers of this document, each listed once: on creation, signers listed in `signers`; when added, signers of the envelope's documents.
- `expires_at` (object) — This document's expiration, read as on an assignment, at least one hour in the future. Text is read as a date: ISO 8601 is the format to send (a UTC offset in the value is honored, a value without one is read as UTC, and a date alone means 23:59 UTC that day), and text that is a number is Unix time. A number is Unix time in seconds, its fraction dropped. Null, 0, an empty text or leaving it out means no expiration; a value that can't be read as a date answers `400`.
- `copy_receiver_ids` (array) — Signer IDs that only receive a copy of this document, as on an assignment.

Example:

```json
{
    "max_total_credits": 1.5,
    "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 envelope with the document added

```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`: `id` (missing, or a document that can't take the assignment: not found, not `metadata_ready`, or already assigned); `method` (other than `virtual` or `collect`); `entries` (missing for `collect`, or not a list of pages with fields naming their `signer_id`); `signer_ids` (missing, not a list of ids, listed twice, not a signer of the envelope's documents, for `collect` not exactly the signers on its fields, or a digital-certificate signer on a `collect` document or with another signer); `expires_at` (not text, a number or null); a null `field` when the envelope already has 20 documents, or would hold more than 2,000 fields (a virtual document's being one per signer) or more than 100 copy receivers with this one. A page or field the assignment doesn't find on a `collect` document, a balance too low, 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": "Each of a document's signers must be listed once in the envelope's signers.",
    "errors": [
        {
            "field": "signer_ids",
            "code": "Invalid",
            "message": "Each of a document's signers must be listed once in the envelope's signers."
        }
    ]
}
```

### 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 — Every document of the envelope is closed (`EnvelopeClosed`), or the document costs more than `max_total_credits` on its own (`CreditCeilingExceeded`).

```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."
        }
    ]
}
```
