> For the complete documentation index, see [llms.txt](https://docs.fonbnk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fonbnk.com/server-to-server/api-endpoints/cancel-order.md).

# Cancel order

## <mark style="color:$warning;">\[POST]</mark> /api/v2/order/cancel

Cancels an order that has not been paid yet. The order moves to `deposit_canceled`.

{% hint style="warning" %}
**Only an order still in `deposit_awaiting` can be cancelled.** Anything later returns `400` "Order is not in a state that allows cancellation" — once the deposit is validating or successful the money is in motion, and a failed payout is refunded instead. See [Order statuses](/server-to-server/order-statuses.md).

This endpoint also requires the end-user-creation capability on your account; without it every call returns `403`. See [Integration guide](/server-to-server/integration-guide.md).
{% endhint %}

You do not have to cancel abandoned orders. An unpaid order expires by itself at `order.expiresAt`. Cancelling is for when the user explicitly backs out, so the offer is released immediately.

{% hint style="info" %}
`deposit_canceled` is not the end of the story. If the user's payment turns up afterwards we still accept it, and the order moves on to `deposit_successful`. Do not treat a cancellation as proof that no money will arrive — keep handling webhooks for that order.
{% endhint %}

Request body type:

{% code overflow="wrap" expandable="true" %}

```typescript
type RequestBody = {
  orderId: string;
}
```

{% endcode %}

Request body example:

{% code overflow="wrap" expandable="true" %}

```json
{
  "orderId": "68728fa56ff494df5f39faf5"
}
```

{% endcode %}

### Response

Returns the updated order — the same `Order` object as [Get order](/server-to-server/api-endpoints/get-order.md), now with `status: "deposit_canceled"`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fonbnk.com/server-to-server/api-endpoints/cancel-order.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
