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

# Get a JWT

> Exchange an OAuth2 code or server credentials for a Mysoleas JWT.

This endpoint returns a Mysoleas JWT.

For a user sign-in, call it after `/oauth/v2/authorize` with the OAuth `code` and PKCE `code_verifier`. For a backend integration, use `client_credentials`.

Once you have the JWT, you can use it to open a session in your application, call `userinfo`, or consume gateway routes with `x-sp-auth-token`.


## OpenAPI

````yaml en/api-reference/openapi.json POST /oauth/v2/token
openapi: 3.1.0
info:
  title: Mysoleas API
  version: 3.0.0
  description: >-
    New Mysoleas architecture: business gateway, Mysoleas Identity Cloud, and
    SoleasPay ecosystem.
servers:
  - url: https://api.mysoleas.com
    description: Mysoleas gateway
  - url: https://account.mysoleas.com
    description: Mysoleas authentication
security:
  - spAuthToken: []
tags:
  - name: Identity Cloud
  - name: Plugin
  - name: Payment links
  - name: Subscriptions
  - name: Collections
  - name: Disbursements
  - name: Verification
  - name: Catalog
paths:
  /oauth/v2/token:
    post:
      tags:
        - Identity Cloud
      summary: Get a JWT
      description: >-
        Supports `authorization_code`, `client_credentials`, and
        `refresh_token`. The JWT can be used to open a session in your
        application, read `userinfo`, or call the gateway with
        `x-sp-auth-token`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OAuthTokenRequest'
            example:
              grant_type: client_credentials
              client_id: YOUR_CLIENT_ID
              client_secret: YOUR_CLIENT_SECRET
              scope: payments services countries providers
      responses:
        '200':
          description: Token genere
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthTokenResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security: []
      servers:
        - url: https://account.mysoleas.com
components:
  schemas:
    OAuthTokenRequest:
      type: object
      required:
        - grant_type
        - client_id
      properties:
        grant_type:
          type: string
          enum:
            - authorization_code
            - client_credentials
            - refresh_token
        client_id:
          type: string
        client_secret:
          type: string
        code:
          type: string
        redirect_uri:
          type: string
        code_verifier:
          type: string
        refresh_token:
          type: string
        scope:
          type: string
    OAuthTokenResponse:
      type: object
      properties:
        token_type:
          type: string
          example: Bearer
        expires_in:
          type: integer
          example: 3600
        access_token:
          type: string
        refresh_token:
          type: string
        id_token:
          type: string
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        code:
          type: integer
          example: 400
        message:
          type: string
          example: empty_data
        error:
          type: object
          properties:
            details:
              type:
                - object
                - array
                - string
                - 'null'
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Authentification invalide ou manquante
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    spAuthToken:
      type: apiKey
      in: header
      name: x-sp-auth-token
      description: >-
        JWT Bearer emis par Mysoleas Identity Cloud. Format: Bearer
        <access_token>.

````