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

> Use this endpoint to create a new reconciliation context. Contexts are used to scope matching rules and organize your reconciliation configuration.



## OpenAPI

````yaml /en/openapi/v3-current/matcher.yaml post /v1/contexts
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:
    post:
      tags:
        - Configuration Contexts
      summary: Create a reconciliation context
      description: >-
        Use this endpoint to create a new reconciliation context. Contexts are
        used to scope matching rules and organize your reconciliation
        configuration.
      operationId: createContext
      parameters:
        - description: A unique identifier for tracing the request across services.
          in: header
          name: X-Request-Id
          schema:
            type: string
        - $ref: '#/components/parameters/XIdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateContextRequest'
        description: Context creation payload
        required: true
      responses:
        '201':
          description: >-
            Successfully created context.


            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/ReconciliationContextResponse'
          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'
        '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:
    CreateContextRequest:
      properties:
        name:
          example: Bank Reconciliation Q1
          maxLength: 100
          minLength: 1
          type: string
        type:
          allOf:
            - $ref: '#/components/schemas/ContextType'
          enum:
            - '1:1'
            - 1:N
            - N:M
          example: '1:1'
        interval:
          example: daily
          maxLength: 100
          minLength: 1
          type: string
        feeToleranceAbs:
          description: Absolute fee tolerance amount
          example: '0.01'
          type: string
        feeTolerancePct:
          description: Percentage fee tolerance
          example: '0.5'
          type: string
        feeNormalization:
          description: Fee normalization mode
          enum:
            - NET
            - GROSS
          example: NET
          type: string
        autoMatchOnUpload:
          description: Whether to trigger matching automatically after file upload
          example: false
          type: boolean
        sources:
          description: Optional list of sources to create inline with the context
          type: array
          maxItems: 10
          items:
            $ref: '#/components/schemas/CreateContextSourceRequest'
        rules:
          description: Optional list of match rules to create inline with the context
          type: array
          maxItems: 50
          items:
            type: object
            required:
              - priority
              - type
            properties:
              priority:
                description: Rule priority (lower number = higher priority)
                example: 1
                minimum: 1
                maximum: 1000
                type: integer
              type:
                description: Matching strategy type
                enum:
                  - EXACT
                  - TOLERANCE
                  - DATE_LAG
                example: EXACT
                type: string
              config:
                description: Rule-specific configuration
                additionalProperties: {}
                type: object
      required:
        - name
        - type
        - interval
      type: object
    ReconciliationContextResponse:
      description: Configuration context for matching rules
      properties:
        id:
          description: Unique identifier for the context
          example: 019c96a0-10a0-72d2-9fb0-2b7de8093182
          type: string
        tenantId:
          description: Tenant ID this context belongs to
          example: 019c96a0-0a98-7287-9a31-786e0809c769
          type: string
        name:
          description: Name of the reconciliation context
          example: Bank Reconciliation Q1
          type: string
        type:
          description: Reconciliation topology type
          enum:
            - '1:1'
            - 1:N
            - N:M
          example: '1:1'
          type: string
        interval:
          description: Execution interval
          example: daily
          type: string
        status:
          description: Current status of the context
          enum:
            - DRAFT
            - ACTIVE
            - PAUSED
            - ARCHIVED
          example: ACTIVE
          type: string
        feeToleranceAbs:
          description: Absolute fee tolerance amount
          example: '0.50'
          type: string
        feeTolerancePct:
          description: Percentage fee tolerance
          example: '0.01'
          type: string
        feeNormalization:
          description: Fee normalization mode
          enum:
            - NET
            - GROSS
          example: NET
          type: string
        autoMatchOnUpload:
          description: Whether matching triggers automatically after file upload
          example: false
          type: boolean
        createdAt:
          description: Creation timestamp in RFC3339 format
          example: '2025-01-15T10:30:00.000Z'
          type: string
        updatedAt:
          description: Last update timestamp in RFC3339 format
          example: '2025-01-15T10:30:00.000Z'
          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
    ContextType:
      description: Reconciliation topology (cardinality between sources)
      enum:
        - '1:1'
        - 1:N
        - N:M
      type: string
      x-enum-varnames:
        - ContextTypeOneToOne
        - ContextTypeOneToMany
        - ContextTypeManyToMany
    CreateContextSourceRequest:
      description: Request payload for creating a source inline with a context
      type: object
      properties:
        name:
          description: Source name
          example: Primary Bank Account
          maxLength: 50
          minLength: 1
          type: string
        type:
          description: Source type
          enum:
            - LEDGER
            - BANK
            - GATEWAY
            - CUSTOM
            - FETCHER
          example: BANK
          type: string
        side:
          description: Which side of the reconciliation this source represents
          enum:
            - LEFT
            - RIGHT
          example: LEFT
          type: string
        config:
          description: Source-specific configuration
          additionalProperties: {}
          type: object
        mapping:
          description: Optional field mapping for this source
          additionalProperties: {}
          type: object
      required:
        - name
        - side
        - type
  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}")'

````