> ## 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 manual fetch-and-ingest from an external transport

> Lists every object matching the supplied transport coordinates (SFTP today) and streams each into the trusted-content ingestion pipeline (dedup + outbox + match-trigger), returning a per-file outcome in fetch order. The tenant is resolved from the JWT and the context/source from the path — NEVER from the body. The body carries connection coordinates plus an OPAQUE credential reference, never a secret. A transport-level fetch failure (the external endpoint is unreachable or rejects the credential) returns 503; per-file intake failures are reported in the response body without failing the batch.



## OpenAPI

````yaml en/openapi/v3-current/matcher.yaml post /v1/imports/contexts/{contextId}/sources/{sourceId}/fetch
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: 4.1.0
  license:
    name: Elastic License 2.0
    url: https://www.elastic.co/licensing/elastic-license
servers:
  - url: https://matcher.sandbox.lerian.net
security: []
paths:
  /v1/imports/contexts/{contextId}/sources/{sourceId}/fetch:
    post:
      tags:
        - Ingestion
      summary: Trigger a manual fetch-and-ingest from an external transport
      description: >-
        Lists every object matching the supplied transport coordinates (SFTP
        today) and streams each into the trusted-content ingestion pipeline
        (dedup + outbox + match-trigger), returning a per-file outcome in fetch
        order. The tenant is resolved from the JWT and the context/source from
        the path — NEVER from the body. The body carries connection coordinates
        plus an OPAQUE credential reference, never a secret. A transport-level
        fetch failure (the external endpoint is unreachable or rejects the
        credential) returns 503; per-file intake failures are reported in the
        response body without failing the batch.
      operationId: fetchTrigger
      parameters:
        - description: Context ID
          in: path
          name: contextId
          required: true
          schema:
            description: Context ID
            format: uuid
            type: string
        - description: Source ID
          in: path
          name: sourceId
          required: true
          schema:
            description: Source ID
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FetchTriggerRequest'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FetchTriggerResponse'
          description: Accepted
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
      security:
        - BearerAuth: []
components:
  schemas:
    FetchTriggerRequest:
      additionalProperties: false
      properties:
        connectOptions:
          additionalProperties:
            type: string
          description: >-
            Optional non-secret transport tuning (e.g. known_hosts, user,
            timeout_seconds)
          type: object
        credentialRef:
          description: Opaque stored-credential reference (not a secret)
          examples:
            - cred-handle-123
          minLength: 1
          type: string
        format:
          description: >-
            Fallback content-format hint applied when a fetched object declares
            none. Accepts the namespaced FormatDescriptor key
            (region/family/variant) or the legacy flat aliases (cnab240,
            cielo_edi, ...); both resolve through the same parser registry
          examples:
            - br/cnab240/febraban-base
          type: string
        glob:
          description: Optional glob filter; empty fetches all
          examples:
            - '*.ret'
          type: string
        host:
          description: Remote endpoint hostname or IP
          examples:
            - sftp.bank.example
          minLength: 1
          type: string
        kind:
          description: Transport kind selecting the adapter
          enum:
            - sftp
            - https
            - s3
            - imap
          examples:
            - sftp
          type: string
        path:
          description: Remote directory to list/fetch from
          examples:
            - outbound/returns
          minLength: 1
          type: string
        port:
          description: Remote endpoint port
          examples:
            - 22
          format: int64
          maximum: 65535
          minimum: 1
          type: integer
      required:
        - host
        - port
        - path
        - credentialRef
      type: object
    FetchTriggerResponse:
      additionalProperties: false
      properties:
        files:
          description: Per-file outcomes of the fetch-and-ingest batch, in fetch order
          items:
            $ref: '#/components/schemas/FileOutcomeResponse'
          type:
            - array
            - 'null'
      required:
        - files
      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
    FileOutcomeResponse:
      additionalProperties: false
      properties:
        error:
          description: Per-file intake failure message; empty on success
          examples:
            - ''
          type: string
        ingestionJobId:
          description: Downstream ingestion job id; empty when the object failed intake
          examples:
            - 550e8400-e29b-41d4-a716-446655440000
          format: uuid
          type: string
        name:
          description: Fetched object's base name
          examples:
            - statement-2025-06.ret
          type: string
        transactionCount:
          description: Number of transactions ingested from this object; zero on failure
          examples:
            - 42
          format: int64
          type: integer
      required:
        - name
        - transactionCount
      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:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Bearer token authentication (format: "Bearer {token}")'

````