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

# Using the API

> Authenticate and make your first API request

The API is available at `https://api.sfcompute.com/v2`. All requests require a
Bearer token.

The API exposes the same resource model as the CLI. Pools hold an allocation schedule, orders buy
and sell compute time, and instances run on pools. If that model is new, start with
[Instances and Pools](https://docs.sfcompute.com/preview/guides/instances-and-pools.md) before wiring the API into an
application.

## Create an API token

Create a token with the CLI.

```bash theme={null}
sf tokens create --name my-token
```

This prints a token starting with `sk_live_`. Save it somewhere safe. You can't retrieve it again.

## Grant permissions

Tokens start with no permissions. Grant access to the resources your token needs. These examples use
a workspace named `my-workspace`; every new organization starts with one named `default`.

```bash theme={null}
sf grants create --token my-token --role admin --workspace my-workspace
```

The `admin` role grants full access to the workspace; give production tokens a narrower role. See
[Roles](https://docs.sfcompute.com/preview/roles.md) and [Grants](https://docs.sfcompute.com/preview/grants.md) for how permissions work, and the
[Quickstart](https://docs.sfcompute.com/preview/quick-start.md) for more on workspaces.

## Make a request

Replace `my-account` with your organization name (shown by `sf me` or in the dashboard). Replace
`<token>` with the token you created above.

```bash theme={null}
curl 'https://api.sfcompute.com/v2/pools?workspace=sfc:workspace:my-account:my-workspace' \
  -H "Authorization: Bearer sk_live_..."
```

API workflows follow the same shape as the [Quickstart](https://docs.sfcompute.com/preview/quick-start.md).

1. Create or choose a pool.
2. Place a buy order to add allocation.
3. Create instances on the pool.
4. Read pool, order, and instance state to track what happened.

## API reference

Browse every endpoint, with request parameters and response shapes, in the sidebar. Start with the
[Pools API](https://docs.sfcompute.com/api-reference/pools/list-pools.md).
