# unlinkInvoice mutation


`unlinkInvoice` 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 the invoice's link to a MAX document your API key can see. Call it when the invoice
does not belong to that document.

- Requires the `invoice.read` and `invoice.write` permissions.
- Removing a link that is not there changes nothing.
- `NOT_FOUND` when the invoice or the document does not exist or your API key cannot see it.
- 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 link was removed,
> so do not retry. See [`Mutation`](/chameleoon-max/mutations).

## Arguments

- `ref`: [`InvoiceRefInput!`](/chameleoon-max/type/invoice-ref-input) · required
- `input`: [`InvoiceLinkInput!`](/chameleoon-max/type/invoice-link-input) · required

## Returns

[`Invoice!`](/chameleoon-max/type/invoice)

## Example

**Mutation**

```graphql
mutation unlinkInvoice($ref: InvoiceRefInput!, $input: InvoiceLinkInput!) {
  unlinkInvoice(ref: $ref, input: $input) {
    id
    direction
    kind
    status
    failureReason
    source
    sourceDocumentType
    sourceChangedAt
    syncedAt
    cancelled
    number
    variableSymbol
    constantSymbol
    specificSymbol
    supplierNumber
    orderNumber
    issueDate
    taxPointDate
    dueDate
    receivedDate
    vatClaimDate
    legalEntityId
    legalEntityMatch
    partnerId
    partnerMatch
    partnerEditable
    seller {
      name
      street
      city
      postalCode
      countryCode
      registrationId
    }
    buyer {
      name
      street
      city
      postalCode
      countryCode
      registrationId
    }
    delivery {
      name
      street
      city
      postalCode
      countryCode
      registrationId
    }
    paymentMethod
    paymentMethodName
    bankAccountNumber
    bankCode
    bankName
    iban
    swift
    currencyCode
    exchangeRate
    exchangeRateAmount
    homeCurrencyCode
    textBeforeItems
    textAfterItems
    printedNote
    vatNote
    reverseCharge
    oss
    totalNet
    totalVat
    totalGross
    rounding
    advancesDeducted
    amountDue
    totalNetHome
    totalVatHome
    totalGrossHome
    paymentStatus
    paidAmount
    remainingAmount
    paidAt
    correctsInvoiceId
    correctedNumber
    correctedIssueDate
    correctedTaxPointDate
    correctionReason
    internalNote
    lines(first: 10) {
      totalCount
    }
    vatSummary(first: 10) {
      totalCount
    }
    settlements(first: 10) {
      totalCount
    }
    links(first: 10) {
      totalCount
    }
    documents(first: 10) {
      totalCount
    }
    createdAt
    updatedAt
  }
}
```

**Variables**

```json
{
  "ref": {
    "id": "00000000-0000-4000-8000-000000000001"
  },
  "input": {
    "type": "SALES_ORDER",
    "targetId": "00000000-0000-4000-8000-000000000001"
  }
}
```

**Response**

```json
{
  "data": {
    "unlinkInvoice": {
      "id": "00000000-0000-4000-8000-000000000001",
      "direction": "ISSUED",
      "kind": "INVOICE",
      "status": "PENDING",
      "failureReason": "example",
      "source": "example",
      "sourceDocumentType": "example",
      "sourceChangedAt": "2026-01-01T00:00:00Z",
      "syncedAt": "2026-01-01T00:00:00Z",
      "cancelled": true,
      "number": "example",
      "variableSymbol": "example",
      "constantSymbol": "example",
      "specificSymbol": "example",
      "supplierNumber": "example",
      "orderNumber": "example",
      "issueDate": "2026-01-01T00:00:00Z",
      "taxPointDate": "2026-01-01T00:00:00Z",
      "dueDate": "2026-01-01T00:00:00Z",
      "receivedDate": "2026-01-01T00:00:00Z",
      "vatClaimDate": "2026-01-01T00:00:00Z",
      "legalEntityId": "00000000-0000-4000-8000-000000000001",
      "legalEntityMatch": "EXPLICIT",
      "partnerId": "00000000-0000-4000-8000-000000000001",
      "partnerMatch": "EXPLICIT",
      "partnerEditable": true,
      "seller": {
        "name": "example",
        "street": "example",
        "city": "example",
        "postalCode": "example",
        "countryCode": "example",
        "registrationId": "example"
      },
      "buyer": {
        "name": "example",
        "street": "example",
        "city": "example",
        "postalCode": "example",
        "countryCode": "example",
        "registrationId": "example"
      },
      "delivery": {
        "name": "example",
        "street": "example",
        "city": "example",
        "postalCode": "example",
        "countryCode": "example",
        "registrationId": "example"
      },
      "paymentMethod": "BANK_TRANSFER",
      "paymentMethodName": "example",
      "bankAccountNumber": "example",
      "bankCode": "example",
      "bankName": "example",
      "iban": "example",
      "swift": "example",
      "currencyCode": "example",
      "exchangeRate": "10.00",
      "exchangeRateAmount": 1,
      "homeCurrencyCode": "example",
      "textBeforeItems": "example",
      "textAfterItems": "example",
      "printedNote": "example",
      "vatNote": "example",
      "reverseCharge": true,
      "oss": true,
      "totalNet": "10.00",
      "totalVat": "10.00",
      "totalGross": "10.00",
      "rounding": "10.00",
      "advancesDeducted": "10.00",
      "amountDue": "10.00",
      "totalNetHome": "10.00",
      "totalVatHome": "10.00",
      "totalGrossHome": "10.00",
      "paymentStatus": "UNPAID",
      "paidAmount": "10.00",
      "remainingAmount": "10.00",
      "paidAt": "2026-01-01T00:00:00Z",
      "correctsInvoiceId": "00000000-0000-4000-8000-000000000001",
      "correctedNumber": "example",
      "correctedIssueDate": "2026-01-01T00:00:00Z",
      "correctedTaxPointDate": "2026-01-01T00:00:00Z",
      "correctionReason": "example",
      "internalNote": "example",
      "lines": {
        "totalCount": 1
      },
      "vatSummary": {
        "totalCount": 1
      },
      "settlements": {
        "totalCount": 1
      },
      "links": {
        "totalCount": 1
      },
      "documents": {
        "totalCount": 1
      },
      "createdAt": "2026-01-01T00:00:00Z",
      "updatedAt": "2026-01-01T00:00:00Z"
    }
  }
}
```

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