> For the complete documentation index, see [llms.txt](https://docs.fastn.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastn.ai/operate/troubleshooting/troubleshooting.md).

# Developer troubleshooting

Common errors when embedding fastn, with their causes and fixes.

### Blank embed / iframe renders nothing

**Most likely cause:** an expired or hardcoded token.

Embed tokens expire after 8 hours. If a token is hardcoded into your frontend or cached and reused, it works until it expires, then the iframe loads blank with no obvious error.

**Fix:** Generate a fresh token from your backend on each page load. Never hardcode or cache tokens. See [Generating Embed Tokens](https://docs.fastn.ai/embed/embedding/generating-embed-tokens.md).

**Also check:** In production, confirm `FASTN_API_KEY` is bound on the runtime, not just present in CI. An undefined API key means token generation fails silently. See [Deployment](https://docs.fastn.ai/build/lifecycle/deployment.md).

### 404 on the token request

**Most likely cause:** the wrong customer identifier.

For `x-org-id`, or `orgId` in the body, use fastn's customer id, or the External ID shown on the customer (your own id if you set one when creating the customer; otherwise it defaults to the slug). An id that matches neither returns `404`: `IDENTITY_ORG_NOT_FOUND` for `x-org-id`, `Tenant not found` for `orgId`. With a key limited to a single customer, only fastn's id works in `orgId`. See [Generating Embed Tokens](https://docs.fastn.ai/embed/embedding/generating-embed-tokens.md).

### 401 on the token request

**Most likely cause:** an API key set to **Enforce** under **Verify caller identity (HMAC)**, called without signed identity headers.

Such a key refuses a token request that names the customer only in the body, or in `x-org-id` with no hash: `401 IDENTITY_HEADERS_REQUIRED` when there are no identity headers, `401 IDENTITY_HMAC_INVALID` when the hash is missing or wrong.

**Fix:** Send `x-org-id`, `x-user-id` and `x-identity-hmac`, computed with the key's identity secret. See [Generating Embed Tokens](https://docs.fastn.ai/embed/embedding/generating-embed-tokens.md).

### Requests fail with a test key

**Most likely cause:** the missing test-mode header.

Requests made with a `fsk_test_` key require the header `X-fastn-Test-Mode: true`. Without it, requests fail with 403 `Test API keys require X-fastn-Test-Mode: true header`.

**Fix:** Add `X-fastn-Test-Mode: true` for test keys. Remove it for live keys. See [Authentication & API Keys](https://docs.fastn.ai/embed/api-keys/authentication-and-api-keys.md).

### "Failed to fetch" in the widget

**Most likely cause:** a tenancy or token mismatch.

This can appear when the iframe URL's tenancy shape doesn't match how the token was minted - for example, a single-tenant embed where the `tenant-id` and token identity don't line up.

**Fix:** Confirm the iframe URL matches your intended tenancy (see [Tenancy](https://docs.fastn.ai/embed/embedding/understanding-tenancy.md)), and that the token was generated with the correct `x-org-id` and identity fields. Confirm the backend token pattern is being used rather than a hardcoded token.

### Empty response token

**Most likely cause:** reading the token from the wrong place in the response.

The token is nested under `data` in the response - `response.data.token`, not `response.token`.

**Fix:** Read `json.data.token`. See [Generating Embed Tokens](https://docs.fastn.ai/embed/embedding/generating-embed-tokens.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.fastn.ai/operate/troubleshooting/troubleshooting.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.
