---
updatedAt: 2026-08-23T17:14:33.000Z
agentTools:
  projectIndex: https://x9.readme.io/llms.txt
---

# Archive Single Account

Archive one trading account. Its positions, orders, and balance are snapshotted and the account is removed from the active set.

**Replaces:** `POST /api/v1/archives/{account_number}/archive`.

# OpenAPI definition

````json
{
  "openapi": "3.1.0",
  "info": {
    "title": "X9 Connect API",
    "description": "X9 Connect — the partner integration API for the X9 trading platform.\n\n**Authentication:** Send your X9 Connect key in the **X-Api-Key** header (company-scoped access — only your company's groups & accounts). Use the **Authorize** button above to enter your credential.\n\n**API environment:** The API explorer defaults to `https://betaapi.x9trader.com/api/broker`. Use the environment selector to switch to `https://1xapi.x9trader.com/api/broker`.\n\n**Errors** come back in a consistent envelope:\n\n```json\n{\n  \"status\": false,\n  \"error\": { \"code\": \"AUTH_MISSING_TOKEN\", \"message\": \"Authentication required\" },\n  \"request_id\": \"8b993fdf-e997-4370-ae6f-2a594a8c1e85\",\n  \"timestamp\": \"2026-08-19T18:06:57.698387+00:00\"\n}\n```\n\nQuote `request_id` when reporting a problem — it identifies the exact call in our logs.\n\n**Real-time:** a WebSocket at `/api/broker/v1/stream` carries live quotes and your accounts' position, order, trade, and balance events. See the **Real-Time Stream** section.\n\n**Upgrading from the old API?** Everything that used to live under `/api/v1` and `/api/v2` on `webapi.x9trader.com` now sits under `/api/broker/v1`, and the auth header changed from `X-CRM-Token` to `X-Api-Key`. Each endpoint below names the old path it **Replaces**.",
    "version": "1.0.0"
  },
  "tags": [
    {
      "name": "Accounts",
      "description": "Create, list, and manage trading accounts — details, settings, passwords, leverage, group membership, and archiving."
    }
  ],
  "paths": {
    "/v1/accounts/{account_number}/archive": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Archive Single Account",
        "description": "Archive one trading account. Its positions, orders, and balance are snapshotted and the account is removed from the active set.\n\n**Replaces:** `POST /api/v1/archives/{account_number}/archive`.",
        "operationId": "archive_account_v1_accounts__account_number__archive_post",
        "parameters": [
          {
            "name": "account_number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Account Number",
              "description": "Trading account number"
            },
            "description": "Trading account number"
          }
        ],
        "responses": {
          "200": {
            "description": "Account archived successfully",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Account cannot be archived in its current state"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "Access denied (credential scope)"
          },
          "404": {
            "description": "Account not found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "CRMTokenAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "CRM token (X9 Connect key) — company-scoped access to your assigned groups & accounts. Issued per company / company admin."
      }
    }
  },
  "servers": [
    {
      "url": "https://{environment}.x9trader.com/api/broker",
      "description": "X9 Connect",
      "variables": {
        "environment": {
          "default": "betaapi",
          "enum": [
            "betaapi",
            "1xapi"
          ],
          "description": "Select the X9 Connect backend"
        }
      }
    }
  ],
  "security": [
    {
      "CRMTokenAuth": []
    }
  ]
}
````