> For the complete documentation index, see [llms.txt](https://docs.anchored.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anchored.finance/trading-api/reference/integration-test-checklist.md).

# Integration Test Checklist

Use this checklist before granting production access or enabling real user trading.

## Test Accounts and Scope

| Check                   | Expected                                |
| ----------------------- | --------------------------------------- |
| API key active          | Requests authenticate successfully      |
| IP whitelist configured | Requests only work from approved IPs    |
| `READ_ONLY` key         | GET works; POST/DELETE fails            |
| `WRITABLE` key          | GET/POST/DELETE work for approved scope |
| Product scope           | Only configured `x-api-p` works         |
| Chain scope             | Only configured `x-api-chain-id` works  |

## Authentication Tests

Required cases:

* Valid GET with sorted query params.
* Valid POST with exact raw body.
* Invalid timestamp older than 45 seconds.
* Duplicate nonce within the replay window.
* Body changed after signature.
* Missing `x-api-chain-id`.
* Wrong `x-api-p` casing.

Expected result: valid requests pass, and each invalid case fails with a clear auth or validation error.

## Market and Portfolio Tests

| Test                          | Expected                                  |
| ----------------------------- | ----------------------------------------- |
| `GET /symbols`                | Returns at least one known tradable stock |
| `GET /prices/{symbol}`        | Returns quote context                     |
| `GET /corporate-action`       | Returns list or empty list without error  |
| `GET /users/{userId}/balance` | Returns `musdBalance` and `tokenBalances` |
| `spenderAddress` query        | Returns `walletAllowance` for spender     |

## Cash Tests

Required cases:

* Deposit calldata with valid `userAddress`, `tokenAddress`, `tokenAmount`.
* Deposit tx succeeds after approval.
* Deposit tx reverts or is blocked when allowance is missing.
* `POST /cash/deposits/tx` is idempotent for the same API key and tx.
* Deposit detail eventually reaches final status.
* Withdrawal calldata builds for available `musdBalance`.
* Withdrawal detail can be polled by `operationId`.

## Stock Movement Tests

Required cases:

* Stock deposit calldata builds for valid `userAddress`, `tokenAddress`, `tokenAmount`.
* Stock deposit tx succeeds after stock token approval.
* Stock withdrawal calldata builds for available `exchangeBalance`.
* Stock deposit and withdrawal details can be polled by `operationId`.

## Order Tests

| Test                             | Expected                                                                                                                                                                                                         |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Market buy calldata              | Returns router `toAddress`, `value`, `callData`                                                                                                                                                                  |
| Market sell calldata             | Plain sell requires sufficient `exchangeBalance`; wallet-held stock can be moved with `/stock/deposits/*` first                                                                                                  |
| Order-with-deposit buy calldata  | Requires cash token allowance and instant deposit eligibility                                                                                                                                                    |
| Order-with-deposit sell calldata | Requires stock token allowance and wallet stock balance                                                                                                                                                          |
| Limit buy calldata               | Requires `quantity`, `price`, and `timeInForce`; current production contracts accept only `DAY`                                                                                                                  |
| Limit sell calldata              | Requires `quantity`, `price`, and `timeInForce`; current production contracts accept only `DAY`. Plain sell requires sufficient `exchangeBalance`; wallet-held stock can be moved with `/stock/deposits/*` first |
| Cancel calldata                  | Works only for open limit orders                                                                                                                                                                                 |
| Record order tx                  | Backfills mapping/orderId                                                                                                                                                                                        |
| Order detail                     | Moves from open to history after settlement                                                                                                                                                                      |

Include negative tests:

* Missing `notional` for market buy.
* Missing `quantity` for market sell.
* Missing `price` for limit order.
* Non-`DAY` `timeInForce` for limit order.
* Expired `deadline`.
* Cancel market order.
* Cancel order owned by different API key.

## One Click Tests

Required cases:

* Status before enable.
* Prepare returns signer-matching `signPayload`.
* Signature by wrong wallet is rejected.
* Expired deadline is rejected.
* Enable succeeds with correct signature.
* `/send` order succeeds after enable.
* Deposit `/send` fails without token approval.
* Disable succeeds and blocks future `/send`.

## Reconciliation Tests

After each state-changing test, verify:

* API response `code` is `200`.
* Tx receipt succeeded.
* Mapping endpoint finds tx.
* Detail endpoint reaches expected state.
* Portfolio reflects final balances.
* Fees and partial fills are shown correctly when present.

## Production Readiness

Before go-live:

* Store API secrets securely.
* Log request path, response `uuid`, txHash, orderId, operationId.
* Never log API secret, wallet private key, or raw authorization material.
* Monitor delayed `processing` operations.
* Document queued cash behavior and async order settlement.
* Provide a manual support path for stuck tx/order/operation IDs.


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.anchored.finance/trading-api/reference/integration-test-checklist.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
