> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rails.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Margin

#### Request

```json theme={null}
{
    "message": "updateMargin",
    "content": {
        "clientRequestId": "79b89ec3-b89b-4e9e-aff3-9a6ff0184009",
        "margin": "201"
    }
}
```

| Field                     | Type   | Required | Description                                                         |
| ------------------------- | ------ | -------- | ------------------------------------------------------------------- |
| `message`                 | string | Yes      | `updateMargin`                                                      |
| `content.clientRequestId` | string | No       | Client-generated UUID for correlation                               |
| `content.market`          | string | No       | Market name, only required when connecting with `market=ALL`        |
| `content.margin`          | string | Yes      | Absolute target value for `isolatedPositionMargin` after the update |

#### Response — Acknowledgment

```json theme={null}
{
    "resultType": "updateMargin",
    "market": "BTC-USDT",
    "data": {
        "statusCode": 202,
        "body": "margin update in progress, pending approval",
        "clientRequestId": "79b89ec3-b89b-4e9e-aff3-9a6ff0184009",
        "apiQuotaUsed": 1
    }
}
```

| Field                  | Type   | Required | Description                           |
| ---------------------- | ------ | -------- | ------------------------------------- |
| `resultType`           | string | Yes      | `updateMargin`                        |
| `market`               | string | Yes      | Market name                           |
| `data.statusCode`      | number | Yes      | `202`                                 |
| `data.body`            | string | Yes      | Status message                        |
| `data.clientRequestId` | string | No       | Client-generated UUID for correlation |
| `data.apiQuotaUsed`    | number | Yes      | API quota consumed                    |

#### Response — Confirmation

```json theme={null}
{
    "resultType": "updateMargin",
    "market": "BTC-USDT",
    "data": {
        "statusCode": 200,
        "body": "margin updated successfully",
        "clientRequestId": "79b89ec3-b89b-4e9e-aff3-9a6ff0184009"
    }
}
```

If the requested `margin` value matches the current `isolatedPositionMargin`, the operation is a successful no-op. In this case, **no 202 acknowledgment is sent first** — the 200 is returned directly:

```json theme={null}
{
    "resultType": "updateMargin",
    "market": "BTC-USDT",
    "data": {
        "statusCode": 200,
        "body": "margin is the same as the current margin, no update needed",
        "clientRequestId": "79b89ec3-b89b-4e9e-aff3-9a6ff0184009"
    }
}
```

| Field                  | Type   | Required | Description                           |
| ---------------------- | ------ | -------- | ------------------------------------- |
| `resultType`           | string | Yes      | `updateMargin`                        |
| `market`               | string | Yes      | Market name                           |
| `data.statusCode`      | number | Yes      | `200`                                 |
| `data.body`            | string | Yes      | Status message                        |
| `data.clientRequestId` | string | No       | Client-generated UUID for correlation |

#### Response — Error

```json theme={null}
{
    "resultType": "updateMargin",
    "market": "BTC-USDT",
    "data": {
        "statusCode": 400,
        "body": "margin decrease below minimum required margin",
        "clientRequestId": "acd02c47-3e8a-41af-aecb-9b60177554fd",
        "error": {
            "code": "0006",
            "slug": "BAD_REQUEST"
        }
    }
}
```

```json theme={null}
{
    "resultType": "updateMargin",
    "market": "BTC-USDT",
    "data": {
        "statusCode": 429,
        "body": "api call rate limit exceeded",
        "error": {
            "slug": "TOO_MANY_REQUESTS",
            "code": "0003"
        },
        "apiQuotaUsed": 10001,
        "retryAfterSec": 300,
        "clientRequestId": "79b89ec3-b89b-4e9e-aff3-9a6ff0184009"
    }
}
```

```json theme={null}
{
    "resultType": "updateMargin",
    "market": "BTC-USDT",
    "data": {
        "statusCode": 500,
        "body": "Internal Server Error",
        "error": {
            "slug": "UPDATE_MARGIN_ERROR",
            "code": "8000"
        },
        "apiQuotaUsed": 1,
        "clientRequestId": "79b89ec3-b89b-4e9e-aff3-9a6ff0184009"
    }
}
```

| Field                  | Type   | Required | Description                           |
| ---------------------- | ------ | -------- | ------------------------------------- |
| `resultType`           | string | Yes      | `updateMargin`                        |
| `market`               | string | Yes      | Market name                           |
| `data.statusCode`      | number | Yes      | Error status (`400`, `429`, `500`)    |
| `data.body`            | string | Yes      | Error description                     |
| `data.error.slug`      | string | Yes      | Error slug                            |
| `data.error.code`      | string | Yes      | Error code                            |
| `data.apiQuotaUsed`    | number | Yes      | API quota consumed                    |
| `data.retryAfterSec`   | number | No       | Present when throttled                |
| `data.clientRequestId` | string | No       | Client-generated UUID for correlation |
