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

# Update a reconciliation context

> Use this endpoint to update the fields of a specific reconciliation context by its identifier. Setting `status` to `ACTIVE` is refused with `409` while the context is not ready for activation. A `signConvention` change is refused with `409` once the context has carried a partial balance, or while a match run is in progress.



## OpenAPI

````yaml /pt/openapi/v3-current/matcher.yaml patch /v1/contexts/{contextId}
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: 6.1.0
  license:
    name: Lerian Studio General License
servers:
  - url: https://matcher.sandbox.lerian.net
security: []
paths:
  /v1/contexts/{contextId}:
    patch:
      tags:
        - Configuration Contexts
      summary: Update a reconciliation context
      description: >-
        Use this endpoint to update the fields of a specific reconciliation
        context by its identifier. Setting `status` to `ACTIVE` is refused with
        `409` while the context is not ready for activation. A `signConvention`
        change is refused with `409` once the context has carried a partial
        balance, or while a match run is in progress.
      operationId: updateContext
      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: Context ID
            format: uuid
            type: string
        - $ref: '#/components/parameters/XIdempotency'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateContextRequest'
        description: Context updates
        required: true
      responses:
        '200':
          description: Successfully updated context.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReconciliationContextResponse'
          headers:
            X-Idempotency-Replayed:
              $ref: '#/components/headers/XIdempotencyReplayed'
        '400':
          description: Invalid request payload
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0001-context-name-is-required:
                  $ref: '#/components/examples/mtch-0001-context-name-is-required'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Context not found
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0110-context-not-found:
                  $ref: '#/components/examples/mtch-0110-context-not-found'
        '409':
          description: The request conflicts with the current state of the context.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                mtch-0101-a-reconciliation-context-with-this-name-already-exists:
                  $ref: >-
                    #/components/examples/mtch-0101-a-reconciliation-context-with-this-name-already-exists--patch-v1-contexts-contextid
                mtch-0103-cannot-pause-context-in-draft-status-invalid-state-transitio:
                  $ref: >-
                    #/components/examples/mtch-0103-cannot-pause-context-in-draft-status-invalid-state-transitio
                mtch-0104-archived-context-cannot-be-modified:
                  $ref: >-
                    #/components/examples/mtch-0104-archived-context-cannot-be-modified
                mtch-0103-context-is-not-ready-for-activation:
                  $ref: >-
                    #/components/examples/mtch-0103-context-is-not-ready-for-activation
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
      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` (`MTCH-0018`), a key whose earlier attempt already ran but
        whose answer cannot be replayed returns `409` (`MTCH-0022`), and an
        idempotency storage failure returns `500`. POST, PUT, PATCH and DELETE
        requests accept the header. These refusals are problem documents.
      schema:
        type: string
  schemas:
    UpdateContextRequest:
      additionalProperties: false
      properties:
        agedBreakCalendar:
          description: >-
            Business-day calendar the aging threshold is measured against. Empty
            string clears it (raw calendar days); omit to leave it unchanged.
          examples:
            - BR_ANBIMA
          type: string
        agedBreakThresholdDays:
          description: >-
            Open-item aging SLA in business days. A positive value
            enables/changes aging; 0 disables it (clears the threshold); omit to
            leave it unchanged.
          examples:
            - 30
          format: int64
          type: integer
        autoMatchOnUpload:
          description: >-
            When true, a match run is triggered automatically after a file
            upload completes.
          examples:
            - true
          type: boolean
        feeNormalization:
          description: >-
            Fee normalization mode. NET compares amounts after fees are
            deducted; GROSS compares amounts before fees. Send an empty string
            to clear the mode; omit to leave it unchanged. (No enum constraint:
            unlike create, the update path accepts the empty string to clear.)
          examples:
            - NET
          type: string
        feeToleranceAbs:
          description: Absolute fee tolerance as a decimal string in the context currency.
          examples:
            - '0.01'
          type: string
        feeTolerancePct:
          description: >-
            Fee tolerance in percent, as a decimal string: 0.5 means 0.5%, not
            50%.
          examples:
            - '0.5'
          type: string
        interval:
          description: Execution interval label for the context (e.g. daily, weekly).
          examples:
            - weekly
          maxLength: 100
          type: string
        name:
          description: New human-readable name of the reconciliation context.
          examples:
            - Bank Reconciliation Q2
          maxLength: 100
          type: string
        signConvention:
          description: >-
            How this context's data carries sign. SAME: a payment carries the
            same sign as what it settles, so a negative amount is a reversal.
            OPPOSITE: a payment carries the opposite sign of the invoice it
            settles. Omit to leave it unchanged. In 1:N contexts only payments
            of the declared sign are allocated to an invoice, and in N:M
            contexts a short-paid invoice keeps an open balance only when it is
            positive under SAME, or when the rule's sign mode is opposite under
            OPPOSITE; any other short payment stays unmatched; a carried open
            balance settles on a payment of the declared sign or on a reversal
            from the invoice's own side, and a row from an archived source stays
            unmatched. It cannot change once the context has carried a partial
            balance, or while a match run is in progress.
          enum:
            - SAME
            - OPPOSITE
          examples:
            - OPPOSITE
          type: string
        status:
          description: >-
            Lifecycle status to transition to. ACTIVE runs the context; PAUSED
            suspends scheduling; ARCHIVED retires it.
          enum:
            - ACTIVE
            - PAUSED
            - ARCHIVED
          examples:
            - ACTIVE
          type: string
        type:
          description: >-
            Reconciliation topology. 1:1 matches one left transaction to one
            right transaction; 1:N matches one transaction against many on the
            other side; N:M matches groups on both sides.
          enum:
            - '1:1'
            - 1:N
            - N:M
          examples:
            - 1:N
          type: string
      type: object
    ReconciliationContextResponse:
      additionalProperties: false
      properties:
        agedBreakCalendar:
          description: >-
            Business-day calendar the aging threshold is measured against.
            Absent/empty means raw calendar days.
          examples:
            - BR_ANBIMA
          type: string
        agedBreakThresholdDays:
          description: >-
            Open-item aging SLA in business days. An open-item residual older
            than this surfaces as an AGED_BREAK exception. Absent when aging is
            disabled for the context.
          examples:
            - 30
          format: int64
          type: integer
        autoMatchOnUpload:
          description: >-
            When true, a match run is triggered automatically after a file
            upload completes.
          examples:
            - false
          type: boolean
        createdAt:
          description: Creation timestamp in RFC 3339 format.
          examples:
            - '2025-01-15T10:30:00Z'
          type: string
        feeNormalization:
          description: >-
            Fee normalization mode. NET compares amounts after fees are
            deducted; GROSS compares amounts before fees.
          enum:
            - NET
            - GROSS
          examples:
            - NET
          type: string
        feeToleranceAbs:
          description: Absolute fee tolerance as a decimal string in the context currency.
          examples:
            - '0.50'
          type: string
        feeTolerancePct:
          description: >-
            Fee tolerance in percent, as a decimal string: 0.5 means 0.5%, not
            50%.
          examples:
            - '0.5'
          type: string
        id:
          description: Unique identifier of the context.
          examples:
            - 550e8400-e29b-41d4-a716-446655440000
          type: string
        interval:
          description: Execution interval label for the context (e.g. daily, weekly).
          examples:
            - daily
          type: string
        name:
          description: Human-readable name of the reconciliation context.
          examples:
            - Bank Reconciliation Q1
          type: string
        signConvention:
          description: >-
            How this context's data carries sign. SAME: a payment carries the
            same sign as what it settles, so a negative amount is a reversal.
            OPPOSITE: a payment carries the opposite sign of the invoice it
            settles. In 1:N contexts only payments of the declared sign are
            allocated to an invoice, and in N:M contexts a short-paid invoice
            keeps an open balance only when it is positive under SAME, or when
            the rule's sign mode is opposite under OPPOSITE; any other short
            payment stays unmatched; a carried open balance settles on a payment
            of the declared sign or on a reversal from the invoice's own side,
            and a row from an archived source stays unmatched. It cannot change
            once the context has carried a partial balance, or while a match run
            is in progress.
          enum:
            - SAME
            - OPPOSITE
          examples:
            - SAME
          type: string
        status:
          description: >-
            Lifecycle status. DRAFT is being configured; ACTIVE runs; PAUSED is
            suspended; ARCHIVED is retired.
          enum:
            - DRAFT
            - ACTIVE
            - PAUSED
            - ARCHIVED
          examples:
            - ACTIVE
          type: string
        tenantId:
          description: Identifier of the tenant that owns the context.
          examples:
            - 550e8400-e29b-41d4-a716-446655440000
          type: string
        type:
          description: >-
            Reconciliation topology. 1:1 matches one left transaction to one
            right transaction; 1:N matches one transaction against many on the
            other side; N:M matches groups on both sides.
          enum:
            - '1:1'
            - 1:N
            - N:M
          examples:
            - '1:1'
          type: string
        updatedAt:
          description: Last update timestamp in RFC 3339 format.
          examples:
            - '2025-01-15T10:30:00Z'
          type: string
      required:
        - id
        - tenantId
        - name
        - type
        - interval
        - status
        - feeToleranceAbs
        - feeTolerancePct
        - autoMatchOnUpload
        - signConvention
        - createdAt
        - updatedAt
      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
    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-0001-context-name-is-required:
      summary: Context name is required
      value:
        type: https://errors.lerian.studio/v1/MTCH-0001
        title: Bad Request
        status: 400
        detail: >-
          a reconciliation context name is required; provide a name and try
          again
        code: MTCH-0001
    mtch-0110-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-0101-a-reconciliation-context-with-this-name-already-exists--patch-v1-contexts-contextid:
      summary: A reconciliation context with this name already exists
      value:
        type: https://errors.lerian.studio/v1/MTCH-0101
        title: Conflict
        status: 409
        detail: >-
          A reconciliation context with this name already exists; the update was
          not applied. Choose a different name.
        code: MTCH-0101
    mtch-0103-cannot-pause-context-in-draft-status-invalid-state-transitio:
      summary: 'Cannot pause context in DRAFT status: invalid state transition'
      value:
        type: https://errors.lerian.studio/v1/MTCH-0103
        title: Conflict
        status: 409
        detail: >-
          A draft context cannot be paused directly; activate it first, then
          pause it
        code: MTCH-0103
    mtch-0104-archived-context-cannot-be-modified:
      summary: Archived context cannot be modified
      value:
        type: https://errors.lerian.studio/v1/MTCH-0104
        title: Conflict
        status: 409
        detail: >-
          This context is archived and cannot be modified; restore it first if
          you need to change its configuration
        code: MTCH-0104
    mtch-0103-context-is-not-ready-for-activation:
      summary: Context is not ready for activation
      value:
        type: https://errors.lerian.studio/v1/MTCH-0103
        title: Conflict
        status: 409
        detail: >-
          context is not ready for activation; call GET setup-progress for the
          missing requirements
        errors:
          - location: context.activation.requirement.right-source
          - location: context.activation.requirement.match-rule
        code: MTCH-0103
  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/AUT-0006
                title: Token Missing
                status: 401
                detail: >-
                  A valid token must be provided in the request header. Please
                  include a token and try again.
                code: AUT-0006
            InvalidToken:
              summary: Invalid token
              value:
                type: https://errors.lerian.studio/v1/AUT-0007
                title: Invalid Token
                status: 401
                detail: >-
                  The provided token is expired, invalid or malformed. Please
                  provide a valid token and try again.
                code: AUT-0007
    Forbidden:
      description: You do not have permission to access this resource.
      content:
        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
            PermissionDenied:
              summary: Permission denied
              value:
                type: https://errors.lerian.studio/v1/AUT-1020
                title: Permission Denied
                status: 403
                detail: >-
                  the credential is not allowed to perform contexts:read on this
                  request
                code: AUT-1020
    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
  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.