TLDR: API requests are authorized using bearer tokens. Generating a token requires FlatPeak account_id and API key. Get both in Dashboard and obtain a token at login endpoint.

Authenticating to FlatPeak API

Follow two simple steps below to start making requests to FlatPeak API endpoints:

1

Get an API key

You can create, view and delete API keys in API keys section of FlatPeak Dashboard. You can create multiple keys so you can use separate keys at various parts of your service and perform key rotation without interrupting the operation of your service.

Never place your API keys at a location where they can be accessed by unauthorised personnel, your website visitors or the general public.
2

Create a bearer token

To make requests to FlatPeak API endpoints you first need to generate a bearer_token at the login endpoint. This endpoint uses HTTP Basic Authentication. The username is your FlatPeak account_id and the password is the api_key.

Bearer token request
curl --request GET \
  --url https://api.flatpeak.com/login \
  --header 'Authorization: Basic base64(account_id:api_key)'
Bearer token returned by FlatPeak API
{
  "bearer_token": "<token>",
  "expires_in": 3600
}

You can use the bearer_token to make calls to any FlatPeak API endpoints until it expires. The expiry time is returned together with the token in the expires_in field. Get a new token before the one you are using expires to avoid failed requests.