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

# Create REST discovery connection

> Use this endpoint to create a REST connection to a payment provider: PagBank, Stripe, or Pix BCB. The credential fields each connector type requires are listed as `requiredFields` on GET /v1/discovery/connector-types. An optional `baseURL` replaces the default provider address for this connection. After you create it, the connection appears in GET /v1/discovery/connections; an update to a REST connection accepts only `configName`.



## OpenAPI

````yaml /en/openapi/v3-current/matcher.yaml post /v1/discovery/rest-connections
openapi: 3.1.0
info:
  title: Matcher APIs
  description: >-
    Complete API reference for the Matcher reconciliation engine, providing
    automated transaction matching between Midaz Ledger and external systems.
  version: 5.0.3
  license:
    name: Lerian Studio General License
servers:
  - url: https://matcher.sandbox.lerian.net
security: []
paths:
  /v1/discovery/rest-connections:
    post:
      tags:
        - Discovery
      summary: Create REST discovery connection
      description: >-
        Use this endpoint to create a REST connection to a payment provider:
        PagBank, Stripe, or Pix BCB. The credential fields each connector type
        requires are listed as `requiredFields` on GET
        /v1/discovery/connector-types. An optional `baseURL` replaces the
        default provider address for this connection. After you create it, the
        connection appears in GET /v1/discovery/connections; an update to a REST
        connection accepts only `configName`.
      operationId: createRESTDiscoveryConnection
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RESTConnectionRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionResponse'
          description: Created
        '400':
          description: The request contains invalid parameters or payload.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0001-rest-credential-field-is-required:
                  $ref: >-
                    #/components/examples/mtch-0001-rest-credential-field-is-required
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '503':
          description: The service is temporarily unavailable. Please try again later.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0203-internal-error:
                  $ref: '#/components/examples/mtch-0203-internal-error'
      security:
        - BearerAuth: []
