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

# Send a message to the granted deployment and stream the answer

> The streaming form of `connectInteract`, relayed through the same proxy: the customer's agent's NDJSON verbatim, one JSON object per line. Anything that can fail cheaply fails before the first byte, so an early failure is still a normal JSON error; a mid-stream failure arrives as one final `StreamError` line.



## OpenAPI

````yaml /api-reference/openapi.yaml post /connect/interact/stream
openapi: 3.0.3
info:
  title: Payman Connect API
  version: 0.1.0
  description: >-
    The HTTP contract behind Payman Connect: exchange a customer's consent for a
    grant, send actions against the accounts it reaches, and follow an approval
    to its receipt. Every call carries your app key, and every call after the
    exchange carries the grant. Non-2xx responses share one `ApiError` envelope.
    Most integrations never write these calls: the SDK speaks them for you.
servers:
  - url: https://paygent-cloud-server-production.up.railway.app
    description: Current hosted Railway deployment
  - url: http://localhost:8891
    description: A local stack
security:
  - bearerAuth: []
tags:
  - name: Connect
    description: >-
      Third-party access. A registered app presents its app key together with a
      grant token its customer consented to; the pair reaches exactly the one
      deployment the grant names, and nothing else on this API.
paths:
  /connect/interact/stream:
    post:
      tags:
        - Connect
      summary: Send a message to the granted deployment and stream the answer
      description: >-
        The streaming form of `connectInteract`, relayed through the same proxy:
        the customer's agent's NDJSON verbatim, one JSON object per line.
        Anything that can fail cheaply fails before the first byte, so an early
        failure is still a normal JSON error; a mid-stream failure arrives as
        one final `StreamError` line.
      operationId: connectInteractStream
      parameters:
        - $ref: '#/components/parameters/idempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentInteractionRequest'
      responses:
        '200':
          description: >-
            The customer's agent's event stream. On a multi-provider grant the
            router's no-dispatch outcomes (`needs_provider` /
            `no_capable_provider`) land BEFORE the first byte and arrive as a
            plain `application/json` `ConnectRoutingDecision` instead of a
            stream — no agent ran, so there were no bytes to relay.
          headers:
            x-paygent-environment:
              schema:
                $ref: '#/components/schemas/ConnectEnvironment'
              description: >-
                Which mode is serving this stream. The header is the stream's
                only environment signal — the body is the agent's bytes, relayed
                verbatim, and nothing is injected into it.
          content:
            application/x-ndjson:
              schema:
                type: string
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectRoutingDecision'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          description: >-
            Invalid Connect credentials (`invalid_connect_credentials`).
            `details.reason` names your own credential's state when that is what
            failed — see the non-streaming route's 401.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: >-
            The grant does not carry the `interact` scope
            (`insufficient_scope`), or a sandbox app's grant points at a
            non-sandbox provider (`sandbox_provider_mismatch`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: >-
            The deployment cannot serve this in its current state: paused
            (`deployment_paused` — `details.pausedReason` is `url_change` when
            the platform paused it over an agent URL move, null when the owner
            paused it themselves), or missing required configuration
            (`deployment_incomplete`, with `details.missingFields`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '502':
          description: The agent rejected the call
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '503':
          description: >-
            The agent is still working on this customer's previous request
            (`agent_busy`). Nothing ran and nothing was charged; the same call
            succeeds once that run finishes.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      security:
        - connectAppKey: []
          connectGrant: []
components:
  parameters:
    idempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        minLength: 16
        maxLength: 255
        pattern: ^[A-Za-z0-9._~-]+$
      description: >-
        A key of your own choosing that names ONE instruction, so a retry of it
        is not a second execution. Scoped to your grant, so it cannot collide
        with another app's.
  schemas:
    AgentInteractionRequest:
      type: object
      required:
        - userInput
      properties:
        userInput:
          type: string
          minLength: 1
        sessionId:
          type: string
          nullable: true
          description: >-
            Reuse within one conversation to thread history. On Connect, also
            scopes short-lived explicit account selection for referential
            follow-ups; use a new ID for each chat.
        sessionOwnerLabel:
          type: string
          nullable: true
          description: Display name for the end user; defaults to the caller's email.
        sessionAttributes:
          type: object
          additionalProperties:
            type: string
          nullable: true
          description: >-
            Extra per-call attributes merged into the ones derived from the
            stored configuration. Configuration wins on a key collision, so a
            caller cannot override a stored bank token from the request body.
        analysisMode:
          allOf:
            - $ref: '#/components/schemas/AnalysisMode'
          nullable: true
        provider:
          type: string
          nullable: true
          maxLength: 256
          description: >-
            Which connected account a multi-provider wallet should use — an
            institution type (`BREX`) or an account label, exactly as a
            `needs_provider` result's candidates listed them. Optional.
    ConnectEnvironment:
      type: string
      enum:
        - sandbox
        - live
      description: >-
        Which world a Connect app lives in. `sandbox` — the Durango demo bank,
        where nothing is money; a sandbox app may declare only DURANGO agents
        and its credentials are minted as `pgc_app_test_…` / `pgc_grant_test_…`.
        `live` — everything else; a live app cannot declare DURANGO agents.
    ConnectRoutingDecision:
      type: object
      required:
        - status
        - message
        - candidates
        - howToProceed
      description: >-
        The multi-provider router's no-dispatch outcomes, served only on grants
        that carry more than one member (`CONNECT_MULTI_PROVIDER`). A NORMAL
        result, not an error: HTTP 200, relayed to the model like any other
        outcome.
      properties:
        status:
          type: string
          enum:
            - needs_provider
            - no_capable_provider
        message:
          type: string
        candidates:
          type: array
          items:
            $ref: '#/components/schemas/ConnectRoutingCandidate'
        howToProceed:
          type: string
          description: What the app (or its model) should do next, in one line.
    ApiError:
      type: object
      required:
        - category
        - code
        - message
      description: >-
        The envelope every non-2xx response uses. `code` is a stable slug a
        client can match on exactly; `message` is safe to show a user as-is.
      properties:
        category:
          $ref: '#/components/schemas/ApiErrorCategory'
        code:
          type: string
          example: agent_not_configured
        message:
          type: string
          example: Configure this agent before sending it messages.
        details:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            Structured context — field errors, the agent's own status, and so
            on.
    AnalysisMode:
      type: string
      enum:
        - fast
        - deep
    ConnectRoutingCandidate:
      type: object
      required:
        - provider
        - institutionName
        - accountLabel
        - capabilities
      description: One account the wallet could route the instruction to.
      properties:
        provider:
          type: string
          description: >-
            The institution type enum value — the string to pass back in the
            request's optional `provider` field.
        institutionName:
          type: string
          description: What a person calls the bank ("Brex", "Coinbase").
        accountLabel:
          type: string
          description: >-
            The deployment's display name — what disambiguates two accounts at
            one institution. Falls back to the institution name.
        capabilities:
          type: string
          description: One human line on what this account can execute.
    ApiErrorCategory:
      type: string
      description: >-
        Fixed taxonomy, matching K2's so a client that already handles K2 errors
        handles these too.
      enum:
        - VALIDATION
        - AUTH
        - PERMISSION
        - NOT_FOUND
        - CONFLICT
        - RATE_LIMIT
        - UPSTREAM
        - TIMEOUT
        - INTERNAL
  responses:
    BadRequest:
      description: The request failed validation
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    NotFound:
      description: No such resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    TooManyRequests:
      description: >-
        Rate limited (`rate_limited`). `details` carries the limit, the window
        and how long until it reopens.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    connectAppKey:
      type: apiKey
      in: header
      name: x-paygent-connect-app-key
      description: >-
        A Connect app key (`pgc_app_…`), identifying the registered third-party
        app. Always presented together with `connectGrant` — the pair is one
        credential, and either half alone is refused. Accepted on the
        `/connect/*` surface only.
    connectGrant:
      type: apiKey
      in: header
      name: x-paygent-connect-grant
      description: >-
        A Connect grant token (`pgc_grant_…`): one user's consent for the
        presenting app to reach one deployment. Every failure mode — missing,
        malformed, revoked, expired, or paired with the wrong app key — answers
        the same 401 `invalid_connect_credentials`.

````

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