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

# Create message

> Send a message within an existing conversation.

**Purpose**: Facilitates communication within a conversation by allowing authorized users or systems to send messages to the patient, subject to various validation checks based on the origin type, direction, and the current state of the conversation.

**Use Case**: This action is critical for maintaining real-time engagement with patients, allowing practices to respond dynamically as needed.

**Field Descriptions**:

- **message**: The content of the message to be sent within the conversation. This field is required, cannot be empty, and must be between 1 and 1024 characters.

- **origin_type**: Specifies the origin of the message. Available choices are:
  - `SYSTEM_RESPONSIVE`: Message sent by the system in response mode.
  - `AGENT`: Message sent manually by an agent.
- **direction**: Defines the direction of the message, indicating if it is inbound or outbound. Available choices are:
  - `INBOUND`: Incoming message to the system.
  - `OUTBOUND`: Outgoing message from the system.



## OpenAPI

````yaml /openapi/peerlogic-api.json post /api/conversations/{id}/message/
openapi: 3.1.0
info:
  title: Peerlogic API
  version: 1.0.0
  description: >-
    Customer-facing API reference for accessing Peerlogic calls, insights,
    conversations, tasks, opportunities, subscriptions, and events.
servers:
  - url: https://api.prod.peerlogic.com
    description: Production
security: []
tags:
  - name: Authentication
    description: Obtain an access token for authenticated API requests.
  - name: Call insights
    description: Call records and aggregate performance insights.
  - name: Transcripts
    description: Transcripts, summaries, sentiment, pauses, and call-purpose details.
  - name: Aimee
    description: Aimee activity, configuration, and performance insights.
  - name: Conversations
    description: Conversation records, messages, and conversation actions.
  - name: Tasks
    description: Customer tasks and task workflow actions.
  - name: Opportunities
    description: Opportunities and follow-up reporting.
  - name: Subscriptions and events
    description: >-
      Create and manage event subscriptions, then inspect event records and
      analytics. For the complete webhook delivery flow, see the Webhooks and
      subscriptions guide.
  - name: Organizations and practices
    description: >-
      Discover the organizations and practices available to the authenticated
      account.
  - name: Contacts and patients
    description: Find contacts and patients for caller recognition and related workflows.
  - name: Appointments
    description: Retrieve appointment history and upcoming appointments for a patient.
  - name: Messaging
    description: Send practice messages, including missed-call recovery outreach.
  - name: Call recordings
    description: Retrieve recording metadata and secure audio URLs for calls.
paths:
  /api/conversations/{id}/message/:
    parameters:
      - name: id
        in: path
        description: A unique value identifying this conversation.
        required: true
        schema:
          type: string
    post:
      tags:
        - Conversations
      summary: Create message
      description: >-
        Send a message within an existing conversation.


        **Purpose**: Facilitates communication within a conversation by allowing
        authorized users or systems to send messages to the patient, subject to
        various validation checks based on the origin type, direction, and the
        current state of the conversation.


        **Use Case**: This action is critical for maintaining real-time
        engagement with patients, allowing practices to respond dynamically as
        needed.


        **Field Descriptions**:


        - **message**: The content of the message to be sent within the
        conversation. This field is required, cannot be empty, and must be
        between 1 and 1024 characters.


        - **origin_type**: Specifies the origin of the message. Available
        choices are:
          - `SYSTEM_RESPONSIVE`: Message sent by the system in response mode.
          - `AGENT`: Message sent manually by an agent.
        - **direction**: Defines the direction of the message, indicating if it
        is inbound or outbound. Available choices are:
          - `INBOUND`: Incoming message to the system.
          - `OUTBOUND`: Outgoing message from the system.
      operationId: conversations_send_message
      requestBody:
        content:
          application/json:
            schema:
              required:
                - message
              type: object
              properties:
                message:
                  title: Message
                  type: string
                  maxLength: 1024
                  minLength: 1
                origin_type:
                  title: Origin type
                  type: string
                  enum:
                    - system_responsive
                    - agent
                  default: system_responsive
                direction:
                  title: Direction
                  type: string
                  enum:
                    - inbound
                    - outbound
                  default: outbound
        required: true
      responses:
        '200':
          description: Message sent successfully.
        '400':
          description: >-
            Bad Request - Invalid input data or the conversation does not accept
            new messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Aimee is not enabled for this Conversation's practice
        '401':
          description: Authentication is required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationError'
              example:
                detail: '''Authorization'' header is required'
        '403':
          description: The authenticated account does not have permission to send messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PermissionError'
              example:
                message: No permissions assigned to permit access to this endpoint.
        '404':
          description: >-
            The conversation was not found or is not accessible to the
            authenticated account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
              example:
                detail: No Conversation matches the given query.
        '409':
          description: Conflict - This conversation is not accepting new messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: This conversation is not accepting new messages.
      security:
        - bearerAuth: []
components:
  schemas:
    ErrorResponse:
      title: Error response
      type: object
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: string
          description: Why the request could not be completed.
    AuthenticationError:
      title: Authentication error
      type: object
      additionalProperties: true
      required:
        - detail
      properties:
        detail:
          type: string
          description: Why authentication failed.
    PermissionError:
      title: Permission error
      type: object
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
          description: Why access was denied.
    NotFoundError:
      title: Not found error
      type: object
      additionalProperties: false
      required:
        - detail
      properties:
        detail:
          type: string
          description: Why the requested resource could not be returned.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer access token issued by Peerlogic.

````

## Related topics

- [Create resolve](/peerlogic-api-reference/conversations/create-resolve.md)
- [Create escalate](/peerlogic-api-reference/conversations/create-escalate.md)
- [Create subscriptions](/peerlogic-api-reference/subscriptions-and-events/create-subscriptions.md)
- [Create practice FAQ](/peerlogic-api-reference/aimee/create-practice-faq.md)
- [Create a time frame](/peerlogic-voice/calling/create-a-time-frame.md)


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