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

# Send message by ID

> Sends an outbound message in the given conversation for the specified company.
`company_id` and `conversation_id` are taken from the URL path. `message_body` is required in the JSON body.
`account_id` is resolved from the authenticated user's account that matches `company_id` (same as other company-scoped routes).
The request is forwarded to the chat service as a POST with `company_id` and `conversation_id` in the path.




## OpenAPI

````yaml POST /v1/send-message/{company_id}/{conversation_id}
openapi: 3.0.3
info:
  title: SalesCaptain API Documentation Service
  description: >
    API Documentation Service for SalesCaptain platform.

    This service provides endpoints for managing and retrieving company
    information for API documentation purposes.
  version: 0.1.0
  contact:
    name: SalesCaptain API Team
    email: support@salescaptain.com
  license:
    name: Proprietary
    url: https://salescaptain.com/license
servers:
  - url: https://api.salescaptain.com
    description: Production server
security:
  - BearerAuth: []
tags:
  - name: Health
    description: Service health and status endpoints
  - name: Companies
    description: Company management and retrieval operations
  - name: Accounts
    description: Account management and retrieval operations
  - name: Conversation Profiles
    description: Conversation profile management for communication channels
  - name: Conversations
    description: Conversation management and retrieval operations
  - name: Contacts
    description: Contact management and retrieval operations
  - name: Custom Fields
    description: Custom field definition management
externalDocs:
  description: SalesCaptain API Documentation
  url: https://docs.salescaptain.com
paths:
  /v1/send-message/{company_id}/{conversation_id}:
    post:
      tags:
        - Conversations
      summary: Send a message in a conversation
      description: >
        Sends an outbound message in the given conversation for the specified
        company.

        `company_id` and `conversation_id` are taken from the URL path.
        `message_body` is required in the JSON body.

        `account_id` is resolved from the authenticated user's account that
        matches `company_id` (same as other company-scoped routes).

        The request is forwarded to the chat service as a POST with `company_id`
        and `conversation_id` in the path.
      operationId: sendMessage
      parameters:
        - name: company_id
          in: path
          required: true
          description: Unique identifier for the company
          schema:
            type: string
            format: uuid
            example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        - name: conversation_id
          in: path
          required: true
          description: Unique identifier for the conversation
          schema:
            type: string
            format: uuid
            example: b2c3d4e5-f6a7-8901-bcde-f12345678901
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - message_body
              properties:
                message_body:
                  type: string
                  description: Plain text body of the message to send
                  example: Hi — this is a test message from the api-doc send endpoint.
            example:
              message_body: Hi — this is a test message from the api-doc send endpoint.
      responses:
        '200':
          description: Message sent successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Message sent successfully!
                  data:
                    $ref: '#/components/schemas/SentMessage'
              example:
                message: Message sent successfully!
                data:
                  conversation_id: b2c3d4e5-f6a7-8901-bcde-f12345678901
                  author: Jane Doe
                  body: Hi — this is a test message from the api-doc send endpoint.
                  date_created: '2025-03-23T18:30:00.000Z'
                  is_me: true
                  message_type: sms_message
                  sent_by_id: d4e5f6a7-b8c9-0123-def1-234567890123
                  sent_by_username: Jane Doe
                  message_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        '400':
          description: >-
            Invalid request (missing fields, invalid IDs, or no account for
            company)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_required:
                  summary: Missing conversation_id, account_id context, or message_body
                  value:
                    status: failure
                    error: >-
                      conversation_id, account_id, and message_body must be
                      provided!
                invalid_company_id:
                  summary: Invalid company UUID
                  value:
                    status: failure
                    error: Invalid company ID
                invalid_conversation_id:
                  summary: Invalid conversation UUID
                  value:
                    status: failure
                    error: Invalid conversation ID
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - BearerAuth: []
components:
  schemas:
    SentMessage:
      type: object
      description: Message as returned after a successful send (chat service response)
      properties:
        conversation_id:
          type: string
          format: uuid
          example: b2c3d4e5-f6a7-8901-bcde-f12345678901
        author:
          type: string
          description: Display name of the message author
          example: Jane Doe
        body:
          type: string
          description: Message text
          example: Hi — this is a test message from the api-doc send endpoint.
        date_created:
          type: string
          format: date-time
          example: '2025-03-23T18:30:00.000Z'
        is_me:
          type: boolean
          description: Whether the message was sent by the authenticated account
          example: true
        message_type:
          type: string
          description: Channel/type of the message
          example: sms_message
        sent_by_id:
          type: string
          description: Account ID of the sender
          example: d4e5f6a7-b8c9-0123-def1-234567890123
        sent_by_username:
          type: string
          example: Jane Doe
        message_id:
          type: string
          description: Unique message identifier from the chat service
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
      required:
        - conversation_id
        - author
        - body
        - date_created
        - is_me
        - message_type
        - sent_by_id
        - sent_by_username
        - message_id
    Error:
      type: object
      description: Error response object
      properties:
        error:
          type: string
          description: Error message
          example: Invalid request parameters
        code:
          type: string
          description: Error code for programmatic handling
          example: INVALID_PARAMS
        timestamp:
          type: string
          format: date-time
          description: Timestamp when the error occurred
          example: '2023-12-01T10:30:00Z'
        path:
          type: string
          description: API endpoint path where the error occurred
          example: /v1/fetch-companies
      required:
        - error
  responses:
    UnauthorizedError:
      description: Authentication token is missing or invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Unauthorized access
            code: UNAUTHORIZED
            timestamp: '2023-12-01T10:30:00Z'
            path: /v1/fetch-companies
    ForbiddenError:
      description: Access forbidden - valid token but insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Forbidden access
            code: FORBIDDEN
            timestamp: '2023-12-01T10:30:00Z'
            path: /v1/fetch-companies
    RateLimitError:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Too many requests, please try again later
            code: RATE_LIMIT_EXCEEDED
            timestamp: '2023-12-01T10:30:00Z'
            path: /v1/fetch-companies
      headers:
        X-RateLimit-Limit:
          description: Request limit per time window
          schema:
            type: integer
            example: 30
        X-RateLimit-Remaining:
          description: Remaining requests in current window
          schema:
            type: integer
            example: 0
        X-RateLimit-Reset:
          description: Time when the rate limit resets
          schema:
            type: integer
            example: 1701425400
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Problem encountered while fetching companies!
            code: INTERNAL_ERROR
            timestamp: '2023-12-01T10:30:00Z'
            path: /v1/fetch-companies
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Authentication token required for accessing protected endpoints.

        The token should be obtained from the main SalesCaptain authentication
        service.

````