# removeInvoice mutation


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

Marks a document as deleted in the accounting system. Call it when the document is deleted
there.

MAX sets the status `REMOVED` and keeps the invoice as evidence.

#### Permissions

Requires the `invoice.sync` permission. Without `invoice.read`, the result's `internalNote` is
null.

#### Repeated calls

- A repeat writes nothing and returns `changed: false`.
- A call whose `sourceChangedAt` is older than the one MAX holds writes nothing and returns
  `reason` `STALE`.

#### Errors

- `NOT_FOUND` when no invoice has the `source` and `externalId`.

#### Good to know

- This call may change a linked sales order's invoice reference, which follows the order's
  governing invoice (`SalesOrder.governingInvoice`).

> An error whose path runs below this field does not mean the call failed: the invoice was
> marked as removed, so do not retry. See [`Mutation`](/chameleoon-max/mutations).

## Arguments

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

## Returns

[`InvoiceSyncResult!`](/chameleoon-max/type/invoice-sync-result)

## Example

**Mutation**

```graphql
mutation removeInvoice($input: RemoveInvoiceInput!) {
  removeInvoice(input: $input) {
    invoice {
      id
      direction
      kind
      status
      failureReason
      source
    }
    changed
    reason
    warnings {
      code
      message
      field
    }
  }
}
```

**Variables**

```json
{
  "input": {
    "source": "example",
    "externalId": "example"
  }
}
```

**Response**

```json
{
  "data": {
    "removeInvoice": {
      "invoice": {
        "id": "00000000-0000-4000-8000-000000000001",
        "direction": "ISSUED",
        "kind": "INVOICE",
        "status": "PENDING",
        "failureReason": "example",
        "source": "example"
      },
      "changed": true,
      "reason": "STALE",
      "warnings": [
        {
          "code": "example",
          "message": "example",
          "field": "example"
        }
      ]
    }
  }
}
```

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