> For the complete documentation index, see [llms.txt](https://ocx.gitbook.io/ocx-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ocx.gitbook.io/ocx-doc/ocx/api/overview.md).

# overview

The OCX REST API lets you do everything the web app does — query markets, place and cancel orders, manage your portfolio, and stream live data.

## Base URL

```
https://api.ocx.global
```

All endpoints in this reference are relative to this base URL unless explicitly noted.

## Quick links

| Need                                        | Section                                                                       |
| ------------------------------------------- | ----------------------------------------------------------------------------- |
| Sign in via SIWE                            | [Auth](broken://pages/4402d427d9724e0c06428a0addec266e007bb164)               |
| Check balances, deposit, withdraw, transfer | [Wallet](broken://pages/8cef121032ab4a5720842f11ac322686e483fa37)             |
| Consolidated portfolio view                 | [Portfolio](broken://pages/4731b675ab749e8bb1ea5263ffa7004bae5ccadc)          |
| Orderbooks, markets, OHLC, quotes           | [Market Data](broken://pages/a59e8e430cd85e8109d057cf89d62387c4f76d02)        |
| Options orders, quotes, board               | [Options Trading](broken://pages/39a39fe628e57eb0b8562910f8a964f6745db2fd)    |
| Spot / perpetual / futures orders           | [Perpetuals Trading](broken://pages/4c464c9c7fbc50951a4424e9d405a0b20e51d098) |
| Create, list, and revoke API keys           | [API Keys](broken://pages/3ef96c2ed737e95650fc76935ee64849bace54f3)           |
| Real-time data over WebSocket and SSE       | [Streams](broken://pages/934cf0fa5680e610a3fa559a076dba1cca7b39e1)            |
| HTTP status codes and error shapes          | [Error Codes](file:///7302513/reference/error-codes.md)                       |

## Format

* All requests and responses use `application/json`.
* All numeric fields are **decimal strings** (e.g., `"67450.25"`) to preserve precision. Your client should parse them into a decimal library — never a 64-bit float — for anything you'll sum or compare.
* All timestamps are **ISO-8601 strings in UTC** (e.g., `"2026-04-24T12:00:00.000Z"`), except `sourceTs` / `engineTs` fields on stream messages which are **unix milliseconds**.

## Authentication

Every authenticated request must include either:

* A session cookie (set by `POST /auth/siwe`), or
* An `Authorization: Bearer <token>` header, where `<token>` is either the raw session JWT or an API key secret (`ocx_sk_...`).

See the [Authentication](file:///7302513/authentication/overview.md) section.

## Idempotency

Order-placement endpoints (`POST /orders`, `POST /perps/orders`, and their bulk cousins) support an optional `clientOrderId` field. If you include the same `clientOrderId` on a retry, OCX will return the existing order instead of creating a duplicate.

**We recommend always setting `clientOrderId`** for production integrations. Generate a UUID or ULID per logical order and keep it in your bot's local state.

## Versioning

Breaking changes to the API are announced at least 30 days in advance in the [Changelog](file:///7302513/reference/changelog.md). Additive changes (new endpoints, new optional fields) are shipped without notice.

## Correlation IDs

Every request is assigned a correlation ID. You can supply your own with the header:

```http
X-Correlation-Id: a1b2c3d4-...
```

If you're reporting an issue, include this ID — it lets us trace your exact request through the platform.


---

# 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 dynamically by asking a question.

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

```
GET https://ocx.gitbook.io/ocx-doc/ocx/api/overview.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.
