# reportError mutation


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

Reports that an external system failed to do something with a record in MAX. Call it once
for each occurrence of the error, for example each time your system fails to carry a receipt
over.

#### Grouping

- Occurrences with the same `subject`, `lineId`, `source` and `code` are grouped into one
  report and counted.
- A new report is created with the status `OPEN`.
- An occurrence on a `RESOLVED` report reopens it and marks it `regressed`.
- An occurrence on a `MUTED` report leaves it muted until its `mutedUntil` has passed, and
  reopens it after that.
- MAX builds the link to the Integrations platform from `integrationsTarget`. Send no URL.

#### Permissions

- Requires the `errorReport.write` permission and the read permission of the document's kind,
  for example `receipt.read` for a receipt. Without the read permission, the error is
  `FORBIDDEN_ROLE` naming it.
- The document must be in your API key's warehouse and legal-entity scope.

#### Repeated calls

`requestId` makes a retry after a lost response safe for 7 days.

- The same `requestId` with the same input returns `counted: false` and `created: false`,
  with the report as it is now. If its document has since been discarded, the error is
  `NOT_FOUND` with the field `subject`.
- The same `requestId` with different input is `CONFLICT` with the reason
  `REQUEST_ID_REUSED`.
- After 7 days MAX forgets the `requestId`, and the same call counts as a new occurrence.

#### Errors

| Code | Reason | When |
| --- | --- | --- |
| `NOT_FOUND` with the field `subject` | | The document does not exist or is outside your API key's scope. |
| `NOT_FOUND` with the field `lineId` | | The line is not on the document. |
| `VALIDATION` | | A field is malformed. The error names the field. |
| `CONFLICT` | `REQUEST_ID_REUSED` | The `requestId` was used before with different input. |

The reason is in `extensions.reason`.

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

## Arguments

- `input`: [`ReportErrorInput!`](/chameleoon-max/type/report-error-input) · required

## Returns

[`ReportErrorResult!`](/chameleoon-max/type/report-error-result)

## Example

**Mutation**

```graphql
mutation reportError($input: ReportErrorInput!) {
  reportError(input: $input) {
    errorReport {
      id
      lineId
      source
      code
      status
      mutedUntil
    }
    created
    counted
    reopened
  }
}
```

**Variables**

```json
{
  "input": {
    "requestId": "example",
    "subject": {
      "type": "STOCK_DOCUMENT",
      "id": "00000000-0000-4000-8000-000000000001"
    },
    "source": "example",
    "code": "example",
    "message": "example"
  }
}
```

**Response**

```json
{
  "data": {
    "reportError": {
      "errorReport": {
        "id": "00000000-0000-4000-8000-000000000001",
        "lineId": "00000000-0000-4000-8000-000000000001",
        "source": "example",
        "code": "example",
        "status": "OPEN",
        "mutedUntil": "2026-01-01T00:00:00Z"
      },
      "created": true,
      "counted": true,
      "reopened": true
    }
  }
}
```

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