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

# Connect provider via OAuth2 authorization code

> Exchanges an OAuth2 authorization code for access/refresh tokens to enable provider API access for the tenant.



## OpenAPI

````yaml en/openapi/v3-current/payments.yaml post /v1/admin/providers/connect
openapi: 3.0.3
info:
  title: Payments — via BTG API
  description: >-
    API for the Lerian Payments interface via BTG. It covers boleto issuance,
    cancellation, installments, and queries; bill payments (bankslip, utilities,
    and DARF), cancellation, and queries; aggregated boleto and payment
    dashboards; provider connection and outbound webhook configuration; and the
    provider webhook receiver for settlement events.
  version: v1.0.0
servers:
  - url: https://payments.sandbox.lerian.net
security: []
tags:
  - name: Health
    description: Service health and readiness endpoints
  - name: Boletos
    description: Boleto issuance, cancellation, installments, and queries
  - name: Payments
    description: Bill payments (bankslip, utilities, DARF), cancellation, and queries
  - name: Dashboards
    description: Aggregated metrics and dashboards for boletos and payments
  - name: Admin
    description: Administrative endpoints for webhook configuration
  - name: Webhooks
    description: Provider webhook receiver for settlement events
paths:
  /v1/admin/providers/connect:
    post:
      tags:
        - Admin
      summary: Connect provider via OAuth2 authorization code
      description: >-
        Exchanges an OAuth2 authorization code for access/refresh tokens to
        enable provider API access for the tenant.
      parameters:
        - description: Tenant organization ID
          in: header
          name: X-Organization-Id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/http.ProviderConnectRequest'
        description: OAuth2 authorization code and redirect URI
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/http.ProviderConnectResponse'
        '400':
          description: Missing code or redirect_uri
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pluginerrors.ErrorResponse'
        '404':
          description: Tenant has no client_id/client_secret synced
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pluginerrors.ErrorResponse'
        '422':
          description: >-
            Provider setup incomplete: company_id could not be resolved from the
            organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pluginerrors.ErrorResponse'
        '502':
          description: Provider token exchange failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pluginerrors.ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    http.ProviderConnectRequest:
      properties:
        code:
          type: string
        redirect_uri:
          type: string
      type: object
    http.ProviderConnectResponse:
      properties:
        company_id:
          type: string
        provider_type:
          type: string
        status:
          type: string
      type: object
    pluginerrors.ErrorResponse:
      properties:
        code:
          example: PBP-0001
          type: string
        details:
          additionalProperties: {}
          type: object
        message:
          example: dueDate must be in YYYY-MM-DD format
          type: string
        title:
          example: Bad Request
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      description: 'Bearer token authentication (format: "Bearer {token}")'
      in: header
      name: Authorization
      type: apiKey

````