> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payfi.global/llms.txt
> Use this file to discover all available pages before exploring further.

# Get operation analysis

> Returns the operation status, latest operation-level Decision Pack when available, and per-document analysis projections.



## OpenAPI

````yaml /openapi/payfi-v1.json get /v1/operations/{operationId}/analysis
openapi: 3.0.0
info:
  title: PayFi Partner API
  description: >-
    Partner API for PayFi compliance document automation. Dashboard Partner
    access is the admin role for exactly one partner integration; public API
    requests remain authenticated with signed partner API keys.
  version: 0.1.0
  contact: {}
servers:
  - url: https://sandbox.payfi.global
    description: Sandbox
  - url: https://api.payfi.global
    description: Production
security: []
tags:
  - name: Customers
    description: Signed partner endpoints for customer records.
  - name: Operations
    description: Signed partner endpoints for operations, documents, and upload completion.
  - name: Webhooks
    description: Partner-managed webhook endpoints and signed callback tests.
paths:
  /v1/operations/{operationId}/analysis:
    get:
      tags:
        - Operations
      summary: Get operation analysis
      description: >-
        Returns the operation status, latest operation-level Decision Pack when
        available, and per-document analysis projections.
      operationId: PartnerApiController_getOperationAnalysis
      parameters:
        - name: operationId
          in: path
          required: true
          description: Operation ID.
          schema:
            type: string
          example: op_example
      responses:
        '200':
          description: Operation analysis.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OperationAnalysisResponse'
              examples:
                readyForManualReview:
                  value:
                    operation:
                      operationId: op_example_ready
                      partnerOperationId: acme-op-123
                      customerId: cus_example
                      status: READY_FOR_MANUAL_REVIEW
                      operationType: IMPORT_GOODS
                      exchangeModality: TERM
                      requirementsStatus: APPROVED
                      requiredDocumentTypes:
                        - invoice
                        - bill_of_lading
                        - packing_list
                      missingDocumentTypes: []
                      score0To100: 94
                      score1To10: 10
                      riskLevel: low
                      createdAt: '2026-05-20T12:00:00.000Z'
                      updatedAt: '2026-05-20T12:10:00.000Z'
                    decisionPack:
                      decisionPackId: dp_example
                      schemaVersion: 2
                      operationId: op_example
                      analysisRunId: job_example
                      status: READY_FOR_MANUAL_REVIEW
                      analysisOutcome: SUCCEEDED
                      qualityStatus: VALID
                      analysisMode: DETERMINISTIC_RULES
                      versionMetadata:
                        workflowVersion: workflow-v2
                        modelVersion: none
                        promptVersion: decision-v2
                        policyVersion: sample-policy-2026-05
                        rulesVersion: payfi-rules-v2
                        regulatoryCorpusVersion: bc-cambio-2026-06-03
                      fallbackUsed: false
                      sourceCoverage: COMPLETE
                      regulatoryCorpusVersion: bc-cambio-2026-06-03
                      policyVersion: sample-policy-2026-05
                      rulesVersion: payfi-rules-0.3.1
                      modelProfile: cheap-default-v1
                      inputSnapshotHash: >-
                        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                      evidence:
                        - sourceType: DOCUMENT
                          sourceId: doc_example
                          sourceVersion: sha256:abc
                          documentId: doc_example
                          page: 1
                      operationFacts:
                        operationId: op_example
                        operationType: IMPORT_GOODS
                        exchangeModality: TERM
                        declaredAmount: '80000'
                        currency: USD
                      documentCoverage:
                        - documentType: invoice
                          criticality: critical
                          status: present
                          documentIds:
                            - doc_example
                          reasonCodes: []
                          citations:
                            - citationId: cit_requirement_invoice
                              sourceType: REGULATION
                              sourceId: documentos-por-modalidade.md
                              sourceTitle: Documentos por modalidade
                              usedFor: DOCUMENT_REQUIREMENT
                              sourceStatus: FOUND
                      entityReconciliation: []
                      natureDecision:
                        declaredNatureCode: '12452'
                        provisionalNatureCode: '12452'
                        predictedNatureCode: '12452'
                        resolvedNatureCode: '12452'
                        phase: FINAL
                        status: MATCHED
                        confidence: 0.93
                        alternatives: []
                        rationale: >-
                          Final nature is supported by matching document-bound
                          nature_code evidence.
                        requiresHumanReview: true
                        reasonCodes:
                          - NATURE_CONFIRMED
                        citations:
                          - citationId: cit_nature_example
                            sourceType: DOCUMENT
                            sourceId: doc_example
                            usedFor: NATURE_DECISION
                            sourceStatus: FOUND
                      regulatoryChecks: []
                      policyChecks: []
                      fraudSignals: []
                      scoreBreakdown: []
                      scoreExplanation: Validated evidence supports manual approval.
                      overallScore: 10
                      score0To100: 100
                      riskLevel: LOW
                      recommendedStatus: READY_FOR_MANUAL_REVIEW
                      reviewPosture: STANDARD_REVIEW
                      blockingReasons: []
                      warnings:
                        - MANUAL_REVIEW_REQUIRED
                      actionItems: []
                      citations:
                        - citationId: cit_nature_example
                          sourceType: DOCUMENT
                          sourceId: doc_example
                          usedFor: NATURE_DECISION
                          sourceStatus: FOUND
                      rawResultRedacted:
                        workflow: PayFi Operation Decision Engine
                        deterministic: true
                      processingTraceEvents:
                        - source: workflow
                          stageKey: decision_engine.output
                          status: SUCCEEDED
                          sequence: 420
                      createdAt: '2026-06-03T15:00:00.000Z'
                    documentAnalyses:
                      - documentId: doc_invoice
                        documentType: invoice
                        originalFileName: invoice-2026-001.pdf
                        documentStatus: PROCESSED
                        jobId: job_invoice
                        jobStatus: SUCCEEDED
                        jobAttempts: 1
                        jobError: null
                        score0To100: 94
                        riskLevel: low
                        flags:
                          validated: []
                          rejected: []
                          additional: []
                          summary:
                            total: 0
                            critical: 0
                            warning: 0
                            info: 0
                        extractedFields:
                          document_type_detected: invoice
                          invoice_number: INV-2026-001
                          value: 80000
                          currency: USD
                          buyer_name: Acme Ltda
                        rawResultRedacted:
                          operation_id: op_example_ready
                          compliance_score: 94
                          risk_level: low
                          flags:
                            validated: []
                            rejected: []
                            additional: []
                            summary:
                              total: 0
                              critical: 0
                              warning: 0
                              info: 0
                          extracted_data:
                            document_type_detected: invoice
                            invoice_number: INV-2026-001
                            value: 80000
                            currency: USD
                          completeness:
                            is_complete: true
                            missing_documents: []
                            missing_types: []
                          pipeline_version: P1
                          processed_at: '2026-05-20T12:05:00.000Z'
                        createdAt: '2026-05-20T12:00:00.000Z'
                        updatedAt: '2026-05-20T12:05:00.000Z'
                        resultCreatedAt: '2026-05-20T12:05:00.000Z'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidRequest:
                  value:
                    error:
                      code: INVALID_REQUEST
                      message: The request payload is invalid.
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  value:
                    error:
                      code: UNAUTHORIZED
                      message: Authentication failed.
      security:
        - PayFiApiKey: []
          PayFiNonce: []
          PayFiSignature: []
