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

# Trigger a matching run

> Use this endpoint to trigger a matching run for a reconciliation context. You can use DRY_RUN mode to test rules without committing results, or COMMIT mode to persist matches.



## OpenAPI

````yaml /pt/openapi/v3-current/matcher.yaml post /v1/matching/contexts/{contextId}/run
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.4
  license:
    name: Lerian Studio General License
servers:
  - url: https://matcher.sandbox.lerian.net
security: []
paths:
  /v1/matching/contexts/{contextId}/run:
    post:
      tags:
        - Matching
      summary: Trigger a matching run
      description: >-
        Use this endpoint to trigger a matching run for a reconciliation
        context. You can use DRY_RUN mode to test rules without committing
        results, or COMMIT mode to persist matches.
      operationId: runMatch
      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:
            description: Reconciliation context ID
            format: uuid
            type: string
        - $ref: '#/components/parameters/XIdempotency'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunMatchRequest'
        description: Run match payload
        required: true
      responses:
        '202':
          description: Indicates that the request was accepted for processing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunMatchResponse'
          headers:
            X-Idempotency-Replayed:
              $ref: '#/components/headers/XIdempotencyReplayed'
        '400':
          description: The request contains invalid parameters or payload.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0401-no-sources-configured-for-context:
                  $ref: >-
                    #/components/examples/mtch-0401-no-sources-configured-for-context
                mtch-0402-at-least-two-sources-are-required:
                  $ref: >-
                    #/components/examples/mtch-0402-at-least-two-sources-are-required
                mtch-0404-1-1-contexts-require-exactly-one-source-per-side:
                  $ref: >-
                    #/components/examples/mtch-0404-1-1-contexts-require-exactly-one-source-per-side
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            You do not have permission to access this resource, or the context
            is not active.
          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
                mtch-0012-context-is-not-active:
                  $ref: '#/components/examples/mtch-0012-context-is-not-active'
        '404':
          description: The requested resource was not found.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0005-context-not-found:
                  $ref: '#/components/examples/mtch-0005-context-not-found'
        '409':
          description: Another match run is already in progress for this context.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0408-another-match-run-is-already-in-progress-for-this-context:
                  $ref: >-
                    #/components/examples/mtch-0408-another-match-run-is-already-in-progress-for-this-context
        '422':
          description: The request was well-formed but contains semantic errors.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0406-fee-normalization-is-enabled-but-no-fee-rules-are-configured:
                  $ref: >-
                    #/components/examples/mtch-0406-fee-normalization-is-enabled-but-no-fee-rules-are-configured
                mtch-0407-fee-rules-are-misconfigured-for-this-context:
                  $ref: >-
                    #/components/examples/mtch-0407-fee-rules-are-misconfigured-for-this-context
                422-validation-failed:
                  $ref: '#/components/examples/422-validation-failed'
        '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-0008-internal-error:
                  $ref: '#/components/examples/mtch-0008-internal-error'
      security:
        - BearerAuth: []
