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

# POST /v1/market/buy — 购买并交付到 Steam 交易链接

> 一次最多购买 100 件商品，并直接交付到您提供的任意 Steam 交易链接，使用已结算余额支付。专为批发与自动化交付而设计。

此端点允许您将商品购买并直接交付到您提供的**任意** Steam 交易链接——而不仅限于绑定到您账户的交易链接。交易链接由 `partner` 和 `token` 字段组成。购买**只能**使用您的**已结算**（不可撤销）余额，因此适用于批发量与自动化交付工作流。

为每笔提取保存一个 `custom_id`。成功响应最多缓存 24 小时，重放时会返回 `Idempotent-Replayed: true` 响应头。如果响应丢失，请用已保存的标识符[查询订单](https://api.csboard.com/zh-Hans/api-reference/get-orders-info.md)。订单创建前，查询可能返回空结果。请保持待处理状态，直到核实原订单。

> [!WARNING]
>
> 此端点处于熔断开关保护之下，要求账户启用了交易且不可撤销状态干净。熔断开关关闭时，将返回 `403 external_buy_disabled`。

**需要身份验证。** 请将密钥作为 `Authorization: Bearer csb_pub_...` 发送。

**需要交易能力。** 该密钥必须启用购买功能，且账户必须处于不可撤销状态干净。

## 请求体

**item\_ids** `string[]` *required*

1–100 个唯一的挂单 id。

**partner** `string` *required*

Steam 交易链接中的 `partner` 值（1–32 个字符）。与 `token` 一起构成商品交付的目标交易链接。

**token** `string` *required*

Steam 交易链接中的 `token` 值（1–32 个字符）。与 `partner` 一起构成目标交易链接。

**max\_price\_usd** `number`

美元价格上限。如果实时总价超过该值，订单将以 `price_moved` 被拒绝且不扣款。强烈建议使用。

**custom\_id** `string`

提取标识符（1–128 个字符）。缓存过期后，使用相同标识符可能会发起新的购买。

**skip\_unavailable** `boolean` (default: false)

如果为 `true`，跳过已不再可用的商品而不会让整个请求失败。

**appId** `integer` (default: 730)

`item_ids` 所属的游戏：`730` CS2（默认）、`570` Dota 2、`252490` Rust。请使用读取这些 id 时（[`GET /v1/listings`](https://api.csboard.com/zh-Hans/api-reference/get-listings)）所用的同一个 `appId`。Dota 2 和 Rust 每个订单最多 10 个 id，并进入队列，因此每个皮肤最初返回 `pending`。

## 响应字段

**data** `object` *required*

**data object**

**purchase\_id** `string` *required*

**steam\_id** `string` *required*

由所提供的 `partner` + `token` 解析得到的 Steam ID。

**created\_at** `datetime` *required*

**custom\_id** `string | null`

**skins** `object[]` *required*

逐件结果。

**skin object**

**name** `string | null`

**price** `number | null`

**status** `string`

**return\_reason** `string | null`

**steam\_trade\_offer\_id** `string | null`

## 示例请求

```bash theme={null}
curl -X POST https://csboard.com/v1/market/buy \
  -H "Authorization: Bearer csb_pub_..." \
  -H "Content-Type: application/json" \
  -d '{
    "item_ids": ["itm_8841201", "itm_8841340"],
    "partner": "447383001",
    "token": "Ab3xZ9Qp",
    "max_price_usd": 30.00,
    "custom_id": "batch-2026-06-29-01",
    "skip_unavailable": false
  }'
```

## 示例响应

```json theme={null}
{
  "data": {
    "purchase_id": "pur_01J9Z3K8Q2",
    "steam_id": "76561198000000000",
    "created_at": "2026-06-29T17:12:04Z",
    "custom_id": "batch-2026-06-29-01",
    "skins": [
      {
        "name": "AK-47 | Redline (Minimal Wear)",
        "price": 14.37,
        "status": "delivering",
        "return_reason": null,
        "steam_trade_offer_id": "5512345678"
      }
    ]
  }
}
```

## 错误代码

| HTTP 状态码 | 代码 | 含义 |
| - | - | - |
| 400 | `invalid_request` | 请求体格式错误（例如 `item_ids` 为空或超过 100）。 |
| 400 | `unsupported_item` | 一个或多个商品无法通过此端点交付（例如 `ss_live_*` id）。 |
| 400 | `invalid_trade_url` | `partner` + `token` 无法组成有效的 Steam 交易链接。 |
| 400 | `unsupported_game` | 您的密钥无法使用该 `appId`。包含 `supported_app_ids`。 |
| 400 | `too_many_items` | 一个订单中 Dota 2 或 Rust 的 id 超过 10 个。包含 `max_items`。 |
| 401 | `invalid_api_key` | API 密钥缺失或无效。 |
| 402 | `insufficient_settled_balance` | 已结算余额低于订单总额。返回中包含 `required_usd` 和 `settled_usd`。 |
| 402 | `insufficient_balance` | 余额低于订单总额。 |
| 403 | `external_buy_disabled` | 熔断开关已关闭；此端点当前已禁用。 |
| 403 | `trading_not_enabled` | 该密钥未启用购买功能。 |
| 403 | `account_restricted` | 此端点要求账户处于不可撤销状态干净。 |
| 409 | `item_unavailable` | 一个或多个商品已不再可用。返回中包含 `unavailable_ids[]`，CS2 购买还可能包含 `unknown_ids[]`。参见下方 [不可用的商品](#unavailable-items)。 |
| 409 | `price_moved` | 实时总价超过上限。返回中包含 `quoted_max_usd`、`current_total_usd` 以及 `items[]`。 |
| 409 | `idempotency_in_progress` | 具有该 `custom_id` 的请求仍在处理中。 |
| 409 | `price_updating` | 价格正在刷新；请稍后重试。 |
| 429 | `rate_limit_exceeded` | 超过每分钟 250 个购买订单（`bucket: "buy_orders"`），或超过密钥的交易限制（`bucket: "trading"`）。请按照 `Retry-After` 响应头中的秒数退避。 |
| 500 | `order_failed` | 请先确认原订单是否已创建，再决定是否重新购买。 |
| 504 | `upstream_timeout` | 市场响应超时。请保持待处理状态，用已保存的标识符查询订单。[Node.js 对账示例（英文）](https://csboard.com/cs2-skins-api/for/case-opening/#reconciliation)。 |

> [!NOTE]
>
> 资金完全来自您的**已结算**余额。在大批量下单前，请检查 [`GET /v1/balance`](https://api.csboard.com/api-reference/get-balance) 上的 `settled_balance_usd`，并始终发送 `max_price_usd` 作为超额扣款保护。

## 不可用的商品

挂单可能在您读取之后、购买之前离开目录。`409 item_unavailable` 的响应体会在 `unavailable_ids` 中列出所有缺失的 id。购买 CS2（不传 `appId` 或传 `730`）时，它还可能带有 `unknown_ids`：缺失的 id 中我们完全没有记录的那些。要么它不是 CSBoard 的挂单 id，要么该挂单离开目录已超过一小时。最常见的混淆是把 Steam 资产 id（asset id）当成挂单 id——CSBoard 的挂单 id 从不全由数字组成，请发送 `/v1/listings` 或流中某一行的 `id`。

```json theme={null}
{
  "code": "item_unavailable",
  "detail": "One or more items are no longer available. 1 of the ids are not known here (`unknown_ids`): not a listing id, or a listing gone for over an hour. Steam asset ids are not listing ids: send the `id` of a row from /v1/listings or the stream.",
  "unavailable_ids": ["31846262931"],
  "unknown_ids": ["31846262931"]
}
```

如需在尝试购买前剔除已售出的挂单，请订阅 [`GET /v1/listings/stream`](https://api.csboard.com/zh-Hans/api-reference/get-listings-stream) 的 `gone` 事件。


## OpenAPI

````yaml POST /market/buy
openapi: 3.1.0
info:
  title: CSBoard API
  version: 1.0.0
  description: >-
    Market data over the CSBoard marketplace — live listings, floats, stickers,
    minAsk prices, FX rates — plus opt-in buying straight from your balance.
    Free to read, key-gated, built for automation.
  contact:
    name: CSBoard
    url: https://csboard.com/docs
servers:
  - url: https://csboard.com/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Status
    description: Liveness and freshness probes.
  - name: Market data
    description: Read the live catalog, prices, and FX rates.
  - name: Trading
    description: Buy listings from your CSBoard balance. Opt-in, key-gated.
  - name: Instant Sell
    description: >-
      Sell CS2, Dota 2 and Rust items from any Steam inventory to the CSBoard
      network and get paid to your balance. Invite-only.
  - name: P2P
    description: >-
      List your own CS2 skins on the CSBoard P2P market. Free — any valid key,
      no balance requirement.
  - name: Account
    description: Your balance, settled funds, and trading status.
  - name: Webhooks
    description: Register an endpoint and receive signed order updates instead of polling.
paths:
  /market/buy:
    post:
      tags:
        - Trading
      summary: Buy and deliver to a Steam trade URL
      description: >-
        Buy up to 100 items and deliver them straight to any Steam trade URL you
        supply (built from `partner` + `token`), paid from your **settled**
        (reversal-safe) balance. Built for wholesale and automated delivery.
        Idempotent via the `custom_id` body field — while the successful
        response is cached (up to 24 hours), the same `custom_id` returns that
        response and the response carries the `Idempotent-Replayed: true`
        header. This endpoint ships behind a kill-switch and requires a
        trading-enabled, reversal-clean account. Pass `appId` (`570` Dota 2,
        `252490` Rust) to buy those games; leave it out for CS2. Dota 2 and Rust
        orders are queued, so every skin answers `pending` first.
      operationId: marketBuy
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExternalBuyRequest'
            example:
              item_ids:
                - itm_8841201
                - itm_8841340
              partner: '447383001'
              token: Ab3xZ9Qp
              max_price_usd: 30
              custom_id: batch-2026-06-29-01
              skip_unavailable: false
      responses:
        '201':
          description: Purchase accepted and debited from settled balance.
          headers:
            Idempotent-Replayed:
              description: >-
                Present and `true` when this response replays an earlier
                purchase made with the same `custom_id`.
              schema:
                type: boolean
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExternalBuyResult'
              example:
                data:
                  purchase_id: pur_01J9Z3K8Q2
                  steam_id: '76561198000000000'
                  created_at: '2026-06-29T17:12:04Z'
                  custom_id: batch-2026-06-29-01
                  skins:
                    - name: AK-47 | Redline (Minimal Wear)
                      price: 14.37
                      status: delivering
                      return_reason: null
                      steam_trade_offer_id: '5512345678'
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                invalid_request:
                  summary: Malformed body
                  value:
                    code: invalid_request
                    detail: item_ids must contain 1–100 unique ids.
                unsupported_item:
                  summary: Item cannot be delivered this way
                  value:
                    code: unsupported_item
                    detail: One or more items cannot be delivered via this endpoint.
                invalid_trade_url:
                  summary: Bad partner/token
                  value:
                    code: invalid_trade_url
                    detail: partner and token do not form a valid Steam trade URL.
                unsupported_game:
                  summary: Game not available to this key
                  value:
                    code: unsupported_game
                    detail: >-
                      appId 570 is not available to this key. Supported: CS2
                      (730).
                    supported_app_ids:
                      - 730
                too_many_items:
                  summary: Over 10 Dota 2 / Rust ids
                  value:
                    code: too_many_items
                    detail: Up to 10 Rust items per order.
                    max_items: 10
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: invalid_api_key
                detail: Missing or invalid API key.
        '402':
          description: Not enough funds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                insufficient_settled_balance:
                  summary: Funds are inside the reversal window
                  value:
                    code: insufficient_settled_balance
                    detail: >-
                      External delivery is payable only from settled
                      (reversal-safe) balance. Wait for in-window credit to
                      settle or top up.
                    required_usd: 26.47
                    balance_usd: 30
                    settled_usd: 10
                insufficient_balance:
                  summary: Balance too low — top up
                  value:
                    code: insufficient_balance
                    detail: Balance is lower than the order total. Top up and retry.
                    required_usd: 26.47
                    balance_usd: 4.75
                    settled_usd: 4.75
        '403':
          description: Not permitted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                external_buy_disabled:
                  summary: Kill-switch off
                  value:
                    code: external_buy_disabled
                    detail: This endpoint is currently disabled.
                trading_not_enabled:
                  summary: Buying off for key
                  value:
                    code: trading_not_enabled
                    detail: Enable buying for this key in your profile.
                account_restricted:
                  summary: Account not eligible
                  value:
                    code: account_restricted
                    detail: This endpoint requires a reversal-clean account.
        '409':
          description: >-
            Conflict — an item is gone, the live price moved past your ceiling,
            a request with the same `custom_id` is still running, or prices are
            mid-refresh. An in-progress conflict leaves the original request
            unresolved. `item_unavailable` lists every missing id in
            `unavailable_ids`; on a CS2 buy, `unknown_ids` names the ones we
            have no record of at all — not a CSBoard listing id (a Steam asset
            id is the usual mix-up; listing ids are never all digits) or a
            listing that left the catalogue more than an hour ago. Follow the
            stream's `gone` events to drop listings before you buy them.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                item_unavailable:
                  summary: Item sold out
                  value:
                    code: item_unavailable
                    detail: One or more items are no longer available.
                    unavailable_ids:
                      - itm_8841999
                item_unknown:
                  summary: Id not known here (e.g. a Steam asset id)
                  value:
                    code: item_unavailable
                    detail: >-
                      One or more items are no longer available. 1 of the ids
                      are not known here (`unknown_ids`): not a listing id, or a
                      listing gone for over an hour. Steam asset ids are not
                      listing ids: send the `id` of a row from /v1/listings or
                      the stream.
                    unavailable_ids:
                      - '31846262931'
                    unknown_ids:
                      - '31846262931'
                price_moved:
                  summary: Live price exceeded ceiling
                  value:
                    code: price_moved
                    detail: Live total exceeds max_price_usd.
                    quoted_max_usd: 30
                    current_total_usd: 31.2
                    items:
                      - id: itm_8841201
                        market_hash_name: AK-47 | Redline (Minimal Wear)
                        price_usd: 15.1
                idempotency_in_progress:
                  summary: Earlier request still running
                  value:
                    code: idempotency_in_progress
                    detail: A request with this custom_id is still being processed.
                price_updating:
                  summary: Prices refreshing
                  value:
                    code: price_updating
                    detail: Prices are updating; retry shortly.
                concurrent_update:
                  summary: Lost a concurrent-update race
                  value:
                    code: concurrent_update
                    detail: >-
                      Another order touched the same items at the same moment
                      and this one was rolled back. Nothing was charged — retry.
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          description: The purchase could not be completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: order_failed
                detail: The purchase could not be completed.
        '504':
          description: >-
            The purchase outcome is unknown. Keep the original order pending and
            reconcile through GET /v1/orders/info using the saved identifier. An
            empty lookup can precede order creation. Do not automatically repeat
            an unresolved purchase, even with the same identifier.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: upstream_timeout
                detail: >-
                  The marketplace did not answer in time, so the outcome of this
                  purchase is UNKNOWN — it may still have gone through. Do not
                  re-send blindly: poll the order list (or re-send the identical
                  custom_id, which replays rather than buys) before treating it
                  as failed.
components:
  schemas:
    ExternalBuyRequest:
      type: object
      properties:
        item_ids:
          type: array
          items:
            type: string
          minItems: 1
          maxItems: 100
          uniqueItems: true
          description: 1–100 unique listing ids to buy.
        partner:
          type: string
          minLength: 1
          maxLength: 32
          description: >-
            Steam trade URL `partner` value. With `token`, forms the destination
            trade URL.
        token:
          type: string
          minLength: 1
          maxLength: 32
          description: >-
            Steam trade URL `token` value. With `partner`, forms the destination
            trade URL.
        max_price_usd:
          type: number
          description: >-
            Total ceiling in USD. Order is rejected with `price_moved` if the
            live total exceeds it.
        custom_id:
          type: string
          minLength: 1
          maxLength: 128
          description: >-
            Save one key per withdrawal. A cached success can be replayed for up
            to 24 hours. After expiry the same value may start a new purchase.
        skip_unavailable:
          type: boolean
          default: false
          description: >-
            If true, skip items that are no longer available instead of failing
            the whole request.
        autoclaim:
          type: boolean
          description: >-
            Sticky per-account setting (not per-order). Send `true` once to
            switch your key into auto-claim mode: every held order is then
            auto-released the moment its hold clears (your bot must auto-accept
            the Steam trade offer within ~15 minutes). Send `false` to switch
            back to manual claiming via `POST /orders/{id}/claim`. Omit to leave
            the setting unchanged.
        appId:
          type: integer
          enum:
            - 730
            - 570
            - 252490
          default: 730
          description: >-
            Game the `item_ids` belong to: `730` = CS2 (the default), `570` =
            Dota 2, `252490` = Rust. Send the same `appId` you read the ids with
            from `GET /listings`. Dota 2 and Rust take up to 10 ids per order. A
            game this key may not buy in answers `400 unsupported_game` —
            `tradable` in `GET /games` tells you in advance.
      required:
        - item_ids
        - partner
        - token
    ExternalBuyResult:
      type: object
      properties:
        data:
          type: object
          properties:
            purchase_id:
              type: string
            steam_id:
              type: string
            created_at:
              type: string
              format: date-time
            custom_id:
              type:
                - string
                - 'null'
            skins:
              type: array
              items:
                type: object
                properties:
                  name:
                    type:
                      - string
                      - 'null'
                  price:
                    type:
                      - number
                      - 'null'
                  status:
                    type: string
                  return_reason:
                    type:
                      - string
                      - 'null'
                  steam_trade_offer_id:
                    type:
                      - string
                      - 'null'
          required:
            - purchase_id
            - steam_id
            - created_at
            - skins
      required:
        - data
    Error:
      type: object
      description: >-
        All errors return { code, detail }. Some carry extra fields (e.g.
        price_moved adds current_total_usd, insufficient_balance adds
        required_usd/current_usd, item_unavailable adds unavailable_ids and, on
        CS2 buys, unknown_ids).
      properties:
        code:
          type: string
          description: >-
            Machine-readable error code, e.g. rate_limit_exceeded,
            trading_not_enabled, price_moved.
        detail:
          type: string
          description: Human-readable explanation.
      required:
        - code
    RateLimitError:
      type: object
      description: >-
        The `429` body of a per-key bucket. Endpoint-specific limits send only
        `code` and `detail`.
      properties:
        code:
          type: string
          description: >-
            `rate_limit_exceeded` for the key's buckets. Endpoint-specific
            limits use their own code (`snapshot_rate_limited`, `rate_limited`).
        detail:
          type: string
          description: Human-readable explanation.
        bucket:
          type: string
          enum:
            - read
            - trading
            - buy_orders
          description: Which bucket is spent.
        limit_per_min:
          type: integer
          description: That bucket's ceiling per minute.
        retry_after_sec:
          type: integer
          minimum: 1
          maximum: 60
          description: >-
            Seconds until the window restarts — the same number as
            `Retry-After`.
      required:
        - code
  responses:
    RateLimited:
      description: >-
        A per-key limit is spent. The key's own buckets answer
        `rate_limit_exceeded` with `bucket` (`read`, `trading` or `buy_orders`),
        `limit_per_min` and `retry_after_sec`. `Retry-After` is the seconds left
        until the one-minute window restarts (1–60), not a flat 60.
        Endpoint-specific limits (`snapshot_rate_limited` on the price snapshot,
        `rate_limited` on Instant Sell) send only `code` and `detail`.
      headers:
        Retry-After:
          description: >-
            Seconds until the one-minute window restarts (1–60). Waiting that
            long is always enough.
          schema:
            type: integer
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
        X-RateLimit-Bucket:
          $ref: '#/components/headers/X-RateLimit-Bucket'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
          example:
            code: rate_limit_exceeded
            detail: >-
              Read rate limit of 100 requests/min exceeded. The counter restarts
              in 23 s. For new listings use GET /v1/listings/stream instead of
              polling.
            bucket: read
            limit_per_min: 100
            retry_after_sec: 23
  headers:
    X-RateLimit-Limit:
      description: >-
        The ceiling per minute of the bucket this call spent (named in
        `X-RateLimit-Bucket`).
      schema:
        type: integer
      example: 3000
    X-RateLimit-Remaining:
      description: Calls left on that bucket in the current one-minute window.
      schema:
        type: integer
        minimum: 0
      example: 2987
    X-RateLimit-Reset:
      description: >-
        Seconds until the one-minute window restarts and the counter starts
        again.
      schema:
        type: integer
        minimum: 1
        maximum: 60
      example: 41
    X-RateLimit-Bucket:
      description: >-
        The bucket this call spent: `read` (reads and every other keyed call) or
        `trading` (buys, order reads, claims, cancels, balance). A `429` from
        the buy-order limit says `buy_orders`.
      schema:
        type: string
        enum:
          - read
          - trading
          - buy_orders
      example: trading
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send your key as a Bearer token on every request: `Authorization: Bearer
        csb_pub_...`. Generate keys in your CSBoard profile. Calls made with a
        key are metered only by that key's own limits — there is no per-IP limit
        on top — and every answer carries `X-RateLimit-Limit`,
        `X-RateLimit-Remaining`, `X-RateLimit-Reset` and `X-RateLimit-Bucket`
        for the bucket the call spent. See [Rate limits](/rate-limits).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.