components:
  schemas:
    OperationAnalysisResponse:
      type: object
      properties:
        operation:
          $ref: '#/components/schemas/OperationStatusResponse'
        decisionPack:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/OperationDecisionPackResponse'
          description: >-
            Latest operation-level Decision Pack, or null before the Decision
            Engine completes.
        documentAnalyses:
          $ref: '#/components/schemas/OperationAnalysisResultListResponse'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: INVALID_SIGNATURE
            message:
              type: string
              example: The request signature is invalid.
    OperationStatusResponse:
      type: object
      properties:
        operationId:
          type: string
          example: op_example
        partnerOperationId:
          type: string
          nullable: true
          example: acme-op-123
        customerId:
          type: string
          nullable: true
          example: cus_example
        status:
          type: string
          enum:
            - CREATED
            - REQUIREMENTS_PENDING
            - REQUIREMENTS_REVIEW_REQUIRED
            - REQUIREMENTS_FAILED
            - AWAITING_DOCUMENTS
            - DOCUMENTS_PARTIAL
            - DOCUMENTS_UPLOADED
            - PROCESSING
            - PROCESSING_FAILED
            - ACTION_REQUIRED
            - READY_FOR_MANUAL_REVIEW
            - MANUAL_REVIEW_APPROVED
            - MANUAL_REVIEW_REJECTED
            - MANUAL_REVIEW_CHANGES_REQUESTED
            - PARTNER_CALLBACK_PENDING
            - PARTNER_CALLBACK_DELIVERED
            - PARTNER_CALLBACK_FAILED
            - CANCELLED
            - FAILED
          example: REQUIREMENTS_REVIEW_REQUIRED
        operationType:
          type: string
          enum:
            - IMPORT_GOODS
            - EXPORT_GOODS
            - SERVICES
          example: IMPORT_GOODS
        exchangeModality:
          type: string
          enum:
            - ADVANCE
            - SIGHT
            - TERM
          example: TERM
        requirementsStatus:
          type: string
          enum:
            - PENDING
            - REVIEW_REQUIRED
            - APPROVED
            - FAILED
          example: REVIEW_REQUIRED
        requiredDocumentTypes:
          type: array
          items:
            type: string
            enum:
              - invoice
              - bill_of_lading
              - packing_list
              - di_duimp
              - bank_details
              - proforma
              - service_contract
              - insurance_policy
            example: invoice
          example:
            - invoice
            - bill_of_lading
            - packing_list
        missingDocumentTypes:
          type: array
          items:
            type: string
            enum:
              - invoice
              - bill_of_lading
              - packing_list
              - di_duimp
              - bank_details
              - proforma
              - service_contract
              - insurance_policy
            example: invoice
          example:
            - invoice
        score0To100:
          type: number
          nullable: true
          example: null
        score1To10:
          type: number
          nullable: true
          example: null
        riskLevel:
          type: string
          enum:
            - low
            - medium
            - high
            - critical
            - unknown
          nullable: true
          example: null
        declaredBeneficiaryName:
          type: string
          nullable: true
          example: Shenzhen NovaTech Components Co Ltd
        declaredEconomicOwnerName:
          type: string
          nullable: true
          example: Shenzhen NovaTech Components Co Ltd
        buyerCountry:
          type: string
          nullable: true
          example: BR
        createdAt:
          type: string
          example: '2026-05-20T12:00:00.000Z'
        updatedAt:
          type: string
          example: '2026-05-20T12:00:00.000Z'
    OperationDecisionPackResponse:
      type: object
      properties:
        decisionPackId:
          type: string
          example: dp_example
        schemaVersion:
          type: number
          example: 2
        operationId:
          type: string
          example: op_example
        analysisRunId:
          type: string
          example: job_example
        status:
          type: string
          enum:
            - DECISION_PACK_READY
            - ACTION_REQUIRED
            - READY_FOR_MANUAL_REVIEW
            - ERROR
          example: READY_FOR_MANUAL_REVIEW
        analysisOutcome:
          type: string
          enum:
            - SUCCEEDED
            - PARTIAL
            - INDETERMINATE
            - FAILED
          example: SUCCEEDED
        qualityStatus:
          type: string
          enum:
            - VALID
            - REVIEW_REQUIRED
            - INVALID
            - DEGRADED
          example: VALID
        analysisMode:
          type: string
          enum:
            - MODEL_ASSISTED
            - DETERMINISTIC_RULES
            - DEGRADED_FALLBACK
          example: DETERMINISTIC_RULES
        versionMetadata:
          type: object
          properties:
            workflowVersion:
              type: string
              example: workflow-v2
            modelVersion:
              type: string
              example: none
            promptVersion:
              type: string
              example: decision-v2
            policyVersion:
              type: string
              example: sample-policy-2026-05
            rulesVersion:
              type: string
              example: payfi-rules-v2
            regulatoryCorpusVersion:
              type: string
              example: bc-cambio-2026-06-03
        fallbackUsed:
          type: boolean
          example: false
        sourceCoverage:
          type: string
          enum:
            - COMPLETE
            - PARTIAL
            - NONE
          example: COMPLETE
        regulatoryCorpusVersion:
          type: string
          example: bc-cambio-2026-06-03
        policyVersion:
          type: string
          example: sample-policy-2026-05
        rulesVersion:
          type: string
          example: payfi-rules-0.3.1
        modelProfile:
          type: string
          example: cheap-default-v1
        inputSnapshotHash:
          type: string
          nullable: true
          example: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        evidence:
          type: array
          items:
            type: object
            properties:
              sourceType:
                type: string
                example: DOCUMENT
              sourceId:
                type: string
                example: doc_example
              sourceVersion:
                type: string
                example: sha256:abc
          example: []
        operationFacts:
          type: object
          properties:
            operationId:
              type: string
              example: op_example
        documentCoverage:
          type: array
          items:
            type: object
            properties:
              documentType:
                type: string
                enum:
                  - invoice
                  - bill_of_lading
                  - packing_list
                  - di_duimp
                  - bank_details
                  - proforma
                  - service_contract
                  - insurance_policy
                example: invoice
              status:
                type: string
                example: present
          example: []
        entityReconciliation:
          type: array
          items:
            type: object
            additionalProperties: false
            required:
              - reconciliationId
              - comparisonType
              - status
              - leftField
              - rightField
              - leftValue
              - rightValue
              - reasonCodes
              - evidence
            properties:
              reconciliationId:
                type: string
                example: rec_beneficiary_exporter
              comparisonType:
                type: string
                enum:
                  - PARTY
                  - BENEFICIARY_EXPORTER
                  - ECONOMIC_OWNER
                  - AMOUNT
                  - CURRENCY
                  - QUANTITY_WEIGHT
                  - BANK
                example: BENEFICIARY_EXPORTER
              status:
                type: string
                enum:
                  - MATCH
                  - CONFLICT
                  - NOT_DETERMINED
                example: CONFLICT
              leftField:
                type: string
                example: beneficiary_name
              rightField:
                type: string
                example: supplier_name
              leftValue:
                oneOf:
                  - type: string
                  - type: number
                nullable: true
                example: Beneficiary Ltd
              rightValue:
                oneOf:
                  - type: string
                  - type: number
                nullable: true
                example: Exporter Ltd
              reasonCodes:
                type: array
                items:
                  type: string
                example:
                  - BENEFICIARY_EXPORTER_MISMATCH
              evidence:
                type: array
                items:
                  type: object
                  properties:
                    sourceType:
                      type: string
                      example: DOCUMENT
                    sourceId:
                      type: string
                      example: doc_example
                    sourceVersion:
                      type: string
                      example: sha256:abc
          example: []
        natureDecision:
          type: object
          properties:
            declaredNatureCode:
              type: string
              nullable: true
              example: '12452'
            provisionalNatureCode:
              type: string
              nullable: true
              example: '12452'
            predictedNatureCode:
              type: string
              nullable: true
              example: '12452'
            resolvedNatureCode:
              type: string
              nullable: true
              example: '12452'
            phase:
              type: string
              enum:
                - FINAL
              example: FINAL
            status:
              type: string
              enum:
                - MATCHED
                - INFERRED
                - MISMATCH_REVIEW_REQUIRED
                - NOT_DETERMINED
              example: MATCHED
            confidence:
              type: number
              example: 0.94
            alternatives:
              type: array
              items:
                type: object
                properties:
                  natureCode:
                    type: string
                    example: '12452'
                  label:
                    type: string
                    example: Importação de bens
                  confidence:
                    type: number
                    example: 0.94
              example: []
            rationale:
              type: string
              example: >-
                Final nature is supported by document-bound nature_code
                evidence.
            requiresHumanReview:
              type: boolean
              example: true
            reasonCodes:
              type: array
              items:
                type: string
                enum:
                  - MISSING_REQUIRED_DOCUMENT
                  - MISSING_CRITICAL_DOCUMENT
                  - BANK_ACCOUNT_MISMATCH
                  - BUYER_OWNER_MISMATCH
                  - DOCUMENT_REFERENCE_MISMATCH
                  - AMOUNT_MISMATCH
                  - CURRENCY_MISMATCH
                  - INVALID_TAX_ID
                  - INVALID_SWIFT_BIC
                  - INVALID_IBAN
                  - NATURE_MISMATCH
                  - LOW_OCR_CONFIDENCE
                  - DUPLICATE_DOCUMENT_HASH
                  - SUSPICIOUS_PDF_METADATA
                  - NO_REGULATORY_SOURCE_FOUND
                  - POLICY_RULE_TRIGGERED
                  - POLICY_NOT_CONFIGURED
                  - MALWARE_DETECTED
                  - DOCUMENT_ANALYSIS_FAILED
                  - UNTRUSTED_ANALYSIS_RESULT
                  - STALE_DECISION_PACK
                  - SCHEMA_VALIDATION_FAILED
                  - MANUAL_REVIEW_REQUIRED
                  - DOCUMENTS_VALIDATED
                  - NATURE_CONFIRMED
                  - HUMAN_OVERRIDE_APPLIED
                example: NATURE_CONFIRMED
              example:
                - NATURE_CONFIRMED
            citations:
              type: array
              items:
                type: object
                properties:
                  citationId:
                    type: string
                    example: cit_nature_doc_example
                  sourceType:
                    type: string
                    enum:
                      - REGULATION
                      - CLIENT_POLICY
                      - DOCUMENT
                      - SYSTEM_RULE
                      - NO_SOURCE
                    example: DOCUMENT
                  sourceId:
                    type: string
                    example: doc_example
                  usedFor:
                    type: string
                    enum:
                      - DOCUMENT_REQUIREMENT
                      - NATURE_DECISION
                      - REGULATORY_CHECK
                      - POLICY_CHECK
                      - FRAUD_SIGNAL
                      - SCORE
                      - ACTION_ITEM
                    example: NATURE_DECISION
                  sourceStatus:
                    type: string
                    enum:
                      - FOUND
                      - NOT_DETERMINED
                    example: FOUND
              example: []
          required:
            - declaredNatureCode
            - predictedNatureCode
            - resolvedNatureCode
            - phase
            - status
            - confidence
            - alternatives
            - rationale
            - requiresHumanReview
            - reasonCodes
            - citations
        regulatoryChecks:
          type: array
          items:
            type: object
            properties:
              status:
                type: string
                enum:
                  - PASS
                  - WARNING
                  - FAIL
                  - NOT_DETERMINED
                example: PASS
          example: []
        policyChecks:
          type: array
          items:
            type: object
            properties:
              status:
                type: string
                enum:
                  - PASS
                  - WARNING
                  - FAIL
                  - NOT_DETERMINED
                example: PASS
          example: []
        fraudSignals:
          type: array
          items:
            type: object
            properties: {}
          example: []
        scoreBreakdown:
          type: array
          items:
            type: object
            properties:
              reasonCode:
                type: string
                enum:
                  - MISSING_REQUIRED_DOCUMENT
                  - MISSING_CRITICAL_DOCUMENT
                  - BANK_ACCOUNT_MISMATCH
                  - BUYER_OWNER_MISMATCH
                  - DOCUMENT_REFERENCE_MISMATCH
                  - AMOUNT_MISMATCH
                  - CURRENCY_MISMATCH
                  - INVALID_TAX_ID
                  - INVALID_SWIFT_BIC
                  - INVALID_IBAN
                  - NATURE_MISMATCH
                  - LOW_OCR_CONFIDENCE
                  - DUPLICATE_DOCUMENT_HASH
                  - SUSPICIOUS_PDF_METADATA
                  - NO_REGULATORY_SOURCE_FOUND
                  - POLICY_RULE_TRIGGERED
                  - POLICY_NOT_CONFIGURED
                  - MALWARE_DETECTED
                  - DOCUMENT_ANALYSIS_FAILED
                  - UNTRUSTED_ANALYSIS_RESULT
                  - STALE_DECISION_PACK
                  - SCHEMA_VALIDATION_FAILED
                  - MANUAL_REVIEW_REQUIRED
                  - DOCUMENTS_VALIDATED
                  - NATURE_CONFIRMED
                  - HUMAN_OVERRIDE_APPLIED
                example: AMOUNT_MISMATCH
              severity:
                type: string
                enum:
                  - INFO
                  - LOW
                  - MEDIUM
                  - HIGH
                  - CRITICAL
                example: HIGH
              field:
                type: string
                nullable: true
                example: value
              impact:
                type: number
                example: -3
              explanation:
                type: string
                example: Declared and documentary values differ.
              evidence:
                type: array
                items:
                  type: object
                  properties:
                    sourceType:
                      type: string
                      example: DOCUMENT
                    sourceId:
                      type: string
                      example: doc_example
                    sourceVersion:
                      type: string
                      example: sha256:abc
                example: []
            required:
              - reasonCode
              - severity
              - field
              - impact
              - explanation
              - evidence
          example: []
        scoreExplanation:
          type: string
          example: Validated evidence supports manual approval.
        overallScore:
          type: number
          nullable: true
          example: 8.2
        score0To100:
          type: number
          nullable: true
          example: 82
        riskLevel:
          type: string
          enum:
            - LOW
            - MEDIUM
            - HIGH
            - CRITICAL
            - NOT_DETERMINED
          example: LOW
        recommendedStatus:
          type: string
          enum:
            - ACTION_REQUIRED
            - READY_FOR_MANUAL_REVIEW
          example: READY_FOR_MANUAL_REVIEW
        reviewPosture:
          type: string
          enum:
            - STANDARD_REVIEW
            - REVIEW_WITH_WARNINGS
            - CRITICAL_REVIEW
          example: STANDARD_REVIEW
        blockingReasons:
          type: array
          items:
            type: string
            enum:
              - MISSING_REQUIRED_DOCUMENT
              - MISSING_CRITICAL_DOCUMENT
              - BANK_ACCOUNT_MISMATCH
              - BUYER_OWNER_MISMATCH
              - DOCUMENT_REFERENCE_MISMATCH
              - AMOUNT_MISMATCH
              - CURRENCY_MISMATCH
              - INVALID_TAX_ID
              - INVALID_SWIFT_BIC
              - INVALID_IBAN
              - NATURE_MISMATCH
              - LOW_OCR_CONFIDENCE
              - DUPLICATE_DOCUMENT_HASH
              - SUSPICIOUS_PDF_METADATA
              - NO_REGULATORY_SOURCE_FOUND
              - POLICY_RULE_TRIGGERED
              - POLICY_NOT_CONFIGURED
              - MALWARE_DETECTED
              - DOCUMENT_ANALYSIS_FAILED
              - UNTRUSTED_ANALYSIS_RESULT
              - STALE_DECISION_PACK
              - SCHEMA_VALIDATION_FAILED
              - MANUAL_REVIEW_REQUIRED
              - DOCUMENTS_VALIDATED
              - NATURE_CONFIRMED
              - HUMAN_OVERRIDE_APPLIED
            example: AMOUNT_MISMATCH
          example: []
        warnings:
          type: array
          items:
            type: string
            enum:
              - MISSING_REQUIRED_DOCUMENT
              - MISSING_CRITICAL_DOCUMENT
              - BANK_ACCOUNT_MISMATCH
              - BUYER_OWNER_MISMATCH
              - DOCUMENT_REFERENCE_MISMATCH
              - AMOUNT_MISMATCH
              - CURRENCY_MISMATCH
              - INVALID_TAX_ID
              - INVALID_SWIFT_BIC
              - INVALID_IBAN
              - NATURE_MISMATCH
              - LOW_OCR_CONFIDENCE
              - DUPLICATE_DOCUMENT_HASH
              - SUSPICIOUS_PDF_METADATA
              - NO_REGULATORY_SOURCE_FOUND
              - POLICY_RULE_TRIGGERED
              - POLICY_NOT_CONFIGURED
              - MALWARE_DETECTED
              - DOCUMENT_ANALYSIS_FAILED
              - UNTRUSTED_ANALYSIS_RESULT
              - STALE_DECISION_PACK
              - SCHEMA_VALIDATION_FAILED
              - MANUAL_REVIEW_REQUIRED
              - DOCUMENTS_VALIDATED
              - NATURE_CONFIRMED
              - HUMAN_OVERRIDE_APPLIED
            example: MANUAL_REVIEW_REQUIRED
          example:
            - MANUAL_REVIEW_REQUIRED
        actionItems:
          type: array
          items:
            type: object
            properties: {}
          example: []
        citations:
          type: array
          items:
            type: object
            properties:
              sourceType:
                type: string
                example: REGULATION
              sourceStatus:
                type: string
                example: FOUND
          example: []
        rawResultRedacted:
          type: object
          properties: {}
        processingTraceEvents:
          type: array
          items:
            type: object
            properties:
              stageKey:
                type: string
                example: decision_engine.output
          example: []
        createdAt:
          type: string
          example: '2026-06-03T15:00:00.000Z'
    OperationAnalysisResultListResponse:
      type: array
      items:
        $ref: '#/components/schemas/OperationAnalysisResultItem'
    OperationAnalysisResultItem:
      type: object
      properties:
        documentId:
          type: string
          example: doc_example
        documentType:
          type: string
          enum:
            - invoice
            - bill_of_lading
            - packing_list
            - di_duimp
            - bank_details
            - proforma
            - service_contract
            - insurance_policy
          example: invoice
        originalFileName:
          type: string
          example: invoice-123.pdf
        documentStatus:
          type: string
          enum:
            - REGISTERED
            - UPLOAD_PENDING
            - UPLOADED
            - SCANNING
            - CLEAN
            - REJECTED
            - PROCESSING
            - PROCESSED
            - PROCESSING_FAILED
          example: PROCESSED
        jobId:
          type: string
          nullable: true
          example: job_example
        jobStatus:
          type: string
          enum:
            - PENDING
            - RUNNING
            - SUCCEEDED
            - FAILED_RETRYABLE
            - FAILED_FINAL
          nullable: true
          example: SUCCEEDED
        jobAttempts:
          type: number
          nullable: true
          example: 1
        jobError:
          type: string
          nullable: true
          example: null
        score0To100:
          type: number
          nullable: true
          example: 94
        riskLevel:
          type: string
          enum:
            - low
            - medium
            - high
            - critical
            - unknown
          nullable: true
          example: low
        flags:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/AnalysisFlagsDto'
          description: Normalized flag projection for the latest document analysis result.
        extractedFields:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/AnalysisExtractedFieldsDto'
          description: Normalized extracted fields for the latest document analysis result.
        rawResultRedacted:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/AnalysisPipelineResultDto'
          description: >-
            Redacted raw Analysis pipeline result. Internal traces, secrets and
            raw document data are never returned.
        createdAt:
          type: string
          example: '2026-05-20T12:00:00.000Z'
        updatedAt:
          type: string
          example: '2026-05-20T12:05:00.000Z'
        resultCreatedAt:
          type: string
          nullable: true
          example: '2026-05-20T12:05:00.000Z'
    AnalysisFlagsDto:
      type: object
      properties:
        validated:
          example: []
          type: array
          items:
            $ref: '#/components/schemas/AnalysisFlagDto'
        rejected:
          example: []
          type: array
          items:
            $ref: '#/components/schemas/AnalysisFlagDto'
        additional:
          example: []
          type: array
          items:
            $ref: '#/components/schemas/AnalysisFlagDto'
        summary:
          $ref: '#/components/schemas/AnalysisFlagSummaryDto'
      required:
        - validated
        - rejected
        - additional
        - summary
    AnalysisExtractedFieldsDto:
      type: object
      properties:
        document_type_detected:
          type: string
          example: invoice
        invoice_number:
          type: string
          example: INV-2026-001
        value:
          type: number
          example: 80000
        currency:
          type: string
          example: USD
        date:
          type: string
          example: '2026-05-18'
        supplier_name:
          type: string
          example: Global Foods LLC
        supplier_country:
          type: string
          example: BR
        buyer_name:
          type: string
          example: Acme Ltda
        buyer_cnpj:
          type: string
          example: 12.345.678/0001-95
        product_description:
          type: string
          example: Frozen fruit pulp
        bl_number:
          type: string
          example: BL-998877
        di_number:
          type: string
          example: DI-112233
        payment_terms:
          type: string
          example: 30 days after shipment
        swift_bic:
          type: string
          example: BOFAUS3NXXX
        iban:
          type: string
          example: GB82WEST12345698765432
        port_loading:
          type: string
          example: Shanghai
        port_discharge:
          type: string
          example: Santos
        insurance_date:
          type: string
          example: '2026-05-17'
        insurance_value:
          type: number
          example: 88000
        incoterm:
          type: string
          example: CIF
        weight_kg:
          type: number
          example: 12500
        quantity:
          type: number
          example: 500
    AnalysisPipelineResultDto:
      type: object
      properties:
        operation_id:
          type: string
          example: op_mpbp4uh7d0f9597aba2d4138
        compliance_score:
          type: number
          example: 90
          minimum: 0
          maximum: 100
        risk_level:
          type: string
          enum:
            - low
            - medium
            - high
            - critical
          example: low
        flags:
          $ref: '#/components/schemas/AnalysisFlagsDto'
        extracted_data:
          $ref: '#/components/schemas/AnalysisExtractedFieldsDto'
        completeness:
          $ref: '#/components/schemas/AnalysisCompletenessDto'
        content_validation:
          $ref: '#/components/schemas/AnalysisContentValidationDto'
        icc_check:
          $ref: '#/components/schemas/AnalysisIccCheckDto'
        cnae_check:
          $ref: '#/components/schemas/AnalysisCnaeCheckDto'
        nature_suggestion:
          $ref: '#/components/schemas/AnalysisNatureSuggestionDto'
        fraud_check:
          $ref: '#/components/schemas/AnalysisFraudCheckDto'
        duplicate_check:
          $ref: '#/components/schemas/AnalysisDuplicateCheckDto'
        ecam_c212:
          $ref: '#/components/schemas/AnalysisEcamC212Dto'
        ecam_ready:
          type: boolean
          example: true
        pipeline_version:
          type: string
          example: P1
        processed_at:
          type: string
          example: '2026-05-18T14:22:10.000Z'
        processingTraceEvents:
          type: array
          items:
            type: object
      required:
        - compliance_score
        - risk_level
        - flags
        - extracted_data
        - completeness
        - pipeline_version
        - processed_at
    AnalysisFlagDto:
      type: object
      properties:
        severity:
          type: string
          example: warning
        category:
          type: string
          example: content
        code:
          type: string
          example: VALUE_DIVERGENCE
        message:
          type: string
          example: Invoice value differs 6.25% from the declared operation value.
        field:
          type: string
          example: value
        confidence:
          type: number
          example: 1
      required:
        - message
    AnalysisFlagSummaryDto:
      type: object
      properties:
        total:
          type: number
          example: 0
        critical:
          type: number
          example: 0
        warning:
          type: number
          example: 1
        info:
          type: number
          example: 2
      required:
        - total
    AnalysisCompletenessDto:
      type: object
      properties:
        scope:
          type: string
          example: single_document
        analysis_scope:
          type: string
          example: single_document
        is_complete:
          type: boolean
          example: true
        operation_nature:
          type: string
          example: IMP_MERC_PRAZO
        uploaded_types:
          example:
            - invoice
          type: array
          items:
            type: string
        required_types:
          example:
            - invoice
            - bill_of_lading
            - packing_list
            - di_duimp
            - bank_details
          type: array
          items:
            type: string
        missing_types:
          example:
            - bill_of_lading
            - packing_list
          type: array
          items:
            type: string
        missing_documents:
          example:
            - bill_of_lading
            - packing_list
          type: array
          items:
            type: string
        completeness_flags:
          type: array
          items:
            $ref: '#/components/schemas/AnalysisFlagDto'
    AnalysisContentValidationDto:
      type: object
      properties:
        content_flags:
          type: array
          items:
            $ref: '#/components/schemas/AnalysisFlagDto'
        overall_severity:
          type: string
          example: ok
    AnalysisIccCheckDto:
      type: object
      properties:
        flags:
          type: array
          items:
            $ref: '#/components/schemas/AnalysisFlagDto'
        summary:
          type: string
          example: No material discrepancy found.
    AnalysisCnaeCheckDto:
      type: object
      properties:
        compatible:
          type: boolean
          example: true
        rationale:
          type: string
          example: Declared CNAE is compatible with the extracted product description.
    AnalysisNatureSuggestionDto:
      type: object
      properties:
        suggested_nature:
          type: string
          example: IMP_MERC_PRAZO
        confidence:
          type: number
          example: 0.91
        rationale:
          type: string
          example: The invoice and payment terms match import of goods on term.
    AnalysisFraudCheckDto:
      type: object
      properties:
        fraud_flags:
          example: []
          type: array
          items:
            $ref: '#/components/schemas/AnalysisFlagDto'
        total_flags:
          type: number
          example: 0
        has_critical:
          type: boolean
          example: false
      required:
        - fraud_flags
        - total_flags
    AnalysisDuplicateCheckDto:
      type: object
      properties:
        checked:
          type: boolean
          example: true
        identifiers_available:
          $ref: '#/components/schemas/AnalysisDuplicateIdentifiersDto'
        duplicate_flags:
          type: array
          items:
            $ref: '#/components/schemas/AnalysisFlagDto'
      required:
        - checked
        - identifiers_available
    AnalysisEcamC212Dto:
      type: object
      properties:
        natureza_operacao:
          type: string
          example: IMP_MERC_PRAZO
        valor_operacao:
          type: number
          example: 80000
        moeda:
          type: string
          example: USD
        data_operacao:
          type: string
          example: '2026-05-18'
        remetente:
          $ref: '#/components/schemas/AnalysisEcamPartyDto'
        destinatario:
          $ref: '#/components/schemas/AnalysisEcamPartyDto'
        documentos_lastro:
          type: array
          items:
            $ref: '#/components/schemas/AnalysisEcamDocumentDto'
    AnalysisDuplicateIdentifiersDto:
      type: object
      properties:
        invoice_number:
          type: boolean
          example: true
        file_hash:
          type: boolean
          example: true
        supplier_name:
          type: boolean
          example: true
        invoice_value:
          type: boolean
          example: true
    AnalysisEcamPartyDto:
      type: object
      properties:
        name:
          type: string
          example: Global Foods LLC
        country:
          type: string
          example: US
        document:
          type: string
          example: 12.345.678/0001-95
        cnpj:
          type: string
          example: 12.345.678/0001-95
    AnalysisEcamDocumentDto:
      type: object
      properties:
        tipo:
          type: string
          example: invoice
        numero:
          type: string
          example: INV-2026-001
        data:
          type: string
          example: '2026-05-18'
      required:
        - tipo
        - numero
  securitySchemes:
    PayFiApiKey:
      type: apiKey
      in: header
      name: X-PayFi-Api-Key
    PayFiNonce:
      type: apiKey
      in: header
      name: X-PayFi-Nonce
    PayFiSignature:
      type: apiKey
      in: header
      name: X-PayFi-Signature

````