# agentChannelCheckoutCancel

mutation · in the family [Selling](/reference/selling/)

## What it does

Cancel an agent checkout before it completes.

THE AGENT CHECKOUT — cancel: the draft's own cancel transition (terminal); a completed/canceled checkout refuses CONFLICT/REF_STATE. Answers the view with status canceled.

## What happens

The draft order is cancelled (terminal); a completed or already-cancelled checkout refuses.

## Who may call it

Capability area: **Selling** — Ringing sales, serving customers and issuing invoices.

- Owner
- Manager
- Associate Manager
- Sales Associate
- Cashier
- An API key whose scope allows `api:agentChannelCheckoutCancel`

## Arguments

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `agentChannelId` | [ID](/types/#scalars) `ID!` | yes | No further notes. |
| `orderId` | [ID](/types/#scalars) `ID!` | yes | No further notes. |
| `reason` | [String](/types/#scalars) | no | No further notes. |
| `linkedConsumerId` | [ID](/types/#scalars) | no | No further notes. |

## Returns

[AgentCheckout](/types/AgentCheckout/) `AgentCheckout!` — THE AGENT CHECKOUT VIEW: the draft Order as a UCP checkout session at NOW — status ∈ incomplete | requires_escalation | ready_for_complete | complete_in_progress | completed | canceled (the status rule) over its lines, buyer, consent, fulfillment offer, totals, discounts and messages.

## Example request

```graphql
mutation ExampleAgentChannelCheckoutCancel($agentChannelId: ID!, $orderId: ID!, $reason: String) {
  agentChannelCheckoutCancel(agentChannelId: $agentChannelId, orderId: $orderId, reason: $reason) {
    orderId
    revision
    revisionNum
    agentChannelId
    organizationId
    platformProfileUrl
    consumerId
    currency
    orderStatus
    status
    validUntil
  }
}
```

Variables:

```json
{
  "agentChannelId": "01900000-0000-7000-8000-d23fae740000",
  "orderId": "01900000-0000-7000-8000-f6d8263a0000",
  "reason": "Correcting a miscount."
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

## Example response

```json
{
  "data": {
    "agentChannelCheckoutCancel": {
      "orderId": "01900000-0000-7000-8000-f6d8263a0000",
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "revisionNum": 1,
      "agentChannelId": "01900000-0000-7000-8000-d23fae740000",
      "organizationId": "01900000-0000-7000-8000-44b781470000",
      "platformProfileUrl": "https://example.com/hook",
      "consumerId": "01900000-0000-7000-8000-6e8c92ec0000",
      "currency": "USD",
      "orderStatus": "<order status>",
      "status": "<status>",
      "validUntil": "<valid until>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

## Errors this call can answer

- `VALIDATION/INVALID` — Something in the request is not valid. ([VALIDATION](/errors/VALIDATION/))
- `AUTHN/REQUIRED` — Sign in to do this. ([AUTHN](/errors/AUTHN/))
- `AUTHZ/FORBIDDEN` — Your role does not allow this action. ([AUTHZ](/errors/AUTHZ/))
- `RATE_LIMIT/THROTTLED` — Too many requests in a short time. ([RATE_LIMIT](/errors/RATE_LIMIT/))
- `NOT_FOUND/*` — That record could not be found. ([NOT_FOUND](/errors/NOT_FOUND/))
- `CONFLICT/*` — The record’s state, or a change made in the meantime, does not allow this; the codes are on the CONFLICT page. ([CONFLICT](/errors/CONFLICT/))
- `VALIDATION/VERSION_REQUIRED` — The request did not say which app version it came from. ([VALIDATION](/errors/VALIDATION/))
