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

# Credential the background publisher



## OpenAPI

````yaml /openapi.yaml post /api/v1/financekit/connections/{connection_id}/credential
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/connections/{connection_id}/credential:
    parameters:
      - name: connection_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
    post:
      tags:
        - FinanceKit
      summary: Credential the background publisher
      responses:
        '200':
          description: Publisher configuration and a newly issued restricted credential
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitPublisherConfiguration'
        '400':
          description: Malformed or unsupported protocol
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '401':
          description: Invalid or missing authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '403':
          description: Insufficient permission or publisher eligibility
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '409':
          description: Enrollment, mapping, lineage, generation, or stream conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '413':
          description: Payload or record limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '422':
          description: Invalid typed record or consent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
        '429':
          description: Rate limited or publisher inbox full
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancekitError'
      security:
        - apiKeyAuth: []
        - oauth2:
            - read_write
components:
  schemas:
    FinancekitPublisherConfiguration:
      allOf:
        - $ref: '#/components/schemas/FinancekitConnection'
        - type: object
          required:
            - protocol_version
            - server_url
            - upload_url
            - consent
            - account_bindings
            - max_records_per_batch
            - max_bytes_per_batch
            - publisher_credential
          properties:
            protocol_version:
              type: integer
              enum:
                - 2
            server_url:
              type: string
              format: uri
            upload_url:
              type: string
              format: uri
            consent:
              $ref: '#/components/schemas/FinancekitConsent'
            account_bindings:
              type: array
              items:
                $ref: '#/components/schemas/FinancekitAccountBinding'
            max_records_per_batch:
              type: integer
              minimum: 1
            max_bytes_per_batch:
              type: integer
              minimum: 1
            publisher_credential:
              type: string
              writeOnly: true
    FinancekitError:
      type: object
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: string
    FinancekitConnection:
      type: object
      required:
        - id
        - connection_id
        - publisher_id
        - status
        - generation
        - next_sequence
        - open_conflicts
      properties:
        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}$
        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}$
        status:
          type: string
          enum:
            - pending_mapping
            - active
            - repair_required
            - revoked
        generation:
          type: integer
          minimum: 1
        stream_id:
          allOf:
            - 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}$
          nullable: true
        next_sequence:
          type: integer
          minimum: 1
        repair_reason:
          type: string
          nullable: true
        last_device_contact_at:
          allOf:
            - type: string
              format: date-time
          nullable: true
        last_accepted_at:
          allOf:
            - type: string
              format: date-time
          nullable: true
        last_imported_at:
          allOf:
            - type: string
              format: date-time
          nullable: true
        last_downstream_at:
          allOf:
            - type: string
              format: date-time
          nullable: true
        last_captured_at:
          allOf:
            - type: string
              format: date-time
          nullable: true
        open_conflicts:
          type: integer
          minimum: 0
        accounts:
          type: array
          items:
            $ref: '#/components/schemas/FinancekitAccountMapping'
        pagination:
          $ref: '#/components/schemas/Pagination'
        purge_requested_at:
          allOf:
            - type: string
              format: date-time
          nullable: true
        purge_completed_at:
          allOf:
            - type: string
              format: date-time
          nullable: true
        disposition:
          type: string
          enum:
            - retain
            - discard
    FinancekitConsent:
      type: object
      additionalProperties: false
      required:
        - version
        - granted_at
        - selected_source_account_ids
        - upload_authorized
        - family_visibility_acknowledged
        - remote_processing_acknowledged
      properties:
        version:
          type: integer
          enum:
            - 1
        granted_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}$
        upload_authorized:
          type: boolean
          enum:
            - true
        family_visibility_acknowledged:
          type: boolean
          enum:
            - true
        remote_processing_acknowledged:
          type: boolean
          enum:
            - true
    FinancekitAccountBinding:
      type: object
      additionalProperties: false
      required:
        - source_account_id
        - lineage_id
        - mapping_version
      properties:
        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
    FinancekitAccountMapping:
      type: object
      additionalProperties: false
      required:
        - source_id
        - lineage_id
        - mapping_version
        - name
        - institution_name
        - currency
        - accountable_type
        - subtype
        - ledger_timezone
        - account_id
      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
        name:
          type: string
        institution_name:
          type: string
          nullable: true
        currency:
          type: string
        accountable_type:
          type: string
        subtype:
          type: string
        ledger_timezone:
          type: string
        account_id:
          allOf:
            - 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}$
          nullable: true
    Pagination:
      type: object
      required:
        - page
        - per_page
        - total_count
        - total_pages
      properties:
        page:
          type: integer
          minimum: 1
        per_page:
          type: integer
          minimum: 1
        total_count:
          type: integer
          minimum: 0
        total_pages:
          type: integer
          minimum: 0
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      name: X-Api-Key
      in: header
      description: API key for authentication. Generate one from your account settings.
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: /oauth/authorize
          tokenUrl: /oauth/token
          scopes:
            read: Read access
            read_write: Read and write access

````

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