> 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

HTTP status codes and the two error shapes.

## 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/errors/http-errors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
