Skip to content

Obtains or refreshes an API token

Request

POST {{authBaseURL}}/oauth2/token

This endpoint obtains or refreshes an API token.

Each Flute endpoint (with the exception of this authentication endpoint) requires an API token, also called an access token). It is an encrypted string generated from a Flute-owned authentication server. The API token is a combination of an authentication of the user and an authorization of the user's permissions.

Each API token has a limited lifespan. This is often 900 seconds, or 15 minutes although the actual value is returned by the authentication call. After the API token expires, it can no longer be used to make calls. The API token must then be obtained anew or refreshed.

Obtaining API Tokens

There are two ways to get a valid API token: Obtaining a new token or Refreshing an existing token.

The endpoint for obtaining a new API token or to refresh an existing one is the same. Only the request body fields are different. Selecting the appropriate option displays the relevant fields and information.

Obtaining a new token
A new token must be obtained because:

  • No token exists. This may be from the user just logging in or the previous API token expired.
  • The stored refresh_token expired, has been revoked, or gets rejected by the server (such as a refresh attempt failed).
  • A different API key is being used.

To obtain a new API token, see the call below, selecting Obtain a new token. This displays the fields and details needed to make the call.

Refreshing an existing token
An existing API token may be refreshed to create a new, valid API token. That existing API token may be currently valid or has expired recently. The goal is to provide continuous operation. This allows users to remain authenticated without repeating full credential authentication on every renewal.

An API token may be refreshed because:

  • The current access_token is about to or has already expired.
  • A valid refresh_token is currently available and valid from the most recent API token.

To refresh an API token, see the call below, selecting Refresh an existing token. This displays the fields and details needed to make the call.

API Token Types

API token types depend on the type of API keys used to create them. The resulting API token type will be one of following:

  • Merchant token if it is created from a merchant API key.
  • Partner token if it is created from a partner API key.

The two API keys types are not interchangeable. Most Flute endpoints require a merchant token. The endpoint description specifies the required API key type. Endpoints requiring a partner token will be explicitly marked. Otherwise, a merchant token is required.

Security
Bearer
Bodyapplication/x-www-form-urlencodedrequired
One of:

Use grant_type=client_credentials to obtain a brand-new API token from your API key.

client_idstringrequired

Specifies client ID from the API key for the account.

Example: 59483870959438697242c

Example:"59483870959438697242c"
client_secretstringrequired

Specifies the client secret from the API key for the account.

Example: 9eb2c6859daa4d8ae5da02a9

Example:"9eb2c6859daa4d8ae5da02a9"
grant_typestringrequired

Specifies the literal value client_credentials.

Example: client_credentials

Value:"client_credentials"
Example:"client_credentials"
scopestringrequired

Specifies the literal value offline_access.

Example: offline_access

Value:"offline_access"
Example:"offline_access"
// Language is not supported.

Responses

OK. The API token was issued successfully.

Bodyapplication/json
access_tokenstringrequired

Indicates the API token.

Example: 213bf7a8-9b0c-4d1e-2f3a-4b5c6d7e8f14

Example:"213bf7a8-9b0c-4d1e-2f3a-4b5c6d7e8f14"
token_typestringrequired

Indicates the token type.

Example: Bearer

Example:"Bearer"
expires_ininteger

Indicates the expiration period (in seconds) of the API token.

Example: 900

Example:900
refresh_tokenstring

Indicates the refresh token (only for authorization_code grant).

Example: 324c08b9-0c1d-4e2f-3a4b-5c6d7e8f9a25

Example:"324c08b9-0c1d-4e2f-3a4b-5c6d7e8f9a25"
scopestring

Indicates the granted scopes, space-delimited.

Example: null

Example:null
Response
{ "access_token": "213bf7a8-9b0c-4d1e-2f3a-4b5c6d7e8f14", "token_type": "Bearer", "expires_in": 900, "refresh_token": "324c08b9-0c1d-4e2f-3a4b-5c6d7e8f9a25", "scope": null }