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

# Send a message to a coding session on an imported app

> <Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Send a message, an answer or an approval to a coding session. While the session works, the message is folded into its current turn; while it waits for input, `text` or `answers` answers the open question and `approve` answers an approval request; after it completes, fails or is cancelled, the message starts a follow-up turn on the same branch and its pull request updates. Once the session's pull request has merged, the session takes no more messages and the request is refused with `pull_request_merged`. The request returns before delivery: poll the session for progress. Only the session's own user can send messages; set `author` to attribute text to someone else in a shared conversation. Send `input_request_id` with an answer so a session that has moved on refuses it with `input_request_changed`, also when the session moved on before delivery. Requires an Idempotency-Key; retries with the same key and body return the same input. Starts paid work like a launch. Limited to 30 requests per minute per user.



## OpenAPI

````yaml /developers/references/app-management/app-management-openapi.json post /api/apps/{app_id}/imported/sessions/{session_id}/messages
openapi: 3.1.0
info:
  title: Base44 App Management API
  version: 1.0.0
servers:
  - url: https://app.base44.com
security:
  - PersonalAccessTokenAuth: []
paths:
  /api/apps/{app_id}/imported/sessions/{session_id}/messages:
    post:
      summary: Send a message to a coding session on an imported app
      description: >-
        <Info>This API is in beta. Endpoints, fields, and behavior may still
        change, so avoid depending on it in production.</Info>


        Send a message, an answer or an approval to a coding session. While the
        session works, the message is folded into its current turn; while it
        waits for input, `text` or `answers` answers the open question and
        `approve` answers an approval request; after it completes, fails or is
        cancelled, the message starts a follow-up turn on the same branch and
        its pull request updates. Once the session's pull request has merged,
        the session takes no more messages and the request is refused with
        `pull_request_merged`. The request returns before delivery: poll the
        session for progress. Only the session's own user can send messages; set
        `author` to attribute text to someone else in a shared conversation.
        Send `input_request_id` with an answer so a session that has moved on
        refuses it with `input_request_changed`, also when the session moved on
        before delivery. Requires an Idempotency-Key; retries with the same key
        and body return the same input. Starts paid work like a launch. Limited
        to 30 requests per minute per user.
      operationId: >-
        submit_session_message_api_apps__app_id__imported_sessions__session_id__messages_post
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
            description: The session's identifier.
            examples:
              - 6820f3a4e7b91d003c45a1f2
            title: Session Id
          description: The session's identifier.
        - name: app_id
          in: path
          required: true
          schema:
            type: string
            title: App Id
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 200
            pattern: ^[A-Za-z0-9_.:-]+$
            description: >-
              A unique key for this message. Retrying with the same key and body
              returns the same input instead of delivering it twice; a different
              body with the same key returns idempotency_conflict.
            examples:
              - thread-reply-1715000000.0001
            title: Idempotency-Key
          description: >-
            A unique key for this message. Retrying with the same key and body
            returns the same input instead of delivering it twice; a different
            body with the same key returns idempotency_conflict.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitSessionInput'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionInputResponse'
        '401':
          description: '`unauthenticated`: Missing or invalid credentials.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '403':
          description: '`forbidden`: You don''t have write access to this app or repository.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '404':
          description: '`not_found`: The imported app or session was not found.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '409':
          description: >-
            `idempotency_conflict`: The key was used with a different message.
            `input_request_changed`: The question this answers is no longer
            open. `session_busy`: The session is stopping; send the message once
            it has stopped. `pull_request_merged`: The session's pull request
            was merged, so its branch takes no more turns; start a new session.
            `branch_unavailable`: The session's branch was deleted. `conflict`:
            The session no longer belongs to this workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '422':
          description: >-
            `invalid_request`: The input or Idempotency-Key is invalid.
            `source_ref_not_found`: `source_ref` isn't a branch in the connected
            repository.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '429':
          description: '`rate_limited`: Retry after the number of seconds in Retry-After.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '503':
          description: >-
            Database temporarily unavailable (`database_unavailable`): the data
            cluster did not answer in time. Retry after the `Retry-After`
            seconds.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
              examples:
                database_unavailable:
                  summary: database_unavailable
                  value:
                    error:
                      code: database_unavailable
                      message: Database temporarily unavailable, please retry
                      details: {}
      security:
        - PersonalAccessTokenAuth:
            - full_access
        - WorkspaceApiKeyAuth:
            - full_access
        - WorkspaceApiKeyBearerAuth:
            - full_access