components:
  schemas:
    RESTConnectionRequest:
      additionalProperties: false
      properties:
        apiKey:
          description: Stripe restricted API key
          maxLength: 512
          type: string
        baseURL:
          description: >-
            Optional per-connection API base URL (http/https); when omitted the
            deployment default for the connector type is used
          examples:
            - https://sandbox.provider.example
          format: uri
          maxLength: 2048
          type: string
        clientCert:
          description: PEM-encoded Pix client certificate
          maxLength: 8192
          type: string
        clientID:
          description: Pix OAuth2 client id
          maxLength: 512
          type: string
        clientKey:
          description: PEM-encoded Pix client private key
          maxLength: 8192
          type: string
        clientSecret:
          description: Pix OAuth2 client secret
          maxLength: 512
          type: string
        configName:
          description: Unique connection config name (tenant-scoped)
          examples:
            - pagbank-prod
          maxLength: 255
          minLength: 1
          type: string
        connectorType:
          description: REST connector type this connection serves
          enum:
            - PAGBANK
            - STRIPE
            - PIX_BCB
          examples:
            - PAGBANK
          minLength: 1
          type: string
        ediToken:
          description: PagBank EDI token
          maxLength: 512
          type: string
        establishmentID:
          description: PagBank establishment id
          maxLength: 512
          type: string
      required:
        - configName
        - connectorType
      type: object
    ConnectionResponse:
      additionalProperties: false
      properties:
        baseURL:
          description: >-
            Per-connection API base URL of a REST connector connection; absent
            when the deployment default applies and for database connectors
          examples:
            - https://sandbox.provider.example
          format: uri
          type: string
        configName:
          description: Connection configuration name
          examples:
            - prod-ledger-db
          type: string
        databaseName:
          description: Database name
          examples:
            - ledger
          type: string
        databaseType:
          description: Database engine type (canonical engine token as stored)
          examples:
            - POSTGRESQL
          type: string
        host:
          description: >-
            Database host; empty for REST connector connections, whose service
            address is reported as baseURL
          examples:
            - db.internal.example.com
          type: string
        id:
          description: Internal Matcher connection identifier
          examples:
            - 3fa85f64-5717-4562-b3fc-2c963f66afa6
          type: string
        lastSeenAt:
          description: Timestamp the connection was last observed healthy (RFC 3339)
          examples:
            - '2026-06-17T14:32:05Z'
          format: date-time
          type: string
        port:
          description: Database port
          examples:
            - 5432
          format: int64
          type: integer
        schema:
          description: Schema/namespace within the database, when set
          examples:
            - public
          type: string
        schemaDiscovered:
          description: Whether table schemas have been discovered for this connection
          type: boolean
        status:
          description: >-
            Current lifecycle status of the connection as reported by the
            extraction engine
          examples:
            - available
          type: string
        userName:
          description: Database user name the connection authenticates as
          examples:
            - matcher_ro
          type: string
      required:
        - id
        - configName
        - databaseType
        - host
        - port
        - databaseName
        - userName
        - status
        - schemaDiscovered
        - lastSeenAt
      type: object
    Detail:
      additionalProperties: false
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          examples:
            - ERR-0001
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    Upstream:
      additionalProperties: false
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
    ErrorResponse:
      description: >-
        Flat error body that Matcher returns when it refuses a request before
        the operation runs.
      type: object
      required:
        - code
        - title
        - message
      properties:
        code:
          type: string
          description: Stable error code.
          example: MTCH-0003
        title:
          type: string
          description: HTTP status text.
          example: Unauthorized
        message:
          type: string
          description: Human-readable error message.
          example: missing authorization token
    RateLimitErrorResponse:
      description: >-
        Flat body that the rate limiter returns. `code` is the HTTP status as a
        number.
      type: object
      required:
        - code
        - title
        - message
      properties:
        code:
          type: integer
          description: HTTP status code.
          example: 429
        title:
          type: string
          description: Error type.
          example: rate_limit_exceeded
        message:
          type: string
          description: Human-readable error message.
          example: rate limit exceeded
  examples:
    mtch-0001-rest-credential-field-is-required:
      summary: Required credential field missing
      value:
        type: https://errors.lerian.studio/v1/MTCH-0001
        title: Bad Request
        status: 400
        detail: >-
          This connector type requires a credential field that the request does
          not supply; no connection was created. Supply every credential field
          this connector type requires and try again.
        code: MTCH-0001
        errors:
          - location: credential.apiKey
            message: this credential field is required for the requested connector type
    mtch-0203-internal-error:
      summary: Service Unavailable
      value:
        type: https://errors.lerian.studio/v1/MTCH-0203
        title: Service Unavailable
        status: 503
        detail: >-
          Source connectivity is temporarily unavailable; retry the request,
          then ask an administrator to check the discovery service if the
          failure continues.
        code: MTCH-0203
  responses:
    Unauthorized:
      description: The request lacks valid authentication credentials.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Detail'
          examples:
            MissingToken:
              summary: Missing token
              value:
                type: https://errors.lerian.studio/v1/MTCH-0003
                title: Unauthorized
                status: 401
                detail: missing authorization token
                code: MTCH-0003
            InvalidToken:
              summary: Invalid token
              value:
                type: https://errors.lerian.studio/v1/MTCH-0003
                title: Unauthorized
                status: 401
                detail: invalid authorization token
                code: MTCH-0003
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
        text/plain:
          schema:
            type: string
          example: Unauthorized
    Forbidden:
      description: You do not have permission to access this resource.
      content:
        text/plain:
          schema:
            type: string
          example: Forbidden
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Detail'
          examples:
            TenantClaimRequired:
              summary: Tenant claim missing
              value:
                type: https://errors.lerian.studio/v1/MTCH-0004
                title: Forbidden
                status: 403
                detail: tenant claim required
                code: MTCH-0004
    ValidationFailed:
      description: >-
        The request failed validation. The `errors` list names each value that
        failed.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Detail'
          example:
            title: Unprocessable Entity
            status: 422
            detail: validation failed
            errors:
              - message: expected required property name to be present
                location: body
    TooManyRequests:
      description: >-
        The request exceeded the rate limit. Wait the number of seconds in
        `Retry-After`, then retry.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
        X-RateLimit-Limit:
          $ref: '#/components/headers/XRateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/XRateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/XRateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitErrorResponse'
          example:
            code: 429
            title: rate_limit_exceeded
            message: rate limit exceeded
    InternalServerError:
      description: An unexpected error occurred on the server.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Detail'
          example:
            type: https://errors.lerian.studio/v1/MTCH-0002
            title: Internal Server Error
            status: 500
            detail: internal error
            code: MTCH-0002
        text/plain:
          schema:
            type: string
          example: Internal Server Error
  headers:
    RetryAfter:
      description: Seconds to wait before you retry.
      schema:
        type: integer
        example: 30
    XRateLimitLimit:
      description: Requests allowed in the current window.
      schema:
        type: integer
        example: 100
    XRateLimitRemaining:
      description: Requests left in the current window. Always `0` on a `429`.
      schema:
        type: integer
        example: 0
    XRateLimitReset:
      description: Unix time, in seconds, when the current window resets.
      schema:
        type: integer
        example: 1767225600
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: 'Bearer token authentication (format: "Bearer {token}")'
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.