> ## 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://api.paygent.payman.ai
    description: Production
  - 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
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentInteractionRequest'
      responses:
        '200':
          description: The customer's agent's event stream
          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
        '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'
      security:
        - connectAppKey: []
          connectGrant: []
components:
  schemas:
    AgentInteractionRequest:
      type: object
      required:
        - userInput
      properties:
        userInput:
          type: string
          minLength: 1
        sessionId:
          type: string
          nullable: true
          description: Reuse across turns to thread conversation history.
        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
    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.
    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
    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`.

````