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

# API authentication with Bearer keys

> Obtain a Bastion API key from the dashboard, choose between the sandbox and production environments, and pass the key as a Bearer token in requests.

Authenticate your requests to the Bastion API by obtaining an API key from the Bastion dashboard and passing it in the `Authorization` HTTP header.

## API environments

Bastion provides two environments:

| Environment | Base URL                         | Dashboard URL                                                                  |
| ----------- | -------------------------------- | ------------------------------------------------------------------------------ |
| Production  | `https://api.prod.bastion.com`   | [https://dashboard.prod.bastion.com](https://dashboard.prod.bastion.com)       |
| Sandbox     | `https://api.sandbox.bastion.io` | [https://dashboard.sandbox.bastion.com](https://dashboard.sandbox.bastion.com) |

## Obtain an API key

Contact our sales team at [sales@bastion.com](mailto:sales@bastion.com) to gain access to the Bastion platform. Our team will review your request and respond with access credentials along with additional instructions and terms of use.

Once you have dashboard access, you can create API keys directly from the Bastion dashboard:

1. Navigate to the **API keys** tab in the left sidebar.

   <Frame>
     <img src="https://docs-cdn.bastion.com/971cf5b1f72e755da54b7fcf45717e5c297ec6837c76d6bba033f04daae09506.png" alt="Bastion sandbox dashboard" />
   </Frame>

2. Select **Create new API Key** and enter a name for the key.

   <Frame>
     <img src="https://docs-cdn.bastion.com/87e521d6d2914cae435a42565675cf0f4504b39e1c9f85e1241ea7087753acaf.png" alt="Create new API key dialog in the sandbox dashboard" />
   </Frame>

3. Copy and securely store the generated secret key — it won't be retrievable after this step.

   <Frame>
     <img src="https://docs-cdn.bastion.com/3db3e3a637041cc5297ee092b92b0923ebb2eaeab0c05a58e16609398861cfec.png" alt="Newly created secret API key shown in the sandbox dashboard" />
   </Frame>

<Info>
  Your API key is unique to your organization. Do not share it with unauthorized individuals or expose it in client-side code, public repositories, or configuration files.
</Info>

## Pass the API key in request headers

Once you have obtained your API key, include it in the HTTP request headers for every API call:

1. Set the `Authorization` header in your HTTP requests.
2. Use the `Bearer` scheme followed by a space and your API key:
   <CodeGroup>
     ```text theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
     Authorization: Bearer <your-api-key>
     ```
   </CodeGroup>
3. Replace `<your-api-key>` with the actual key provided to you.

### Example requests

<CodeGroup>
  ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
     curl -H "Authorization: Bearer <your-api-key>" \
       https://api.sandbox.bastion.io/v2/accounts
  ```
</CodeGroup>

A successful authenticated request returns a `200` response. If your key is missing or invalid, you'll receive a `401 Unauthorized` response.

## Next steps

* Explore the [Sandbox access](/guides/getting-started/api-access-prerequisites) page for details on the sandbox environment and dashboard
* Browse the [API reference](/v2/api-reference/authentication/overview) to see available endpoints


## Related topics

- [API authentication overview](/guides/security/api-authentication.md)
- [Request signing with JWTs](/v2/api-reference/authentication/request-signing.md)
- [Sandbox vs. production environments](/guides/getting-started/sandbox-vs-production-environments.md)
- [JWT generation example](/v2/api-reference/authentication/jwt-generation-example.md)
- [Security architecture overview](/guides/security/overview.md)
