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

# Durably accept an ordered FinanceKit publisher batch



## OpenAPI

````yaml /openapi.yaml post /api/v1/financekit/publishers/{publisher_id}/batches
openapi: 3.0.3
info:
  title: Sure API
  version: v1
  description: OpenAPI documentation generated from executable request specs.
servers:
  - url: https://app.sure.am
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
paths:
  /api/v1/financekit/publishers/{publisher_id}/batches:
    parameters:
      - name: publisher_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
    post:
      tags:
        - FinanceKit
      summary: Durably accept an ordered FinanceKit publisher batch
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            format: uuid
        - name: X-Sure-Payload-SHA256
          in: header
          required: false
          schema:
            type: string
            pattern: ^[0-9a-f]{64}$
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FinancekitBatch'
        required: true
      responses:
        '202':
          description: Immutable bytes accepted into the inbox
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitBatchReceipt'
        '400':
          description: Malformed or unsupported protocol
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '401':
          description: Invalid publisher credential
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '409':
          description: Digest, sequence, predecessor, generation, or idempotency conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '413':
          description: Payload or record limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '429':
          description: Publisher inbox full
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
      security:
        - financekitPublisher: []
components:
  schemas:
    FinancekitBatch:
      type: object
      additionalProperties: false
      required:
        - protocol_version
        - connection_id
        - publisher_id
        - generation
        - stream_id
        - batch_id
        - sequence
        - capture_id
        - chunk_index
        - chunk_count
        - capture_mode
        - snapshot_complete
        - captured_at
        - selected_source_account_ids
        - events
      properties:
        protocol_version:
          type: integer
          enum:
            - 2
        connection_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        publisher_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        generation:
          type: integer
          minimum: 1
        stream_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        batch_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        sequence:
          type: integer
          minimum: 1
        predecessor_digest:
          type: string
          pattern: ^[0-9a-f]{64}$
        capture_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        chunk_index:
          type: integer
          minimum: 0
        chunk_count:
          type: integer
          minimum: 1
          maximum: 100
        capture_mode:
          type: string
          enum:
            - snapshot
            - delta
        snapshot_complete:
          type: boolean
        captured_at:
          type: string
          format: date-time
        selected_source_account_ids:
          type: array
          minItems: 1
          maxItems: 20
          uniqueItems: true
          items:
            type: string
            format: uuid
            pattern: >-
              ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        events:
          type: array
          maxItems: 500
          items:
            $ref: '#/components/schemas/FinancekitEvent'
      description: >-
        Immutable ordered publisher batch. sequence 1 omits predecessor_digest;
        later batches carry the SHA-256 digest of the preceding payload.
        Omission never deletes data.
    FinancekitBatchReceipt:
      type: object
      additionalProperties: false
      required:
        - connection_id
        - publisher_id
        - generation
        - stream_id
        - batch_id
        - sequence
        - payload_digest
        - status
        - accepted_at
        - applied_at
        - error_code
      properties:
        connection_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        publisher_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        generation:
          type: integer
        stream_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        batch_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        sequence:
          type: integer
        payload_digest:
          type: string
          pattern: ^[0-9a-f]{64}$
        status:
          type: string
          enum:
            - accepted
            - processing
            - applied
            - failed
            - revoked
        accepted_at:
          type: string
          format: date-time
        applied_at:
          type: string
          format: date-time
          nullable: true
        error_code:
          type: string
          nullable: true
    FinancekitError:
      type: object
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: string
    FinancekitEvent:
      oneOf:
        - type: object
          additionalProperties: false
          required:
            - kind
            - account
          properties:
            kind:
              type: string
              enum:
                - account_upsert
            account:
              $ref: '#/components/schemas/FinancekitAccountEvent'
        - type: object
          additionalProperties: false
          required:
            - kind
            - source_account_id
            - lineage_id
            - mapping_version
          properties:
            kind:
              type: string
              enum:
                - account_unavailable
            source_account_id:
              type: string
              format: uuid
              pattern: >-
                ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
            lineage_id:
              type: string
              format: uuid
              pattern: >-
                ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
            mapping_version:
              type: integer
              minimum: 1
        - type: object
          additionalProperties: false
          required:
            - kind
            - balance
          properties:
            kind:
              type: string
              enum:
                - balance_upsert
            balance:
              $ref: '#/components/schemas/FinancekitBalanceEvent'
        - type: object
          additionalProperties: false
          required:
            - kind
            - transaction
          properties:
            kind:
              type: string
              enum:
                - transaction_upsert
            transaction:
              $ref: '#/components/schemas/FinancekitTransactionEvent'
        - type: object
          additionalProperties: false
          required:
            - kind
            - tombstone
          properties:
            kind:
              type: string
              enum:
                - transaction_tombstone
            tombstone:
              $ref: '#/components/schemas/FinancekitTombstoneEvent'
    FinancekitAccountEvent:
      type: object
      additionalProperties: false
      required:
        - source_id
        - lineage_id
        - mapping_version
        - display_name
        - institution_name
        - currency
        - kind
      properties:
        source_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        lineage_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        mapping_version:
          type: integer
          minimum: 1
        display_name:
          type: string
          maxLength: 255
        institution_name:
          type: string
          maxLength: 255
        currency:
          type: string
        kind:
          type: string
          enum:
            - asset
            - liability
        account_description:
          type: string
          maxLength: 1000
        opening_date:
          type: string
          format: date-time
    FinancekitBalanceEvent:
      type: object
      additionalProperties: false
      required:
        - source_id
        - source_account_id
        - lineage_id
        - mapping_version
        - kind
        - observed_at
        - money
      properties:
        source_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        source_account_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        lineage_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        mapping_version:
          type: integer
          minimum: 1
        kind:
          type: string
          enum:
            - available
            - booked
        observed_at:
          type: string
          format: date-time
        money:
          $ref: '#/components/schemas/FinancekitMoney'
    FinancekitTransactionEvent:
      type: object
      additionalProperties: false
      required:
        - source_id
        - source_account_id
        - lineage_id
        - mapping_version
        - amount
        - transaction_description
        - original_transaction_description
        - transaction_type
        - status
        - transacted_at
      properties:
        source_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        source_account_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        lineage_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        mapping_version:
          type: integer
          minimum: 1
        amount:
          $ref: '#/components/schemas/FinancekitMoney'
        foreign_amount:
          $ref: '#/components/schemas/FinancekitMoney'
        foreign_exchange_rate:
          type: string
        transaction_description:
          type: string
          maxLength: 1000
        original_transaction_description:
          type: string
          maxLength: 1000
        transaction_type:
          type: string
          maxLength: 100
        status:
          type: string
          enum:
            - authorized
            - pending
            - booked
            - rejected
            - memo
            - unknown
        transacted_at:
          type: string
          format: date-time
        posted_at:
          type: string
          format: date-time
        merchant_name:
          type: string
          maxLength: 255
        merchant_category_code:
          type: integer
          minimum: -32768
          maximum: 32767
    FinancekitTombstoneEvent:
      type: object
      additionalProperties: false
      required:
        - source_id
        - source_account_id
        - lineage_id
        - mapping_version
      properties:
        source_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        source_account_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        lineage_id:
          type: string
          format: uuid
          pattern: >-
            ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
        mapping_version:
          type: integer
          minimum: 1
    FinancekitMoney:
      type: object
      additionalProperties: false
      required:
        - amount
        - currency
        - direction
      properties:
        amount:
          type: string
          pattern: ^(0|[1-9][0-9]{0,14})(\.[0-9]{1,4})?$
        currency:
          type: string
          pattern: ^[A-Z]{3,5}$
        direction:
          type: string
          enum:
            - credit
            - debit
  securitySchemes:
    financekitPublisher:
      type: http
      scheme: bearer
      bearerFormat: opaque publisher credential
      description: Revocable credential restricted to one FinanceKit publisher upload URL.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.