components:
  schemas:
    SubmitSessionInput:
      properties:
        text:
          anyOf:
            - type: string
              maxLength: 20000
              minLength: 1
            - type: 'null'
          title: Text
          description: >-
            A message for the session. While it works, the message is folded
            into the current turn; while it waits for input, it answers the open
            question; after it finishes, it starts a follow-up turn on the same
            branch.
          examples:
            - Also add a test for the redaction.
        answers:
          anyOf:
            - items:
                $ref: '#/components/schemas/SessionAnswer'
              type: array
              maxItems: 10
              minItems: 1
            - type: 'null'
          title: Answers
          description: >-
            Structured answers to the open question, by question index. Requires
            `input_request_id`.
        approve:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Approve
          description: >-
            Approve (`true`) or decline (`false`) the open approval request.
            Requires `input_request_id`.
        input_request_id:
          anyOf:
            - type: string
              maxLength: 100
              minLength: 1
            - type: 'null'
          title: Input Request Id
          description: >-
            The `input_request_id` from Get a coding session's open question. A
            session that has moved on refuses the input with
            `input_request_changed`.
        author:
          anyOf:
            - type: string
              maxLength: 100
              minLength: 1
            - type: 'null'
          title: Author
          description: >-
            Who wrote the message, when it isn't the session's own user, for
            example a teammate in a shared thread. The text is attributed to
            them.
          examples:
            - Dana
        file_urls:
          anyOf:
            - items:
                type: string
              type: array
              maxItems: 10
              minItems: 1
            - type: 'null'
          title: File Urls
          description: >-
            Images for the agent to see alongside the text: URLs of files
            uploaded to this app, or `null`.
      additionalProperties: false
      type: object
      title: SubmitSessionInput
    SessionInputResponse:
      properties:
        id:
          type: string
          title: Id
          description: The input's identifier.
          examples:
            - 6820f3a4e7b91d003c45a1f9
        state:
          type: string
          enum:
            - pending
            - delivered
            - failed
          title: State
          description: '`pending` until the session takes the input.'
          examples:
            - pending
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
          description: >-
            Why a `failed` input wasn't delivered, for example
            `input_request_changed`, `session_busy`, `cancelled` or
            `delivery_interrupted`; `null` otherwise.
          examples:
            - null
        session:
          $ref: '#/components/schemas/SessionResponse'
      type: object
      required:
        - id
        - state
        - session
      title: SessionInputResponse
    StandardErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/StandardError'
          description: What went wrong.
      type: object
      required:
        - error
      title: StandardErrorEnvelope
      description: The error body returned in the standard envelope.
    SessionAnswer:
      properties:
        question_index:
          type: integer
          maximum: 9
          minimum: 0
          title: Question Index
          description: Zero-based index of the question being answered.
          examples:
            - 0
        selected_label:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: Selected Label
          description: The chosen option's label for a single-choice question.
          examples:
            - Both call sites
        selected_labels:
          anyOf:
            - items:
                type: string
              type: array
              maxItems: 20
            - type: 'null'
          title: Selected Labels
          description: The chosen options' labels for a multi-select question.
          examples:
            - - Redis
              - MongoDB
        custom_text:
          anyOf:
            - type: string
              maxLength: 20000
            - type: 'null'
          title: Custom Text
          description: A free-text answer instead of, or in addition to, an option.
          examples:
            - Only the retry path
      additionalProperties: false
      type: object
      required:
        - question_index
      title: SessionAnswer
    SessionResponse:
      properties:
        launch_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Launch Key
          description: >-
            The original Idempotency-Key, or `null` for sessions created before
            key recovery was recorded. Use the same principal and key to retry a
            queued launch.
          examples:
            - flag-cleanup-123
        client_reference:
          anyOf:
            - type: string
            - type: 'null'
          title: Client Reference
          description: Your application reconciliation reference, or null.
          examples:
            - release-task-123
        id:
          type: string
          title: Id
          description: The session's opaque identifier.
          examples:
            - 6820f3a4e7b91d003c45a1f2
        created_by_user_id:
          type: string
          title: Created By User Id
          description: >-
            The ID of the user who launched the session. A session launched with
            a workspace API key reports the key's owner.
          examples:
            - 6820f3a4e7b91d003c45a1f4
        state:
          type: string
          enum:
            - queued
            - running
            - opening_pull_request
            - needs_input
            - completed
            - failed
            - cancelling
            - cancelled
          title: State
          description: >-
            The session's state: `queued`, `running`, `opening_pull_request`,
            `needs_input`, `completed`, `failed`, `cancelling`, or `cancelled`.
          examples:
            - running
        message_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Message Id
          description: >-
            The UUID of the session's user message, or `null` before dispatch.
            Queued processing updates it to the UUID used for the turn.
          examples:
            - ca00e880-1111-4444-aaaa-ccddeeff0011
        input_request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Input Request Id
          description: >-
            Opaque identifier of the current question or approval pause, or
            `null` when the session is not waiting for input or the pause
            predates identifier tracking. Use it to deduplicate notifications
            for repeated input requests. To answer, use the `input_request_id`
            from Get a coding session's open question.
          examples:
            - ca00e880-1111-4444-aaaa-ccddeeff0011
        repository_full_name:
          type: string
          title: Repository Full Name
          description: The connected repository the session runs in.
          examples:
            - acme/project
        branch_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Branch Id
          description: >-
            The session's Base Code branch identifier, or `null` before
            provisioning.
          examples:
            - 6820f3a4e7b91d003c45a1f3
        branch_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Branch Name
          description: The session's working Git branch, or `null` before provisioning.
          examples:
            - base-code/fix-login-redirect-45a1f2
        session_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Url
          description: >-
            The Base Code editor URL for inspecting the session or answering
            pending questions, or `null` until its branch is provisioned.
          examples:
            - >-
              https://app.base44.com/apps/6820f3a4e7b91d003c45a1f2/editor/preview
        pull_request:
          anyOf:
            - $ref: '#/components/schemas/SessionPullRequest'
            - type: 'null'
          description: >-
            The pull request of the branch the session launched on, in the
            connected repository, or `null` until one is opened. `pull_requests`
            lists every pull request of the session.
          examples:
            - number: 123
              url: https://github.com/acme/project/pull/123
        pull_requests:
          items:
            $ref: '#/components/schemas/SessionPullRequestListItem'
          type: array
          title: Pull Requests
          description: >-
            Every pull request of the session, for each branch in `branches` and
            each repository: the connected repository and the repositories added
            to a multi-repository project. Ordered by branch as in `branches`;
            within a branch, the connected repository first, then the added
            repositories. Empty until a pull request is opened.
          examples:
            - - branch_id: 6820f3a4e7b91d003c45a1f3
                branch_name: base-code/fix-login-redirect-45a1f2
                is_draft: false
                number: 123
                repository_full_name: acme/project
                state: open
                url: https://github.com/acme/project/pull/123
              - branch_id: 6820f3a4e7b91d003c45a1f3
                branch_name: base-code/fix-login-redirect-45a1f2
                is_draft: false
                number: 45
                repository_full_name: acme/api
                state: merged
                url: https://github.com/acme/api/pull/45
        branches:
          items:
            $ref: '#/components/schemas/SessionBranch'
          type: array
          title: Branches
          description: >-
            The session's branches: the branch it launched on first, then the
            branches opened in the same Base Code session (for example after
            continuing it in the editor), in the order they were added. Merged
            and deleted branches stay listed. Empty before provisioning.
          examples:
            - - branch_id: 6820f3a4e7b91d003c45a1f3
                branch_name: base-code/fix-login-redirect-45a1f2
                is_current: false
              - branch_id: 6820f3a4e7b91d003c45a1f5
                branch_name: fix-login-copy
                is_current: true
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
          description: The stable failure cause, or `null` if there is no failure.
          examples:
            - execution_failed
        error_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Reason
          description: >-
            A short, human-readable explanation of `error_code` and what to do
            next, or `null` if there is no failure or cut-short turn.
          examples:
            - >-
              The branch's sandbox ran out of disk space. Crash dumps were
              removed; send the message again.
        outcome:
          anyOf:
            - type: string
              enum:
                - pull_request
                - answer
            - type: 'null'
          title: Outcome
          description: >-
            How a `completed` session ended: `pull_request` when it opened or
            updated a pull request, `answer` when it ended without one and
            replied instead; `has_unpublished_changes` says whether that branch
            still changes files. `null` until the session completes. Pull
            requests opened later on the session's other branches don't change
            it; read `pull_requests` for those.
          examples:
            - pull_request
        summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary
          description: >-
            The session's final reply in Markdown, up to 10,000 characters: the
            answer for an `answer` outcome, the change summary for a
            `pull_request` outcome. `null` until the session publishes.
          examples:
            - Removed the retired flag and kept the enabled behavior.
        live_turns:
          items:
            $ref: '#/components/schemas/SessionLiveTurn'
          type: array
          title: Live Turns
          description: >-
            Turns running on the session's branches (every branch in `branches`)
            after it finished: a PR Watch turn fixing review findings, or a turn
            someone started in the editor. Empty when nothing is running.
            `state` keeps its finished value, so poll this field to tell a
            finished, idle session from one still working.
          examples:
            - - branch_id: 6820f3a4e7b91d003c45a1f3
        latest_watch_summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Latest Watch Summary
          description: >-
            The final reply of the most recent PR Watch turn on the session's
            branch, in Markdown up to 10,000 characters, or `null` when no Watch
            turn has replied. A Watch turn that changed nothing leaves `summary`
            as it was, so its conclusion appears only here.
          examples:
            - >-
              Re-ran the flaky check: infrastructure timeout, no code change
              needed.
        has_unpublished_changes:
          type: boolean
          title: Has Unpublished Changes
          description: >-
            `true` when an `answer` session's branch changes files that no pull
            request carries yet: send a message asking for one to have the agent
            open it. `false` otherwise.
          default: false
          examples:
            - false
        push_failed:
          type: boolean
          title: Push Failed
          description: >-
            `true` when a `pull_request` session's last changes did not reach
            the pull request's branch on GitHub because the push failed;
            `summary` then starts with a warning that says where the work is.
            `false` otherwise.
          default: false
          examples:
            - false
      type: object
      required:
        - id
        - created_by_user_id
        - state
        - message_id
        - repository_full_name
        - branch_id
        - branch_name
        - session_url
        - pull_request
        - error_code
      title: SessionResponse
    StandardError:
      properties:
        code:
          type: string
          title: Code
          description: >-
            Stable machine-readable cause of the failure. Match on this, not on
            `message`.
          example: not_found
        message:
          type: string
          title: Message
          description: Human-readable explanation. It isn't a stable contract.
          example: App not found
        details:
          additionalProperties: true
          type: object
          title: Details
          description: >-
            Structured context for the failure, or an empty object when there's
            none.
          example: {}
      type: object
      required:
        - code
        - message
      title: StandardError
    SessionPullRequest:
      properties:
        number:
          type: integer
          title: Number
          description: The pull request's number in the connected repository.
          examples:
            - 123
        url:
          type: string
          title: Url
          description: The pull request's URL.
          examples:
            - https://github.com/acme/project/pull/123
      type: object
      required:
        - number
        - url
      title: SessionPullRequest
    SessionPullRequestListItem:
      properties:
        repository_full_name:
          type: string
          title: Repository Full Name
          description: >-
            The repository the pull request is in: the connected repository, or
            a repository added to a multi-repository project.
          examples:
            - acme/project
        number:
          type: integer
          title: Number
          description: The pull request's number in its repository.
          examples:
            - 123
        url:
          type: string
          title: Url
          description: The pull request's URL.
          examples:
            - https://github.com/acme/project/pull/123
        branch_id:
          type: string
          title: Branch Id
          description: The session branch whose Git branch is the pull request's head.
          examples:
            - 6820f3a4e7b91d003c45a1f3
        branch_name:
          type: string
          title: Branch Name
          description: The pull request's head Git branch.
          examples:
            - base-code/fix-login-redirect-45a1f2
        state:
          anyOf:
            - type: string
              enum:
                - open
                - merged
                - closed
            - type: 'null'
          title: State
          description: >-
            `open`, `merged`, or `closed` (closed without a merge), or `null`
            when GitHub could not be read. A merged branch's pull request in the
            connected repository is `merged`.
          examples:
            - open
        is_draft:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Draft
          description: >-
            Whether the pull request is a draft, or `null` when `state` is
            `null`.
          examples:
            - false
      type: object
      required:
        - repository_full_name
        - number
        - url
        - branch_id
        - branch_name
        - state
        - is_draft
      title: SessionPullRequestListItem
    SessionBranch:
      properties:
        branch_id:
          type: string
          title: Branch Id
          description: The Base Code branch identifier.
          examples:
            - 6820f3a4e7b91d003c45a1f3
        branch_name:
          type: string
          title: Branch Name
          description: The branch's Git branch.
          examples:
            - base-code/fix-login-redirect-45a1f2
        is_current:
          type: boolean
          title: Is Current
          description: Whether this is the branch the session's conversation works on now.
          examples:
            - true
      type: object
      required:
        - branch_id
        - branch_name
        - is_current
      title: SessionBranch
    SessionLiveTurn:
      properties:
        branch_id:
          type: string
          title: Branch Id
          description: The session branch the running turn works on.
          examples:
            - 6820f3a4e7b91d003c45a1f3
      type: object
      required:
        - branch_id
      title: SessionLiveTurn
  securitySchemes:
    PersonalAccessTokenAuth:
      type: http
      scheme: bearer
      description: >-
        Personal access token, sent as `Authorization: Bearer <token>`. Each
        operation lists the permission it needs: `read_only` or `full_access`. A
        full-access token can call every operation. A read-only token can call
        only the operations that list `read_only`; anything else returns 403
        `read_only_credential_route_not_allowed`.
    WorkspaceApiKeyAuth:
      type: apiKey
      in: header
      name: api_key
      description: >-
        Workspace API key, sent as `api_key: <key>`. Each operation that accepts
        one lists what the key needs: a permission, `read_only` or
        `full_access`, like a personal access token, or a scope. A key without
        the scope gets 403 `workspace_api_key_scope_required`.
    WorkspaceApiKeyBearerAuth:
      type: http
      scheme: bearer
      description: >-
        Workspace API key, sent as `Authorization: Bearer <key>`. Accepted
        wherever `api_key` is, with the same permission.

````

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