> ## 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

> In order to launch a session with Connect, you need a `connect_token`. 

This single-use object securely authenticates a session between your customer-facing app and Connect’s HTTP service endpoint — without exposing your main API keys.

<Tip>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.</Tip>


## OpenAPI

````yaml api-reference/zero/flatpeak-api-spec-zero.json POST /connect/tariff/token
openapi: 3.0.3
info:
  description: Flatpeak API
  version: 2024-08-24.zero
  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/tariff/token:
    parameters: []
    post:
      tags:
        - Connect
      summary: Create a connect token
      description: >-
        In order to launch a session with Connect, you need a `connect_token`. 


        This single-use object securely authenticates a session between your
        customer-facing app and Connect’s HTTP service endpoint — without
        exposing your main API keys.
      operationId: create-connect-token
      requestBody:
        $ref: '#/components/requestBodies/ConnectInitTariff'
      responses:
        '200':
          $ref: '#/components/responses/ConnectInitTariff'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
      security:
        - bearerAuth: []
components:
  requestBodies:
    ConnectInitTariff:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ConnectInitTariff'
          examples: {}
  responses:
    '403':
      description: 403 bad credentials
      content:
        application/json:
          schema:
            type: object
            x-examples:
              Example:
                message: Bad credentials
            properties:
              message:
                type: string
                example: Bad credentials
          examples: {}
    '500':
      description: 500 error
      content:
        application/json:
          schema:
            type: object
            x-examples:
              '':
                message: Internal Server Error
            properties:
              message:
                type: string
                example: Internal Server Error
          examples: {}
    ConnectInitTariff:
      description: Connect token object
      content:
        application/json:
          schema:
            type: object
            x-examples:
              Example:
                id: cot_6587fa4362341be5b524de3b
                object: connect_session
                data:
                  direction: IMPORT
                  type: COMMODITY
                  callback_uri: https://webhook.site/4623e56fc5c1
                  connect_web_uri: 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:
    ConnectInitTariff:
      type: object
      x-stoplight:
        id: 5zrqpzzr2yn7a
      x-examples: {}
      title: ConnectInitTariff
      description: Connect init session data.
      properties:
        direction:
          type: string
          x-stoplight:
            id: ajjyhwmk2ox8y
          example: IMPORT
          default: IMPORT
          description: >-
            Indicates tariff direction you want to work with. Set to `IMPORT` or
            `EXPORT`.
        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`.
        callback_uri:
          type: string
          description: >-
            URI or deeplink to redirect customer's session after Connect
            completes.
          example: https://app.myapp.com/4623e56fc5c1
        connect_web_uri:
          type: string
          description: >-
            URI to redirect the customer’s session at the **Handling Callback**
            stage of the [Provider login
            redirect](/api-reference/zero/connect/provider-login) 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:
          type: string
          description: >-
            Flatpeak `customer_id`. Connect will add 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
          example: loc_641b90b758fb8e6293716e40
          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.
        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_id:
          type: string
          description: >-
            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
          x-stoplight:
            id: geapz777q18hm
        postal_address:
          $ref: '#/components/schemas/PostalAddress'
      required:
        - callback_uri
    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_token` you obtained from
        [/login](/api-reference/zero/login/create-a-bearer-token) endpoint.

````