# Take document out of envelope

`DELETE /v1/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}`

Take an open document out of the envelope: it is cancelled as cancelling the envelope cancels it, its owner, signers and copy receivers told in a notice naming the envelope, and it is no longer listed; the other documents carry on. Out of the envelope, `GET /v1/documents/{documentId}?expand=envelope_id` reads null for it; a signer whose invitation link was sent from it keeps reaching the envelope's other documents with that link, so it can't be deleted on its own (`409` with code `EnvelopeOpen`) until every document of the envelope is closed. A document that is not in the envelope, or was taken out already, answers `404`.

**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. |
| `documentId` | path | string | yes | Document ID. |

## Responses

### 200 — The envelope without the document

```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": ""
}
```

### 403 — 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 document is closed, signed by every signer (its certification queued) or being certificated, and can no longer be cancelled (`DocumentClosed`).

```json
{
    "status": 400,
    "code": "PlanRestricted",
    "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."
        }
    ]
}
```
