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

# Send Message

> Send a message to a running agent task. The message ID is delivered via SSE (UserMessageEvent with action=queued).



## OpenAPI

````yaml /api-reference/tasks.yaml post /tasks/{task_id}/message
openapi: 3.1.0
info:
  title: Tasks
  version: v1
servers:
  - url: https://api.mobilerun.ai
    description: Droidrun Cloud API
security:
  - bearerAuth: []
paths:
  /tasks/{task_id}/message:
    post:
      tags:
        - Tasks
      summary: Send Message
      description: >-
        Send a message to a running agent task. The message ID is delivered via
        SSE (UserMessageEvent with action=queued).
      operationId: send_message_tasks__task_id__message_post
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Task Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskMessageCreate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskMessageResponse'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not Found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Content
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Mobilerun from '@mobilerun/sdk';


            const client = new Mobilerun({
              apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
            });


            const response = await
            client.tasks.sendMessage('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
              message: 'x',
            });


            console.log(response.sent);
        - lang: Python
          source: |-
            import os
            from mobilerun_sdk import Mobilerun

            client = Mobilerun(
                api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"),  # This is the default and can be omitted
            )
            response = client.tasks.send_message(
                task_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                message="x",
            )
            print(response.sent)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/droidrun-cloud-go\"\n\t\"github.com/stainless-sdks/droidrun-cloud-go/option\"\n)\n\nfunc main() {\n\tclient := mobileruncloud.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.Tasks.SendMessage(\n\t\tcontext.TODO(),\n\t\t\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\",\n\t\tmobileruncloud.TaskSendMessageParams{\n\t\t\tMessage: \"x\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Sent)\n}\n"
        - lang: CLI
          source: |-
            mobilerun-cloud tasks send-message \
              --api-key 'My API Key' \
              --task-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e \
              --message x
components:
  schemas:
    TaskMessageCreate:
      properties:
        message:
          type: string
          maxLength: 4000000
          minLength: 1
          title: Message
          description: Message to send to the running agent
      type: object
      required:
        - message
      title: TaskMessageCreate
    TaskMessageResponse:
      properties:
        sent:
          type: boolean
          title: Sent
          description: Whether the message was queued for delivery
      type: object
      required:
        - sent
      title: TaskMessageResponse
    ErrorResponse:
      properties:
        title:
          type: string
          title: Title
          description: The title of the error
        status:
          type: integer
          title: Status
          description: The status code of the error
        detail:
          type: string
          title: Detail
          description: The detail of the error
        errors:
          items: {}
          type: array
          title: Errors
          description: The errors
      type: object
      required:
        - title
        - status
        - detail
        - errors
      title: ErrorResponse
    UnauthorizedResponse:
      properties:
        title:
          type: string
          title: Title
          description: The title of the error
          default: Unauthorized
        status:
          type: integer
          title: Status
          description: The status code of the error
          default: 401
        detail:
          type: string
          title: Detail
          description: The detail of the error
          default: You are not authorized to access this resource
        errors:
          items: {}
          type: array
          title: Errors
          description: The errors
          default: []
      type: object
      title: UnauthorizedResponse
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Opaque
      description: Bearer token via Authorization header

````