Skip to main content
All examples on this page use the test environment, so nothing is booked. They assume your test key is in the BULLIONWALE_API_KEY environment variable (see the quickstart).

The order request

POST /orders places a market order at the current price. The body: Send quantity and expected_price as JSON numbers. Responses return them, and every other amount, as strings. The Idempotency-Key header is required: 1 to 64 characters, a new UUID per order. A missing or empty header is 400 idempotency_key_required; one longer than 64 characters is 422 invalid_request. See Idempotency and safe retries.

Place the order

201 Created

Send it again with the same key

Sending the same request with the same Idempotency-Key does not place a second order. You get the existing order back with status 200 and the response header Idempotent-Replayed: true. This is what makes a retry after a timeout safe.
200 OK (Idempotent-Replayed: true)
Reusing the key with a different body (another symbol, side, quantity, expected_price or client_order_id) books nothing and is refused:
curl
422 Unprocessable Entity

List your orders

GET /orders returns your test orders, newest first, with the total number that match.
200 OK

Read your test positions

200 OK
Gold is in grams and silver in kilograms. See Positions and your weight allocation.

Try the common errors

Every refusal is an HTTP status with a JSON body whose detail.code you can branch on. The full list is in Errors. No key. Every call needs the X-API-Key header.
curl
401 Unauthorized
A live key on a test path (or a test key on a production path):
curl
401 Unauthorized
No Idempotency-Key header on an order:
curl
400 Bad Request
An Idempotency-Key longer than 64 characters:
curl
422 Unprocessable Entity
A key without orders:write placing an order:
curl
403 Forbidden
An unknown symbol:
curl
404 Not Found
More than your free weight allocation:
curl
400 Bad Request
An invalid body, here a negative quantity. The errors list says which field is wrong:
curl
422 Unprocessable Entity
An order id that is not yours (or does not exist):
curl
404 Not Found