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

# Authentication

> Create a Get2Dial API key and authenticate every request to the API with it as a bearer token, in one header.

Create an API key and use it to authenticate requests to the Get2Dial API.

## Before you start

* You need an **admin** role to create API keys.

## Steps

<Steps>
  <Step title="Go to API keys">
    In your Get2Dial workspace, go to **Settings > API keys**, then select **New API key**.
  </Step>

  <Step title="Name the key and set its scopes">
    Enter a **Name**. Optionally set a custom **Rate limit (requests / minute)** — leave it
    blank to use your workspace's default. Under **Scopes**, set each resource to **No
    access**, **Read**, or **Read & write** — the same model used for
    [user roles](/account/roles-and-permissions). A key only reaches what it's granted.
  </Step>

  <Step title="Copy the key">
    Copy the key immediately — it starts with `g2d_key_` and is shown in full exactly once.
    Get2Dial stores only a hash of it; if you lose it, you have to create a new one.
  </Step>

  <Step title="Send it on every request">
    Include it as a bearer token:

    ```bash theme={null}
    curl https://api.get2dial.com/api/v1/campaigns \
      -H "Authorization: Bearer <your-api-key>"
    ```
  </Step>
</Steps>

<Note>
  The same `Authorization: Bearer <token>` header also accepts a session token from
  `POST /auth/login` — useful for testing, but a workspace API key is the right credential for
  a real integration since it's independently scoped and doesn't expire with a browser
  session.
</Note>

## Verify

<Check>
  A request with your key against `GET /api/v1/campaigns` (or any endpoint your key's
  capabilities cover) returns `200 OK` instead of `401` or `403`.
</Check>

## Common problems

* **401 Unauthorized.** The key is missing, malformed, or revoked. Confirm the header is
  exactly `Authorization: Bearer <your-api-key>`.
* **403 Forbidden on a specific endpoint.** The key doesn't have the capability that
  endpoint requires — edit the key and grant it.
* **You lost the key.** There's no way to retrieve it again — revoke it and create a new
  one.

## Next steps

<CardGroup cols={2}>
  <Card title="Make your first request" href="/developers/make-your-first-request" />

  <Card title="Conventions" href="/developers/conventions" />
</CardGroup>
