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

# API Quickstart

> Make your first authenticated call to the Dynamic REST API in a few minutes, using a dashboard API token.

Use the REST API when you want to work with Dynamic from a backend, a script, or any language without a Dynamic SDK. This page gets you to a first successful response.

<Note>
  Building a client app instead? Start with an SDK: [JavaScript](/docs/javascript/reference/quickstart), [Swift](/docs/swift/quickstart), [Kotlin](/docs/kotlin/quickstart), [Flutter](/docs/flutter/quickstart), or [Node](/docs/node/quickstart).
</Note>

## Which token do you need

The API has two kinds of endpoint, and they take different bearer tokens.

| You are calling                                  | Token                          | Where it comes from   |
| ------------------------------------------------ | ------------------------------ | --------------------- |
| Admin endpoints, acting as the environment owner | **API token**, prefixed `dyn_` | The dashboard, once   |
| SDK endpoints, acting as a signed-in user        | **User JWT**                   | Your app, per session |

This quickstart uses an API token. For the SDK endpoints, read [Authentication](/docs/api-reference/overview#authentication).

## Steps

<Steps>
  <Step title="Create an API token">
    In the dashboard, open the [Developer tab](https://app.dynamic.xyz/dashboard/developer/api) and click **Create Token** in the API Token section.

    Name it after the system that will use it, for example `billing-service`, and grant only the scopes that system needs. See [API token permissions](/docs/platform/dashboard/api-token-permissions).

    <Warning>
      Copy the token before closing the dialog. Dynamic does not store the plaintext value, so a lost token has to be replaced with a new one.
    </Warning>
  </Step>

  <Step title="Find your environment ID">
    Every request is scoped to an environment. Your environment ID is in the dashboard, and each environment has a separate sandbox and live pair. Use the sandbox one while you are trying things out.
  </Step>

  <Step title="Make your first call">
    Read back your own environment. A `200` confirms the token, the environment ID, and the scopes are all correct.

    <CodeGroup>
      ```bash curl theme={"system"}
      curl "https://app.dynamic.xyz/api/v0/environments/$DYNAMIC_ENVIRONMENT_ID" \
        --header "Authorization: Bearer $DYNAMIC_API_TOKEN" \
        --header 'Content-Type: application/json'
      ```

      ```typescript TypeScript theme={"system"}
      const response = await fetch(
        `https://app.dynamic.xyz/api/v0/environments/${process.env.DYNAMIC_ENVIRONMENT_ID}`,
        {
          headers: {
            Authorization: `Bearer ${process.env.DYNAMIC_API_TOKEN}`,
            'Content-Type': 'application/json',
          },
        },
      );

      if (!response.ok) {
        throw new Error(`Dynamic API returned ${response.status}`);
      }

      const environment = await response.json();
      ```

      ```python Python theme={"system"}
      import os
      import requests

      response = requests.get(
          f"https://app.dynamic.xyz/api/v0/environments/{os.environ['DYNAMIC_ENVIRONMENT_ID']}",
          headers={
              "Authorization": f"Bearer {os.environ['DYNAMIC_API_TOKEN']}",
              "Content-Type": "application/json",
          },
          timeout=10,
      )
      response.raise_for_status()
      environment = response.json()
      ```
    </CodeGroup>

    <Warning>
      Keep the token server-side. Read it from an environment variable or a secrets manager, never from client-side code or a committed file, since it carries the scopes you granted it.
    </Warning>
  </Step>

  <Step title="Call something useful">
    List the users in the environment:

    ```bash curl theme={"system"}
    curl "https://app.dynamic.xyz/api/v0/environments/$DYNAMIC_ENVIRONMENT_ID/users" \
      --header "Authorization: Bearer $DYNAMIC_API_TOKEN"
    ```

    See [Get all users for an environment](/docs/api-reference/users/get-all-users-for-an-environment) for filtering and pagination.
  </Step>
</Steps>

## If it does not work

| Status | What it usually means                                                    |
| ------ | ------------------------------------------------------------------------ |
| `401`  | The token is missing, malformed, or revoked. Check the `Bearer ` prefix. |
| `403`  | The token is valid but lacks the scope for this endpoint.                |
| `404`  | The environment ID is wrong, or belongs to another project.              |

The full list is in [Standard errors](/docs/api-reference/overview#standard-errors).

## Next

<Columns cols={2}>
  <Card title="Authentication" href="/docs/api-reference/overview#authentication">
    API tokens, user JWTs, and when to use each.
  </Card>

  <Card title="Endpoints" href="/docs/api-reference/overview">
    Every endpoint, grouped by resource.
  </Card>
</Columns>
