> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flatpeak.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Connect token

> To start a Connect session, you must generate a connect_token. 

This single-use token securely authenticates the session between your customer-facing app and Connect’s HTTP endpoint, without exposing your main API keys.



## OpenAPI

````yaml api-reference/anode/flatpeak-api-spec-anode.json POST /connect/token
openapi: 3.0.3
info:
  description: Flatpeak API
  version: 2025-09-14.anode
  title: Flatpeak API
  termsOfService: https://flatpeak.com/legal
  contact:
    name: Technical Support
    email: support@flatpeak.com
    url: https://flatpeak.com/contact
  license:
    name: Apache 2.0
    url: https://flatpeak.com/legal
servers:
  - url: https://api.flatpeak.com
    description: Location
security: []
tags:
  - name: Consumption
    description: Consumption operations
  - name: Customers
    description: Customer operations
  - name: Devices
    description: Device operations
  - name: Meters
    description: Meter readings operations
  - name: Events
    description: Events operations
  - name: Login
    description: Bearer auth token operations
  - name: Connect
    description: Connect operations
  - name: Locations
    description: Location operations
  - name: Rates
    description: Rates operations
  - name: Costs
    description: Consumption cost calculations
  - name: Schedules
    description: Consumption schedules
  - name: Tariffs
    description: Tariff operations
  - name: Slots
    description: Slots operations
externalDocs:
  description: Location documentation
  url: https://docs.flatpeak.com
paths:
  /connect/token:
    parameters: []
    post:
      tags:
        - Connect
      summary: Create a Connect token
      description: >-
        To start a Connect session, you must generate a connect_token. 


        This single-use token securely authenticates the session between your
        customer-facing app and Connect’s HTTP endpoint, without exposing your
        main API keys.
      operationId: create-connect-token
      requestBody:
        $ref: '#/components/requestBodies/ConnectTokenCreate'
      responses:
        '200':
          $ref: '#/components/responses/ConnectTokenCreate'
        '403':
          $ref: '#/components/responses/403'
        '429':
          $ref: '#/components/responses/429'
      security:
        - bearerAuth: []
