# Cancel session

> `PUT https://api.kustom.co/ipp/v1/sessions/{session_id}/cancel`

Cancels a session. Triggers a session.cancelled callback. This is a terminal state — no further payment collection is possible.

## Parameters

- `session_id` (string, path, required)

## Responses

### 200

Session cancelled.

`application/json`

- `session_id` (string) — Unique session identifier.
- `status` (string) — Possible session statuses. Enum: `CREATED`, `ACTIVE`, `FINALIZED`, `CANCELLED`, `EXPIRED`, `FAILED`.
- `device_id` (string) — Device ID handling the session.
- `order_id` (string) — Order ID once created.
- `order_amount` (integer) — Total order amount in minor units.
- `purchase_currency` (string) — Currency code (ISO 4217).
- `purchase_started_at` (string) — Timestamp when the purchase started.
- `purchase_completed_at` (string) — Timestamp when the purchase was completed.
- `order_items[]` (array<object>) — List of line items in the order.
  - `type` (string, required) — Type of the line item. Enum: `physical`, `discount`, `shipping_fee`, `sales_tax`, `store_credit`, `gift_card`, `digital`, `surcharge`, `return_fee`, `package`.
  - `reference` (string) — External reference ID for the item (e.g., SKU).
  - `name` (string, required) — Name or description of the item.
  - `quantity` (integer, required) — Quantity of the item.
  - `unit_price` (integer, required) — Unit price in minor units (e.g., cents).
  - `total_amount` (integer, required) — Total amount for this line in minor units.
  - `tax_rate` (integer, required) — Tax rate in basis points (e.g., 2500 for 25%).
  - `total_discount_amount` (integer) — Total discount amount in minor units.
  - `total_tax_amount` (integer, required) — Total tax amount for this line in minor units.
- `merchant_reference1` (string) — First merchant reference.
- `merchant_reference2` (string) — Second merchant reference.
- `order_tax_amount` (integer) — Total tax amount in minor units.
- `merchant_data` (string) — Arbitrary merchant data.
- `created_at` (string) — Timestamp when the session was created.
- `expires_at` (string) — Timestamp when the session expires.
- `updated_at` (string) — Timestamp when the session was last updated.

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "CREATED",
  "device_id": "660e8400-e29b-41d4-a716-446655440001",
  "order_id": "770e8400-e29b-41d4-a716-446655440002",
  "order_amount": 2000,
  "purchase_currency": "SEK",
  "purchase_started_at": "2024-01-15T10:30:00Z",
  "purchase_completed_at": "2024-01-15T10:35:00Z",
  "order_items": [
    {
      "type": "physical",
      "reference": "SKU-12345",
      "name": "T-Shirt",
      "quantity": 2,
      "unit_price": 1000,
      "total_amount": 2000,
      "tax_rate": 2500,
      "total_discount_amount": 200,
      "total_tax_amount": 400
    }
  ],
  "merchant_reference1": "ORDER-12345",
  "merchant_reference2": "REF-67890",
  "order_tax_amount": 400,
  "merchant_data": {
    "customer_id": "C123"
  },
  "created_at": "2024-01-15T10:30:00Z",
  "expires_at": "2024-01-15T11:30:00Z",
  "updated_at": "2024-01-15T10:35:00Z"
}
```

### 401

Missing or invalid credentials.

`application/json`

### 404

Resource not found.

`application/json`

### 409

Session is already in a terminal state.

`application/json`
