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

# Generate connection token

> This endpoint lets you generate a connection token to authenticate a user without having to indicate its credentials. To be able to generate a connection token for a user, you need to have `WRITE` access on that user and that user cannot have `PROVIDER` role. A connection token is valid only once and has a time to live of maximum one day.




## OpenAPI

````yaml /assets/openapi/openapi-bundled.yaml post /connection/generate_token
openapi: 3.1.0
info:
  title: Partoo Rest API
  version: v2
  license:
    name: © Copyright Partoo
    url: https://www.partoo.co/en/gtu-api/
  x-logo:
    url: >-
      https://partoo-client-images.s3.amazonaws.com/logo-partoo-restapi-white.png
  description: >
    ## Introduction

    The Partoo Rest API allows you to automate all the actions that are possible
    to do in the Partoo Web Application.


    The Partoo Rest API can be used for many different purposes:
      - Create/update/delete your businesses & users if you are a client.
      - Create/subscribe/manage organizations, businesses & users if you are a reseller.
      - Retrieve data on businesses you have access to if you are a publisher.
      - ...
servers:
  - url: https://api.partoo.co/v2
    description: Production server
  - url: https://api.sandbox.partoo.co/v2
    description: Sandbox server (dev environment for clients & partners)
security:
  - ApiKeyAuth: []
paths:
  /connection/generate_token:
    post:
      tags:
        - Connection Tokens
      summary: Generate connection token
      description: >
        This endpoint lets you generate a connection token to authenticate a
        user without having to indicate its credentials. To be able to generate
        a connection token for a user, you need to have `WRITE` access on that
        user and that user cannot have `PROVIDER` role. A connection token is
        valid only once and has a time to live of maximum one day.
      operationId: generateConnectionToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - user_id
              properties:
                user_id:
                  $ref: '#/components/schemas/UserId'
                ttl:
                  type: integer
                  maximum: 86400
                  default: 86400
                  example: 3600
                  description: Token time to live in seconds. It can be maximum 1 day.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  token:
                    description: New connection token
                    type: string
                    example: \xaf3e8951c1f4c42f9cc53116b3fc855bd44bce01cf27604b
                  expiration_date:
                    type: string
                    description: Expiration date of the newly created token
                    format: date-time
                    example: '2019-08-01T19:15:54.256000+02:00'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
components:
  schemas:
    UserId:
      description: User id
      type: string
      example: 5309c3a237bbc544d8e26737
  responses:
    '400':
      description: Your request is incorrect
      content:
        application/json:
          schema:
            description: |
              Error that occcurs when your request is incorrect
            properties:
              errors:
                type: object
                description: The detail of the error encountered
                properties:
                  json:
                    type: object
    '401':
      description: You are not authenticated
      content:
        application/json:
          schema:
            description: Error that occurs when you are not authenticated
            type: object
            properties:
              errors:
                type: object
                description: The detail of the error encountered
                properties:
                  authentication:
                    type: string
                    default: User not authenticated
    '403':
      description: |
        You are not allowed to perform this action
      content:
        application/json:
          schema:
            description: >
              Error that occurs when you are authenticated but you are trying to
              perform an action you are not allowed to perform
            type: object
            properties:
              errors:
                type: object
                description: The detail of the error encountered
                properties:
                  authorization:
                    type: string
                    default: Operation not allowed
    '404':
      description: Resource does not exist
      content:
        application/json:
          schema:
            description: >-
              Error that occcurs when you are trying to reach a resource that
              does not exist
            type: object
            properties:
              errors:
                type: object
                description: The detail of the error encountered
                properties:
                  json:
                    type: string
                    default: Resource not found
  securitySchemes:
    ApiKeyAuth:
      description: >
        The authentication system on Partoo API is using API Key that should be
        put in the header of the request (the name of the header is `x-APIKey`).
        An api_key is linked to a user. This user's role will give you different
        access level to the API features.
      type: apiKey
      in: header
      name: x-APIKey

````