Skip to main content
This guide will get you all set up and ready to use the Nightly API. We’ll cover how to get started with an API key and how to make your first API request. We’ll also look at where to go next to find all the information you need to take full advantage of the powerful Nightly platform.

Account Setup

Before you can use the API, you’ll need to create a Nightly account and get an API key.

Create an account

If you don’t already have one, start by creating a Nightly account at app.nightly.sh. This registration process will guide you through the necessary steps to open an active Nightly account.

Get an API key

Once your Nightly account is active, head to your settings page to find your API key. You’ll need this key to authenticate your API requests.

Use the API

Now that you have a Nightly account, you can start using the API to create buckets and receive data.

Create a Bucket

We’ll start by using cURL, but you can also use our libraries to access the Nightly API. In Nightly, a Bucket is an SFTP server that you control. You can create as many buckets as you need to receive data from your customers. Before making your first API request, you need to make sure cURL is installed:
# cURL is most likely already installed on your machine
curl --version
Once you’ve confirmed that cURL is installed, you can create your first bucket:
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer API_KEY_GOES_HERE" \
  -d '{"name": "My First Bucket"}' \
  https://api.nightly.sh/v1/buckets
Don’t forget to replace API_KEY_GOES_HERE with your API key from the settings page.
Assuming all went well, you’ll see a response like this:
{
  "id": "nly_prod_buc_1amaj5125as",
  "name": "My First Bucket",
  "host": "1amaj5125as.sftp.nightly.sh",
  "active": true,
  "created_at": 692233200
}

Create a User

Now that you have a bucket, you can create a user to access it.
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer API_KEY_GOES_HERE" \
  -d '{"username": "user", "password": "password", "bucket_id": "BUCKET_ID_FROM_PREVIOUS_STEP"}' \
  https://api.nightly.sh/v1/users
Don’t forget to replace API_KEY_GOES_HERE with your API key from the settings page and BUCKET_ID_FROM_PREVIOUS_STEP with the id from the previous JSON response.
A successful response will look something like this:
{
  "id": "nly_prod_usr_1amaj5125as",
  "username": "user",
  "active": true,
  "permissions": {},
  "created_at": 692233200
}

Access Your Bucket

Finally, you can use any SFTP client to access your bucket. At Nightly, we’re big fans of Transmit, but you can use any SFTP client you like. You can also use the command line:

What’s Next

Congratulations! You’ve successfully set up your first SFTP bucket. Here are some more resources to help you dig deeper: