# Getting Started with Trading API

> Place, observe, and reconcile a sandbox trade with the MyStocks Partner API.

## Workflow

1. Authenticate with a sandbox partner key.
2. Create or select a verified sub-account, or use the master account.
3. Request a quote using the exact symbol, side, quantity, or `cashValue`.
4. Place the order with the returned `quoteId` and an `Idempotency-Key`.
5. Poll order status or subscribe to signed webhook/SSE events.
6. Inspect executions, portfolio, buying power, and ledger entries.
7. Reconcile the completed trade against the daily report.

The full request sequence is in [Trading](/partners/docs/trading), including market, limit, stop, time-in-force, cancellation, and fractional cash-value examples.

## Important invariants

- Never reuse an expired or already-consumed quote.
- Never generate a new idempotency key when retrying the same write.
- Treat webhook delivery as at-least-once and potentially out of order.
- Do not treat a submitted or pending order as settled custody.

Use the [API Tester](/partners/docs/api-tester) for individual calls and the [API Reference](/partners/docs/api-reference) for the exact request schema.

## Exercise the order lifecycle

Use the [guided sandbox workflow](/partners/docs/api-tester?workflow=broker) with a synthetic, funded customer. The quote-to-trade handoff exercises the quote-gated API; the simulator exercises deterministic lifecycle transitions separately.

1. Create a pending simulator order and copy its actual `orderId`.
2. Partially fill five of ten units, inspect executions, then fill the remainder.
3. Settle the filled order and check its settlement state separately from the order status.
4. Read the wallet, portfolio and transactions, comparing amounts and quantities to the starting state.
5. Create separate rejected and cancelled orders and check reservation release.

Use **Retry same request** only with the unchanged URL and body. Inspect both the response and the resulting order state to verify that a retry did not duplicate the write. Review [Errors](/partners/docs/errors) for response codes and [Webhooks](/partners/docs/webhooks) for event verification. Next, add reconciliation checks from [Reconciliation](/partners/docs/daily-reconciliation).
