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

# Orchestrate Core operation

> Resolves participant routing, consumes quota when indirect, records settlement tracking, attributes fees/commissions, persists saga state, and emits Core domain events.



## OpenAPI

````yaml en/openapi/v3-current/spi-core.yaml post /api/v1/core/operations/
openapi: 3.1.0
info:
  contact:
    email: contact@lerian.studio
    name: Lerian Studio
    url: https://lerian.studio
  description: >-
    Core service of Lerian SPI: MED (Mecanismo Especial de Devolução) dispute
    cases, PIX participant lifecycle by ISPB, payment routing resolution, and
    cross-context Core operation orchestration over the Brazilian Instant
    Payment System (SPI/Pix).
  license:
    name: Lerian Studio General License
  title: Lerian SPI — Core API
  version: 1.0.0
servers:
  - url: https://spi.sandbox.lerian.net
security: []
tags:
  - description: >-
      MED (Mecanismo Especial de Devolução) dispute cases: open, list, retrieve,
      analyze, resolve, close, cancel, and attach evidence.
    name: MED
  - description: >-
      PIX participant lifecycle: register, list, retrieve, suspend, activate,
      and offboard by ISPB.
    name: Participants
  - description: Payment routing resolution across participants.
    name: Routing
  - description: Core operation orchestration across the rail's bounded contexts.
    name: Operations
paths:
  /api/v1/core/operations/:
    post:
      tags:
        - Operations
      summary: Orchestrate Core operation
      description: >-
        Resolves participant routing, consumes quota when indirect, records
        settlement tracking, attributes fees/commissions, persists saga state,
        and emits Core domain events.
      operationId: orchestrateOperation
      parameters:
        - description: Idempotency key, max 255 characters
          in: header
          name: Idempotency-Key
          schema:
            description: Idempotency key, max 255 characters
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrchestrateOperationRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrchestrateOperationResponse'
          description: OK
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
      security:
        - BearerAuth: []
components:
  schemas:
    OrchestrateOperationRequest:
      additionalProperties: false
      properties:
        amount:
          description: >-
            Transaction amount in centavos (BRL minor units); must be greater
            than zero.
          examples:
            - 15000
          format: int64
          type: integer
        commissionAmount:
          description: Commission amount in centavos (BRL minor units); zero or positive.
          examples:
            - 10
          format: int64
          type: integer
        commissionRecipientISPB:
          description: >-
            ISPB of the participant receiving the commission (8 numeric digits);
            optional.
          examples:
            - '87654321'
          type: string
        endToEndId:
          description: >-
            PIX EndToEndID of the transaction, format
            E{ISPB}{YYYYMMDD}{uniqueID}.
          examples:
            - E12345678202604281234ABCDE123456
          type: string
        feeAmount:
          description: Fee amount in centavos (BRL minor units); zero or positive.
          examples:
            - 25
          format: int64
          type: integer
        feePayerISPB:
          description: >-
            ISPB of the participant charged the fee (8 numeric digits);
            optional.
          examples:
            - '12345678'
          type: string
        operationId:
          description: >-
            Caller-assigned idempotency/business identifier for the operation,
            max 128 characters.
          examples:
            - op-20260428-0001
          type: string
        senderISPB:
          description: ISPB of the sending participant, exactly 8 numeric digits.
          examples:
            - '12345678'
          type: string
      required:
        - operationId
        - endToEndId
        - senderISPB
        - amount
        - feeAmount
        - commissionAmount
      type: object
    OrchestrateOperationResponse:
      additionalProperties: false
      properties:
        commissionAmount:
          description: Commission amount applied, in centavos (BRL minor units).
          examples:
            - 10
          format: int64
          type: integer
        commissionRecipientISPB:
          description: >-
            ISPB of the participant receiving the commission (8 numeric digits);
            omitted when no fee attribution applies.
          examples:
            - '87654321'
          type: string
        feeAmount:
          description: Fee amount applied, in centavos (BRL minor units).
          examples:
            - 25
          format: int64
          type: integer
        feeAttributionId:
          description: >-
            UUID of the fee attribution record; empty when no fee attribution
            was created.
          examples:
            - 550e8400-e29b-41d4-a716-446655440000
          type: string
        feePayerISPB:
          description: >-
            ISPB of the participant charged the fee (8 numeric digits); omitted
            when no fee attribution applies.
          examples:
            - '12345678'
          type: string
        operationId:
          description: Caller-assigned identifier echoed from the request.
          examples:
            - op-20260428-0001
          type: string
        routingDecision:
          $ref: '#/components/schemas/OperationRoutingDecisionResponse'
          description: >-
            Routing snapshot showing how the operation was directed through
            sponsor/indirect participants.
        sagaId:
          description: UUID of the orchestration saga coordinating the operation.
          examples:
            - 550e8400-e29b-41d4-a716-446655440000
          type: string
        sagaStatus:
          description: Current state of the orchestration saga (e.g. COMPLETED).
          examples:
            - COMPLETED
          type: string
        settlementId:
          description: UUID of the settlement created for this operation.
          examples:
            - 550e8400-e29b-41d4-a716-446655440000
          type: string
        settlementStatus:
          description: Current state of the settlement (e.g. PENDING).
          examples:
            - PENDING
          type: string
      required:
        - sagaId
        - operationId
        - sagaStatus
        - settlementId
        - settlementStatus
        - feeAttributionId
        - routingDecision
        - feeAmount
        - commissionAmount
      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
      type: object
    OperationRoutingDecisionResponse:
      additionalProperties: false
      properties:
        indirectISPB:
          description: >-
            ISPB of the indirect participant being routed through the sponsor (8
            numeric digits); empty for direct participants.
          examples:
            - '12345678'
          type: string
        isDirect:
          description: >-
            True when the sender connects directly to BACEN; false when routed
            through a sponsor.
          examples:
            - false
          type: boolean
        quotaConsumed:
          description: >-
            Amount in centavos (BRL minor units) consumed from the indirect
            participant's quota for this operation.
          examples:
            - 15000
          format: int64
          type: integer
        sponsorISPB:
          description: >-
            ISPB of the sponsor participant routing the payment (8 numeric
            digits); empty for direct participants.
          examples:
            - '87654321'
          type: string
      required:
        - quotaConsumed
        - isDirect
      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
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````