# Postman

Every call of the API as a Postman collection, with a sandbox and a live environment: import three files, paste your key, send.

The collection has every REST call of the API, one folder per part (accounts, positions, orders, exits, strategies, webhooks, TradingView and the others), each request with its parameters and an example body. It is generated from the same OpenAPI document as the SDKs and the reference, so it always matches them.

## Download

- [The collection](/downloads/postman/phoenixperps.postman_collection.json)
- [The sandbox environment](/downloads/postman/sandbox.postman_environment.json)
- [The live environment](/downloads/postman/live.postman_environment.json)

## Set it up

1. In Postman, choose Import and drop the three files.
2. Pick the sandbox environment (top right), open it and paste a sandbox key (`ppk_test_...`) as `apiKey`, in the Current value column: that column stays on your computer, the Initial value is what a shared workspace sends to others.
3. Open the accounts folder and send the request that lists your accounts.

The live environment works the same with a live key (`ppk_live_...`): its orders are real. A key works on its own host only, so a sandbox key on the live environment answers `wrong_environment`.

## What the collection fills in

- `{{baseUrl}}`: the environment's host, the sandbox's or the live one.
- `{{apiKey}}`: sent as `Authorization: Bearer <key>` on every request.
- `{{idempotencyKey}}`: a new Idempotency-Key for each write you send, made by the collection before each request. A retry of the same request inside one run reuses it, so an order is placed once.
- `{{accountId}}`, `{{market}}`, `{{orderId}}` and the other ids in the paths: collection variables. Set them once (Variables tab of the collection) and every request uses them.

## Other tools

Insomnia, Bruno, Hoppscotch and code generators read the [OpenAPI document](/openapi.json) (OpenAPI 3.1). The streams are described in the [AsyncAPI document](/asyncapi.json).
