> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baag.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# API keys

> Send a key in the Authorization header of every request.

```bash theme={null}
Authorization: Bearer pk_live_xxxxxxxxx
```

| Key | Format | Use it |
| :- | :- | :- |
| **Public** | `pk_live_…` | In the browser |
| **Secret** | `sk_live_…` | On your server only. Never in frontend code. |

Both keys work on every endpoint, except [`GET /v1/checkout/sessions/{id}`](/v1/checkout/get): **secret key only**.

**Note:** You can always find your keys in **Baag App** → **Settings** → **Developers** section.

## Key errors

<AccordionGroup>
  <Accordion title="Missing API key">
    Returned with status `401` when there's no `Authorization` header.

    ```json theme={null}
    {
      "error": {
        "code": "missing_api_key",
        "message": "Send your API key as: Authorization: Bearer <key>."
      }
    }
    ```
  </Accordion>

  <Accordion title="Invalid API key">
    Returned with status `401` when the key is wrong, or it was regenerated in Baag App.

    ```json theme={null}
    {
      "error": {
        "code": "invalid_api_key",
        "message": "That API key isn't valid. It may have been regenerated."
      }
    }
    ```
  </Accordion>

  <Accordion title="Plan required">
    Returned with status `403` when the store's plan doesn't include API access. The keys work again once the store is back on the **Basic** plan.

    ```json theme={null}
    {
      "error": {
        "code": "plan_required",
        "message": "This store's plan doesn't include API access."
      }
    }
    ```
  </Accordion>

  <Accordion title="Rate limited">
    Returned with status `429` when the key sent too many requests in a short time. Wait a moment, then retry.

    ```json theme={null}
    {
      "error": {
        "code": "rate_limited",
        "message": "Too many requests. Slow down and try again shortly."
      }
    }
    ```
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.