Skip to main content
POST
/
connect
/
token
Create a Connect token
curl --request POST \
  --url https://api.flatpeak.com/connect/token \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "customer_id": "cus_65e421d1daa4a24082b4f590",
  "customer_reference_id": "CUS0123456789",
  "location_id": "loc_641b90b758fb8e6293716e40",
  "location_reference_id": "LOC0123456789",
  "tariff_direction": "IMPORT",
  "tariff_type": "COMMODITY",
  "connect_url": "myapp://nova/flatpeak/connect",
  "callback_url": "myapp://nova/flatpeak/complete",
  "tariff_id": "trf_6597ef46529ab4467502af0b",
  "actions": {
    "disconnect_tariff": false,
    "edit_tariff": true
  },
  "route_options": {
    "advanced_tariff_capture": false,
    "tariff_name_capture": false,
    "contract_term_capture": false
  },
  "postal_address_type": "RESIDENTIAL",
  "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
}

Authorizations

Authorization
string
header
required

Authenticate with bearer you obtained from authentication endpoint.

Body

application/json

Connect init session data.

connect_url
string
required

URL the customer is redirected to during the Handling Callback step of the Provider Login Redirect. Specify either the URL where your Connect web app is hosted or a deep link into your native app.

Example:

"myapp://nova/flatpeak/connect"

callback_url
string
required

URL where the customer is redirected after they complete or exit their Connect session.

Example:

"myapp://nova/flatpeak/complete"

customer_id
string

A Flatpeak customer_id. Connect will create 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_direction
string
default:IMPORT

Tariff to apply. Set to IMPORT, EXPORT or LOCAL

Example:

"IMPORT"

tariff_type
string
default:COMMODITY

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

Example:

"COMMODITY"

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"

actions
object
route_options
object
postal_address_type
string

Type of address. Accepted values: RESIDENTIAL or COMMERCIAL.

Example:

"RESIDENTIAL"

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.