> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/errors/http-errors.md).

# HTTP errors

## Status codes

| Code  | Meaning               | Common cause                                                              |
| ----- | --------------------- | ------------------------------------------------------------------------- |
| `400` | Bad request           | Invalid pubkey, missing field, bad enum, trigger/limit validation failure |
| `404` | Not found             | Account/pool not found; price symbol not in the config                    |
| `429` | Too many requests     | Per-owner WebSocket connection limit (5) exceeded                         |
| `500` | Internal server error | Compute failure, blockhash fetch failed, unexpected state                 |
| `503` | Service unavailable   | Price data missing (market closed); global WebSocket limit reached        |

## Two error shapes

```json
// HTTP-level failure (400, 404, 500, …)
{ "error": "descriptive message" }

// Compute failure returned inside a 200 body (quote endpoints)
{ "err": "descriptive message" }
```

The API uses `"error"` for HTTP/transport failures and `"err"` for domain/compute failures on trading/preview quote endpoints. Trigger-order and limit-order builders return validation failures as `400 { "error": "…" }`. **Always check for both.**

## Handling pattern

```typescript
const res = await fetch(`${FLASH_API_URL}/transaction-builder/open-position`, {
  method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(req),
});

if (!res.ok) {
  const { error } = await res.json();          // 4xx / 5xx
  if (res.status === 404) console.error("Market or symbol not found");
  if (res.status === 503) console.error("Price unavailable (market closed?)");
  throw new Error(error);
}

const data = await res.json();
if (data.err) throw new Error(data.err);       // compute error in a 200 body
// else sign & submit data.transactionBase64
```

For submitted-transaction failures (the program rejects a signed tx), see [On-chain error codes](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/errors/onchain-error-codes.md).


---

# 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.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/errors/http-errors.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.
