# removeDocument mutation


`removeDocument` is a GraphQL mutation of the Chameleoon MAX API. Send it as `POST https://max-api.chameleoon.sk/api/v1/graphql` with your API key, see [Chameleoon MAX](/chameleoon-max).

Removes a document. Call it when a document no longer belongs to its order or invoice.

The document is gone from every read and its download. MAX keeps its versions.

#### Permissions

Requires the permission to write the document's target, with that target in your API key's
scope:

- `order.write` for a sales order's document.
- `invoice.sync` for an invoice's document.

Without it, the document is `NOT_FOUND` on `documentId`.

#### Repeated calls

A replay of the call that removed the document returns `applied: false` with the same
`documentId`.

#### Errors

- `CONFLICT` with `extensions.reason` `DOCUMENT_REMOVED` when the document was removed already,
  by another call.
- `CONFLICT` with `extensions.reason` `ORDER_STATUS` when the order is not `CONFIRMED`,
  `COMPLETED` or `CANCELLED`.
- `CONFLICT` with `extensions.reason` `INVOICE_REMOVED` when the invoice was removed in its
  accounting system.

## Arguments

- `input`: [`RemoveDocumentInput!`](/chameleoon-max/type/remove-document-input) · required

## Returns

[`RemoveDocumentResult!`](/chameleoon-max/type/remove-document-result)

## Example

**Mutation**

```graphql
mutation removeDocument($input: RemoveDocumentInput!) {
  removeDocument(input: $input) {
    applied
    documentId
  }
}
```

**Variables**

```json
{
  "input": {
    "requestId": "example",
    "documentId": "00000000-0000-4000-8000-000000000001"
  }
}
```

**Response**

```json
{
  "data": {
    "removeDocument": {
      "applied": true,
      "documentId": "00000000-0000-4000-8000-000000000001"
    }
  }
}
```

Values are illustrative: replace IDs and codes with your own before you send the call.
