Skip to main content
POST
/
connect
/
tariff
/
token
Create a connect token
curl --request POST \
  --url https://api.flatpeak.com/connect/tariff/token \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "direction": "IMPORT",
  "type": "COMMODITY",
  "callback_uri": "https://app.myapp.com/4623e56fc5c1",
  "connect_web_uri": "myapp://oauth-callback/flatpeak",
  "customer_id": "cus_65e421d1daa4a24082b4f590",
  "customer_reference_id": "CUS0123456789",
  "location_id": "loc_641b90b758fb8e6293716e40",
  "location_reference_id": "LOC0123456789",
  "tariff_id": "trf_6597ef46529ab4467502af0b",
  "postal_address": {
    "address_line1": "1-3",
    "address_line2": "Strand",
    "city": "London",
    "state": "Greater London",
    "post_code": "WC2N 5EH",
    "country_code": "GB"
  }
}'
{
  "connect_token": "cot_65df3e949a785c52283026ec",
  "expires_in": 86400,
  "live_mode": true
}
When you want to enable a customer to view the summary of their tariff anywhere in your app, update it or even revoke tariff access, specify a location_id in the request body. When you launch Connect, it will return the summary screen enabling tariff connection management.

Authorizations

Authorization
string
header
required

Authenticate with bearer_token you obtained from /login endpoint.

Body

application/json

Connect init session data.

callback_uri
string
required

URI or deeplink to redirect customer's session after Connect completes.

Example:

"https://app.myapp.com/4623e56fc5c1"

direction
string
default:IMPORT

Indicates tariff direction you want to work with. Set to IMPORT or EXPORT.

Example:

"IMPORT"

type
string
default:COMMODITY

Indicates tariff type you want to work with. Set to COMMODITY or NON_COMMODITY.

Example:

"COMMODITY"

connect_web_uri
string

URI to redirect the customer’s session at the Handling Callback stage of the Provider login redirect step in the Connect flow. Specify the URI where Connect WebView is hosted, or a deeplink if native app is used.

Example:

"myapp://oauth-callback/flatpeak"

customer_id
string

Flatpeak customer_id. Connect will add or update the location for the customer ID you specified.

Example:

"cus_65e421d1daa4a24082b4f590"

customer_reference_id
string

An ID for the customer from your system. Supply when you want to create a customer with this reference.

Example:

"CUS0123456789"

location_id
string

Flatpeak location_id. Specify when you want to show the tariff summary to the customer. Connect will return tariff summary route objects enabling your customer to manage tariff connection for that location.

Example:

"loc_641b90b758fb8e6293716e40"

location_reference_id
string

An identifier for a location from your system. Use this reference when creating a new location in Flatpeak. You can only supply either location_id or location_reference but not both.

Example:

"LOC0123456789"

tariff_id
string

Flatpeak tariff_id. Specify when you want the customer to update a specific tariff element. Use this parameter after receiving tariff event type webhooks, such as when tariff has expired.

Example:

"trf_6597ef46529ab4467502af0b"

postal_address
object

Information on the postal address.

Response

Connect token object

connect_token
string

The connect_token.

Example:

"cot_65df3e949a785c52283026ec"

expires_in
integer

Expiration time in seconds.

Example:

86400

live_mode
boolean

Set to true if the object exists in live mode.