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

# Authentication

> Learn about how to authenticate with Nightly

You'll need to authenticate your requests to access any of the endpoints in the Buckets API. In this guide, we'll look at how authentication works.

## Get a Token

Start by getting an API token from your dashboard. Depending on your environment, it'll look something like:

```
nly_test_api_123abc
```

## Using Your Token

The only way to authenticate with the Nightly API is by using OAuth2. When establishing a connection using OAuth2, you will need an API key — you will find it in the Nightly dashboard under API settings. Here's how to add the token to the request header using cURL:

```bash
curl https://api.nightly.sh/v1/buckets \
  -H "Authorization: Bearer {token}"
```

<Warning>
  Always keep your token safe and reset it in the dashboard if you suspect it
  has been compromised.
</Warning>
