# Mutations

**Endpoint:** `POST /cashramp/bot/graphql`\
**Auth:** `Authorization: Bearer {api_key}` (agent API key)

***

### Accept Withdrawal

Agent accepts an incoming withdrawal order.

```graphql
mutation {
  acceptWithdrawal(p2pPayment: "P2P_PAYMENT_GLOBAL_ID")
}
```

<table><thead><tr><th width="160">Argument</th><th width="130">Type</th><th width="94">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>p2pPayment</code></td><td><code>ID!</code></td><td><strong>Yes</strong></td><td>The global ID of the P2P payment to accept.</td></tr></tbody></table>

Returns `Boolean` indicating if the operation succeeded.

***

### Cancel Withdrawal

Agent cancels a withdrawal order.

```graphql
mutation {
  cancelWithdrawal(p2pPayment: "P2P_PAYMENT_GLOBAL_ID")
}
```

<table><thead><tr><th width="160">Argument</th><th width="130">Type</th><th width="94">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>p2pPayment</code></td><td>ID<code>!</code></td><td><strong>Yes</strong></td><td>The global ID of the P2P payment to cancel.</td></tr></tbody></table>

Returns `Boolean` indicating if the operation succeeded.

***

### Mark Deposit as Received

Agent confirms a deposit has been received.

```graphql
mutation {
  markDepositAsReceived(p2pPayment: "P2P_PAYMENT_GLOBAL_ID")
}
```

<table><thead><tr><th width="160">Argument</th><th width="130">Type</th><th width="94">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>p2pPayment</code></td><td><code>ID!</code></td><td><strong>Yes</strong></td><td>The global ID of the P2P payment to confirm.</td></tr></tbody></table>

Returns `Boolean` indicating if the operation succeeded.

***

### Mark Withdrawal as Paid

Agent marks a withdrawal as paid out.

```graphql
mutation {
  markWithdrawalAsPaid(
    p2pPayment: "P2P_PAYMENT_GLOBAL_ID"
    paymentMethod: "PAYMENT_METHOD_GLOBAL_ID"
    receipt: "receipt_url_or_reference"
  )
}
```

<table><thead><tr><th width="160">Argument</th><th width="130">Type</th><th width="94">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>p2pPayment</code></td><td><code>ID!</code></td><td><strong>Yes</strong></td><td>The global ID of the P2P payment.</td></tr><tr><td><code>paymentMethod</code></td><td>ID<code>!</code></td><td><strong>Yes</strong></td><td>The global ID of the payment method used.</td></tr><tr><td><code>receipt</code></td><td><code>String</code></td><td>No</td><td>Optional receipt URL or reference for the payout.</td></tr></tbody></table>

Returns `Boolean` indicating if the operation succeeded.

***

### Update Rates

Update the agent's deposit and/or withdrawal rates and margins. At least one argument must be provided.

```graphql
mutation {
  updateRates(
    depositRate: 1550
    withdrawalRate: 1530
  )
}
```

<table><thead><tr><th width="180">Argument</th><th width="130">Type</th><th width="94">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>depositRate</code></td><td><code>Decimal</code></td><td>No</td><td>The agent's local-currency rate for deposits (fiat in, stablecoin out).</td></tr><tr><td><code>withdrawalRate</code></td><td><code>Decimal</code></td><td>No</td><td>The agent's local-currency rate for withdrawals (stablecoin in, fiat out).</td></tr><tr><td><code>depositMargin</code></td><td><code>Decimal</code></td><td>No</td><td>Margin above the market buy rate for deposits. Ignored if <code>depositRate</code> is provided.</td></tr><tr><td><code>withdrawalMargin</code></td><td><code>Decimal</code></td><td>No</td><td>Margin below the market sell rate for withdrawals. Ignored if <code>withdrawalRate</code> is provided.</td></tr></tbody></table>

Returns `Boolean` indicating if the operation succeeded. Fails with `REQUIRED_ATTRIBUTES_MISSING` if no arguments are provided.

#### Rate / Margin Derivation

The deposit and withdrawal sides are handled independently. For each side, you can provide a rate, a margin, or neither — but not both (any margin sent alongside a rate on the same side is ignored).

**Deposit side (against the market buy rate):**

* If `depositRate` is provided → `depositMargin = max(0, depositRate − marketBuyRate)`. Any `depositMargin` sent with the request is ignored.
* If only `depositMargin` is provided → `depositRate = marketBuyRate + depositMargin`.

**Withdrawal side (against the market sell rate):**

* If `withdrawalRate` is provided → `withdrawalMargin = max(0, marketSellRate − withdrawalRate)`. Any `withdrawalMargin` sent with the request is ignored.
* If only `withdrawalMargin` is provided → `withdrawalRate = marketSellRate − withdrawalMargin`.

Derived margins are floored at zero — a deposit rate below the market buy rate (or a withdrawal rate above the market sell rate) results in a margin of `0` rather than a negative value.

{% hint style="info" %}
The market buy and sell rates are Cashramp's reference rates for your agent's local currency at the moment the mutation is processed.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cashramp.co/cashramp/cashramp-bot-api/mutations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
