# Authentication (/api/v0.2b/using-the-api/authentication)

To use Spoke Public API endpoints you will first need to generate an API key
for authenticating with our servers.

To do this you need to go to your Spoke Dispatch settings page > Integrations
\> API, and generate a new key there.

Once you have the API key you can use it in the `Authorization` header
either using the Basic scheme, or as a Bearer token.

## Basic Auth

[Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) is the primary authentication scheme used
by Spoke's API.

Basic authentication typically uses a base64 encoded `username:password`
pair, but since we only require an API key we instead structure the payload as `[yourApiKey]:[empty]`. This
value is then base64 encoded as usual.

Example with `curl`:

```bash
curl "https://api.spoke.com/public/v0.2b/plans" -u yourApiKey:
```

If you did everything correctly you should see a list of your team's plans in response
to this request.

The `-u` flag adds a header to the request in the following format:

```http
Authorization: Basic eW91ckFwaUtleToK
```

Note that curl automatically base64 encoded the data. Other clients will do the same e.g. if using Postman you would
configure the request's Authorization option instead of adding a header directly.

## Bearer Token

Alternatively you can pass the API key as a Bearer token without any special encoding.
i.e. `Authorization: Bearer [yourApiKey]`.

Example with `curl`:

```bash
curl "https://api.spoke.com/public/v0.2b/plans" -H "Authorization: Bearer yourApiKey"
```