components:
  parameters:
    XIdempotency:
      name: X-Idempotency
      in: header
      required: false
      description: >-
        Optional idempotency key for safe retries. Matcher reads the key only
        from this header, and only when you send one. A request that carries a
        key only in `X-Idempotency-Key` or `Idempotency-Key` is refused with
        `400` (`MTCH-0015`), and nothing is processed. If the same key is sent
        again and the original request was already processed, the stored
        response is returned with `X-Idempotency-Replayed: true`. A malformed
        key returns `400`, a key whose first request is still in progress
        returns `409`, and an idempotency storage failure returns `500`. These
        refusals are problem documents.
      schema:
        type: string
  schemas:
    RunMatchRequest:
      additionalProperties: false
      properties:
        async:
          description: >-
            Submit asynchronously: when true the run is queued (status QUEUED)
            and executed by the worker; when false/omitted the run executes
            in-request and the response carries the completed run (terminal
            status). Both paths return HTTP 202; distinguish by the response
            status. Poll GET /v1/matching/runs/{runId} for async progress.
          examples:
            - false
          type: boolean
        mode:
          description: Execution mode
          enum:
            - DRY_RUN
            - COMMIT
          examples:
            - DRY_RUN
          type: string
      required:
        - mode
      type: object
    RunMatchResponse:
      additionalProperties: false
      properties:
        runId:
          description: Identifier of the match run that was triggered
          examples:
            - 550e8400-e29b-41d4-a716-446655440000
          format: uuid
          type: string
        status:
          description: >-
            Status of the run at acceptance: QUEUED (async submit, awaiting
            worker pickup), COMPLETED (finished synchronously), or FAILED
            (errored synchronously). A synchronous run is already terminal; an
            async run is QUEUED. Poll GET /v1/matching/runs/{runId} for async
            progress (PROCESSING/FINALIZING/COMPLETED)
          enum:
            - QUEUED
            - COMPLETED
            - FAILED
          examples:
            - COMPLETED
          type: string
      required:
        - runId
        - status
      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
    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
    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
    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
  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.
      schema:
        type: boolean
    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
  examples:
    mtch-0401-no-sources-configured-for-context:
      summary: No sources configured for context
      value:
        type: https://errors.lerian.studio/v1/MTCH-0401
        title: Bad Request
        status: 400
        detail: >-
          This context has no sources configured; no match run was created for
          this request. Add at least two sources to the context, then run the
          match again.
        code: MTCH-0401
    mtch-0402-at-least-two-sources-are-required:
      summary: At least two sources are required
      value:
        type: https://errors.lerian.studio/v1/MTCH-0402
        title: Bad Request
        status: 400
        detail: at least two sources are required
        code: MTCH-0402
    mtch-0404-1-1-contexts-require-exactly-one-source-per-side:
      summary: 1:1 contexts require exactly one source per side
      value:
        type: https://errors.lerian.studio/v1/MTCH-0404
        title: Bad Request
        status: 400
        detail: 1:1 contexts require exactly one source per side
        code: MTCH-0404
    mtch-0012-context-is-not-active:
      summary: Context is not active
      value:
        type: https://errors.lerian.studio/v1/MTCH-0012
        title: Forbidden
        status: 403
        detail: context is not active
        code: MTCH-0012
    mtch-0005-context-not-found:
      summary: Context not found
      value:
        type: https://errors.lerian.studio/v1/MTCH-0005
        title: Not Found
        status: 404
        detail: >-
          No reconciliation context matches this id; check the context id and
          try again.
        code: MTCH-0005
    mtch-0408-another-match-run-is-already-in-progress-for-this-context:
      summary: Another match run is already in progress for this context
      value:
        type: https://errors.lerian.studio/v1/MTCH-0408
        title: Conflict
        status: 409
        detail: >-
          Another match run is already in progress for this context; no match
          run was created for this request. Wait for the current run to finish,
          then retry.
        code: MTCH-0408
    mtch-0406-fee-normalization-is-enabled-but-no-fee-rules-are-configured:
      summary: >-
        Fee normalization is enabled but no fee rules are configured for this
        context
      value:
        type: https://errors.lerian.studio/v1/MTCH-0406
        title: Unprocessable Entity
        status: 422
        detail: >-
          fee normalization is enabled but no fee rules are configured for this
          context
        code: MTCH-0406
    mtch-0407-fee-rules-are-misconfigured-for-this-context:
      summary: Fee rules are misconfigured for this context
      value:
        type: https://errors.lerian.studio/v1/MTCH-0407
        title: Unprocessable Entity
        status: 422
        detail: >-
          This context's fee rules are misconfigured (too many fee rules, or a
          rule references a fee schedule that no longer exists); no match run
          was created for this request. Ask an administrator to check the
          context's fee rule configuration.
        code: MTCH-0407
    422-validation-failed:
      summary: Validation failed
      value:
        title: Unprocessable Entity
        status: 422
        detail: validation failed
    mtch-0008-internal-error:
      summary: Service Unavailable
      value:
        type: https://errors.lerian.studio/v1/MTCH-0008
        title: Service Unavailable
        status: 503
        detail: internal error
        code: MTCH-0008
  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
    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
  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.