> ## 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 a reconciliation source

> Use this endpoint to create a new reconciliation source under a specific context. Sources define where transaction data comes from for reconciliation.



## OpenAPI

````yaml /en/openapi/v3-current/matcher.yaml post /v1/contexts/{contextId}/sources
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: v2.1.1
  license:
    name: Elastic License 2.0
    url: https://www.elastic.co/licensing/elastic-license
servers:
  - url: https://matcher.sandbox.lerian.net
security: []
paths:
  /v1/contexts/{contextId}/sources:
    post:
      tags:
        - Configuration Sources
      summary: Create a reconciliation source
      description: >-
        Use this endpoint to create a new reconciliation source under a specific
        context. Sources define where transaction data comes from for
        reconciliation.
      operationId: createSource
      parameters:
        - description: A unique identifier for tracing the request across services.
          in: header
          name: X-Request-Id
          schema:
            type: string
        - description: The unique identifier of the reconciliation context.
          in: path
          name: contextId
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/XIdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSourceRequest'
        description: Source creation payload
        required: true
      responses:
        '201':
          description: >-
            Successfully created source.


            The response includes the `X-Idempotency-Replayed` header.


            If the value is false, the request was just processed. If the value
            is true, the response is a replay of a previously processed request.


            See [Retries and idempotency](/en/reference/retries-idempotency) for
            more details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReconciliationSourceResponse'
          headers:
            X-Idempotency-Replayed:
              $ref: '#/components/headers/XIdempotencyReplayed'
        '400':
          description: Invalid request payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: The request lacks valid authentication credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: You do not have permission to access this resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Context not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: 'Idempotency conflict: request with same key in progress'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  parameters:
    XIdempotencyKey:
      name: X-Idempotency-Key
      in: header
      required: false
      description: >-
        Optional idempotency key for safe retries. Also accepts
        `Idempotency-Key` as an alternative header name. If the same key is sent
        again and the original request was already processed, the cached
        response is returned with `X-Idempotency-Replayed: true`.


        See [Retries and idempotency](/en/reference/retries-idempotency) for
        details.
      schema:
        type: string
  schemas:
    CreateSourceRequest:
      properties:
        name:
          example: Primary Bank Account
          maxLength: 50
          minLength: 1
          type: string
        type:
          allOf:
            - $ref: '#/components/schemas/SourceType'
          enum:
            - LEDGER
            - BANK
            - GATEWAY
            - CUSTOM
            - FETCHER
          example: BANK
        side:
          description: Side of the reconciliation this source feeds
          enum:
            - LEFT
            - RIGHT
          example: LEFT
          type: string
        config:
          additionalProperties: {}
          type: object
        feeScheduleId:
          description: Fee schedule identifier to associate with this source
          example: 019c96a0-2b20-7123-9a1b-2c3d4e5f6a7b
          format: uuid
          type: string
      required:
        - name
        - side
        - type
      type: object
    ReconciliationSourceResponse:
      properties:
        id:
          type: string
        contextId:
          type: string
        name:
          type: string
        type:
          $ref: '#/components/schemas/SourceType'
        side:
          description: Side of the reconciliation this source feeds
          enum:
            - LEFT
            - RIGHT
          type: string
        config:
          additionalProperties: {}
          type: object
        feeScheduleId:
          type: string
          format: uuid
        createdAt:
          type: string
        updatedAt:
          type: string
      type: object
    ErrorResponse:
      description: Standard error response returned by all API endpoints
      type: object
      required:
        - code
        - title
        - message
      properties:
        code:
          type: string
          description: HTTP status code as a string.
          example: '404'
        title:
          type: string
          description: Error type identifier.
          example: not_found
        message:
          type: string
          description: Human-readable error message with details.
          example: context not found
        error:
          type: string
          description: Deprecated. Error message for backward compatibility.
          deprecated: true
        details:
          description: Additional error context as key-value pairs
          additionalProperties: {}
          type: object
    SourceType:
      description: Category of data source for reconciliation
      enum:
        - LEDGER
        - BANK
        - GATEWAY
        - CUSTOM
        - FETCHER
      type: string
      x-enum-varnames:
        - SourceTypeLedger
        - SourceTypeBank
        - SourceTypeGateway
        - SourceTypeCustom
        - SourceTypeFetcher
  headers:
    XIdempotencyReplayed:
      description: >-
        Indicates whether this response was served from the idempotency cache.
        When `true`, the response is a replay of the original request with the
        same idempotency key.


        See [Retries and idempotency](/en/reference/retries-idempotency) for
        details.
      schema:
        type: boolean
      example: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Bearer token authentication (format: "Bearer {token}")'

````