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

# Wait For Agent Session

> Wait until the Agent turn finishes or timeoutSeconds elapses (default 60, maximum 300). Pass the runId returned by send-message so an earlier turn is not mistaken for this one. Call again when timedOut is true until finished is true. A timeout does not stop the turn.



## OpenAPI

````yaml https://api.krea.ai/openapi.json post /agent/wait-for-session
openapi: 3.1.0
info:
  title: Krea API
  version: v1
servers:
  - url: https://api.krea.ai
    description: Krea API
security:
  - bearerAuth: []
tags:
  - name: General
    description: Core API operations including job management and billing information
  - name: Krea
    description: Krea-owned generation models including Krea 2
  - name: Assets
    description: >-
      Asset management endpoints for uploading and managing images, videos,
      audio files, and 3D models
  - name: Styles
    description: Style (LoRA) generation and management endpoints
  - name: Node Apps
    description: Executing custom node apps built in our nodes tool
  - name: Image
    description: Image generation endpoints
  - name: Image Enhance
    description: Image enhance endpoints
  - name: Video
    description: Video generation endpoints
  - name: Video Enhance
    description: Video enhance and upscale endpoints
  - name: 3D
    description: 3D model generation endpoints
  - name: Audio
    description: Speech and audio generation endpoints
  - name: Usage
    description: Workspace usage reporting
  - name: Agent
    description: Krea Agent sessions
  - name: Utilities
    description: Miscellaneous utility endpoints
paths:
  /agent/wait-for-session:
    post:
      tags:
        - Agent
      summary: Wait For Agent Session
      description: >-
        Wait until the Agent turn finishes or timeoutSeconds elapses (default
        60, maximum 300). Pass the runId returned by send-message so an earlier
        turn is not mistaken for this one. Call again when timedOut is true
        until finished is true. A timeout does not stop the turn.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                sessionId:
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  description: Session id returned by send_agent_message
                timeoutSeconds:
                  default: 60
                  type: integer
                  minimum: 1
                  maximum: 300
                runId:
                  description: >-
                    runId from send_agent_message, so a previous turn's finished
                    status is not mistaken for this one
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
              required:
                - sessionId
      responses:
        '200':
          description: The Agent session result.
          content:
            application/json:
              schema:
                type: object
                properties:
                  sessionId:
                    type: string
                  threadId:
                    type: string
                  runId:
                    type: string
                  status:
                    type: string
                    enum:
                      - not_started
                      - running
                      - completed
                      - failed
                      - cancelled
                  finished:
                    type: boolean
                    description: True once status is completed, failed, or cancelled
                  text:
                    type: string
                    description: Latest assistant message text
                  media:
                    type: array
                    description: >-
                      Media the session produced — the deliverables the agent
                      presented, plus its other generations while a turn is
                      running. Order is not significant. Each item is {jobId,
                      mediaKind?} for a generation (fetch it with get_job),
                      {url} for rehosted media, or {uri, name, mimeType} for a
                      Krea file (read it with read_files)
                    items:
                      type: object
                      properties:
                        jobId:
                          type: string
                        mediaKind:
                          type: string
                          enum:
                            - image
                            - video
                            - audio
                            - 3d
                        url:
                          type: string
                        uri:
                          type: string
                        name:
                          type: string
                        mimeType:
                          type: string
                  error:
                    type: string
                  url:
                    type: string
                    description: The session in the Krea app
                  timedOut:
                    type: boolean
                required:
                  - sessionId
                  - threadId
                  - status
                  - finished
                  - text
                  - media
                  - url
                  - timedOut
        '400':
          description: Invalid JSON body.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  allowedModels:
                    type: array
                    items:
                      type: string
                required:
                  - error
                additionalProperties: false
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  allowedModels:
                    type: array
                    items:
                      type: string
                required:
                  - error
                additionalProperties: false
        '402':
          description: Insufficient compute unit balance or free message limit reached.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  allowedModels:
                    type: array
                    items:
                      type: string
                required:
                  - error
                additionalProperties: false
        '403':
          description: The requested model is not included in the workspace plan.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  allowedModels:
                    type: array
                    items:
                      type: string
                required:
                  - error
                additionalProperties: false
        '404':
          description: Session or attachment not found or not accessible.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  allowedModels:
                    type: array
                    items:
                      type: string
                required:
                  - error
                additionalProperties: false
        '409':
          description: A turn is already in progress.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  allowedModels:
                    type: array
                    items:
                      type: string
                required:
                  - error
                additionalProperties: false
        '422':
          description: Invalid input or desktop app unavailable.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  allowedModels:
                    type: array
                    items:
                      type: string
                required:
                  - error
                additionalProperties: false
components:
  securitySchemes:
    bearerAuth:
      scheme: bearer
      bearerFormat: Bearer
      type: http

````

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