components:
  requestBodies:
    ConnectTokenCreate:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ConnectTokenCreate'
          examples: {}
  responses:
    '403':
      description: 403 forbidden
      content:
        application/json:
          schema:
            type: object
            x-examples:
              Example:
                message: Bad credentials
            properties:
              object:
                type: string
                example: error
                x-stoplight:
                  id: gria4ysjd9zhk
                default: error
              type:
                type: string
                x-stoplight:
                  id: 7mhtfljidnqcu
                example: invalid_request
                default: invalid_request
              code:
                type: string
                x-stoplight:
                  id: sy7ljpdy5wdes
                example: access_denied
                default: access_denied
              time_created:
                type: string
                x-stoplight:
                  id: 84d5biv9dfbc9
                format: date-time
                example: '2025-01-01T00:00:00Z'
            required:
              - object
              - type
              - code
          examples: {}
    '429':
      description: 429 Too many requests
      content:
        application/json:
          schema:
            type: object
            properties:
              object:
                type: string
                x-stoplight:
                  id: irkmp11gg6sjx
                example: error
                default: error
              type:
                type: string
                x-stoplight:
                  id: u0gq12cizam3d
                default: rate_limit
                example: rate_limit
              code:
                type: string
                x-stoplight:
                  id: uh7x9404d4w3q
                default: too_many_requests
                example: too_many_requests
              message:
                type: string
                x-stoplight:
                  id: 9z8h79l1coblc
                default: Too many requests. Please retry after a short delay.
                example: Too many requests. Please retry after a short delay.
              time_created:
                type: string
                x-stoplight:
                  id: ea7o3uvdojrtc
                format: date-time
                default: '2026-01-29T17:11:52Z'
                example: '2026-01-29T17:11:52Z'
            required:
              - object
              - type
              - code
              - message
    ConnectTokenCreate:
      description: Connect token object
      content:
        application/json:
          schema:
            type: object
            x-examples:
              Example:
                id: cot_6587fa4362341be5b524de3b
                object: connect_session
                data:
                  tariff_direction: IMPORT
                  tariff_type: COMMODITY
                  callback_url: https://webhook.site/4623e56fc5c1
                  connect_url: http://localhost:3000
                  customer_id: cus_65e421d1daa4a24082b4f590
                  customer_reference: CUS0123456789
                  location_id: loc_641b90b758fb8e6293716e40
                  location_reference: LOC0123456789
                  postal_address:
                    address_line1: 1-3
                    address_line2: Strand
                    city: London
                    state: Greater London
                    post_code: WC2N 5EH
                    country_code: GB
                time_created: '2023-05-05T18:37:27Z'
                time_expiry: '2023-05-05T19:37:27Z'
            properties:
              connect_token:
                type: string
                example: cot_65df3e949a785c52283026ec
                description: The `connect_token`.
                x-stoplight:
                  id: zx1xgwn7g440w
              expires_in:
                type: integer
                description: Expiration time in seconds.
                example: 86400
                x-stoplight:
                  id: heui29te7p3km
              live_mode:
                type: boolean
                description: Set to `true` if the object exists in live mode.
                x-stoplight:
                  id: pj6zzp8y0e6ir
  schemas:
    ConnectTokenCreate:
      type: object
      x-stoplight:
        id: 5zrqpzzr2yn7a
      x-examples: {}
      title: ConnectTokenCreate
      description: Connect init session data.
      properties:
        customer_id:
          type: string
          description: >-
            A Flatpeak `customer_id`. Connect will create or update the location
            for the customer ID you specified.
          example: cus_65e421d1daa4a24082b4f590
        customer_reference_id:
          type: string
          description: >-
            An ID for the customer from your system. Supply when you want to
            create a customer with this reference.
          example: CUS0123456789
          x-stoplight:
            id: 18wgwddn1nx5o
        location_id:
          type: string
          description: >-
            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:
          type: string
          description: >-
            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
          x-stoplight:
            id: fre78758p0zgb
        tariff_direction:
          type: string
          x-stoplight:
            id: ajjyhwmk2ox8y
          example: IMPORT
          default: IMPORT
          description: Tariff to apply. Set to `IMPORT`, `EXPORT` or `LOCAL`
        tariff_type:
          type: string
          x-stoplight:
            id: qowd8qqn1m6ae
          default: COMMODITY
          example: COMMODITY
          description: >-

            Indicates tariff type you want to work with. Set to `COMMODITY` or
            `NON_COMMODITY`.
        connect_url:
          type: string
          example: myapp://nova/flatpeak/connect
          x-stoplight:
            id: 0ne3molmrq5s0
          description: >-
            URL the customer is redirected to during the **Handling Callback**
            step of the [Provider Login
            Redirect](/api-reference/anode/connect/provider-login). Specify
            either the URL where your Connect web app is hosted or a deep link
            into your native app.
        callback_url:
          type: string
          example: myapp://nova/flatpeak/complete
          x-stoplight:
            id: 0ne3molmrq5s0
          description: >-
            URL where the customer is redirected after they complete or exit
            their Connect session.
        tariff_id:
          type: string
          description: >-
            Flatpeak `tariff_id`. Specify when you want the customer to update a
            specific tariff. Use this parameter after receiving tariff event
            type webhooks, such as when tariff has expired.
          example: trf_6597ef46529ab4467502af0b
          x-stoplight:
            id: geapz777q18hm
        actions:
          type: object
          x-stoplight:
            id: 9rsq8o7b5mnxw
          properties:
            disconnect_tariff:
              type: boolean
              x-stoplight:
                id: ncqgbyuo58uiq
              description: >-
                Disconnects tariff for given location and direction when set to
                `true`. Defaults to `false`.
              default: false
            edit_tariff:
              type: boolean
              x-stoplight:
                id: h2wb0yo4rjcg7
              description: >-
                Restarts connect flow from the Provider Selection page when set
                to `true`. Current tariff is not disconnected. Defaults to
                `false`.
        route_options:
          type: object
          x-stoplight:
            id: kosfzu6a1zf02
          properties:
            advanced_tariff_capture:
              type: boolean
              x-stoplight:
                id: yz0yke6cccj1z
              description: >-
                Enables `advanced_tariff_capture` route when set to `true`.
                Defaults to `false`.
              default: false
            tariff_name_capture:
              type: boolean
              x-stoplight:
                id: mqh7marrwr0mk
              description: >-
                Enables `tariff_name_capture` route when set to `true`. Defaults
                to `false`.
              default: false
            contract_term_capture:
              type: boolean
              x-stoplight:
                id: kpnqmibk13tnj
              description: >-
                Enables `contract_term_capture` route when set to `true`.
                Defaults to `false`.
              default: false
        postal_address_type:
          type: string
          example: RESIDENTIAL
          x-stoplight:
            id: j81xrsb2vkhz5
          description: 'Type of address. Accepted values: `RESIDENTIAL` or `COMMERCIAL`.'
        postal_address:
          $ref: '#/components/schemas/PostalAddress'
      required:
        - connect_url
        - callback_url
    PostalAddress:
      title: PostalAddress
      x-stoplight:
        id: c08e007sm4dhc
      type: object
      description: Information on the postal address.
      x-examples: {}
      properties:
        address_line1:
          type: string
          x-stoplight:
            id: y3w1smzzi7doq
          description: Address line 1 (e.g., street, PO Box, or company name).
          example: 1-3
        address_line2:
          type: string
          x-stoplight:
            id: d2a0gmwulev18
          description: Address line 2 (e.g., apartment, suite, unit, or building).
          example: Strand
        city:
          type: string
          x-stoplight:
            id: 6vwq2lw863yc5
          description: City, district, suburb, town, or village.
          example: London
        state:
          type: string
          x-stoplight:
            id: yjtu3ijseco94
          example: NSW
          description: >-
            State, county, province, or region. For
            [Australia](https://en.wikipedia.org/wiki/ISO_3166-2:AU),
            [Canada](https://en.wikipedia.org/wiki/ISO_3166-2:CA), and
            [US](https://en.wikipedia.org/wiki/ISO_3166-2:US), use ISO 3166-2
            state or province abbreviations (codes).
        post_code:
          type: string
          x-stoplight:
            id: 1styvjbg8556w
          description: ZIP or postal code.
          example: WC2N 5EH
        country_code:
          type: string
          x-stoplight:
            id: 53dqxz94xzzys
          description: >-
            Two-letter country code in [ISO 3166-1
            alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
          example: GB
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Authenticate with `bearer` you obtained from
        [authentication](/api-reference/anode/authentication) endpoint.

````