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

# Create a message

> Sends a message to a contact. Set `class` to `"sms"` or `"email"` to control the delivery channel, and identify the recipient with `type: "contact"` + `type_id` (the contact's ID). There is **no `contact_id` field** on this endpoint — a posted `contact_id` is silently dropped and the message will fail to resolve a recipient. Address the message with `type: "contact"` and `type_id: "<contact id>"` instead.

Send an SMS or email to a contact



## OpenAPI

````yaml /api-reference/specs/messages.json post /api/messages
openapi: 3.1.0
info:
  title: ConveYour API — Messages
  description: >-
    Send SMS and email messages to contacts, and manage conversation thread
    assignments.
  version: 1.0.0
servers:
  - url: https://{subdomain}.conveyour.com
    description: Your organization's ConveYour instance
    variables:
      subdomain:
        default: acme
        description: >-
          Your organization's slug — the subdomain you sign in on. Replace
          `acme` with yours: if you sign in at `bigco.conveyour.com`, enter
          `bigco`.
security:
  - conveyourToken: []
tags:
  - name: Messages
    description: >-
      Send SMS and email messages to contacts, and manage conversation thread
      assignments.
paths:
  /api/messages:
    post:
      tags:
        - Messages
      summary: Create a message
      description: >-
        Sends a message to a contact. Set `class` to `"sms"` or `"email"` to
        control the delivery channel, and identify the recipient with `type:
        "contact"` + `type_id` (the contact's ID). There is **no `contact_id`
        field** on this endpoint — a posted `contact_id` is silently dropped and
        the message will fail to resolve a recipient. Address the message with
        `type: "contact"` and `type_id: "<contact id>"` instead.


        Send an SMS or email to a contact
      operationId: sendAnSmsOrEmailToAContact
      parameters:
        - $ref: '#/components/parameters/teams'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - class
                - type
                - type_id
                - body
              properties:
                class:
                  description: The delivery channel. Either `"sms"` or `"email"`.
                  type: string
                type:
                  description: >-
                    The recipient type. Use `"contact"` to send to a single
                    contact. (Other values: `bookmark`, `trigger`, `campaign`,
                    `trigger_lesson`, `trigger_wait`.)
                  type: string
                type_id:
                  description: >-
                    The ID of the recipient. When `type` is `"contact"`, this is
                    the contact's ID.
                  type: string
                body:
                  description: >-
                    The message body. Supports [Liquid
                    syntax](/guides/liquid-syntax) for personalization.
                  type: string
                subject:
                  description: >-
                    Email subject line. Required when `class` is `"email"`.
                    Supports Liquid syntax.
                  type: string
                close:
                  type: boolean
                  default: false
                  description: Close the conversation thread after sending.
                inherit_thread_close_state:
                  type: boolean
                  default: false
                  description: >-
                    Adopt the thread's existing closed state instead of setting
                    it explicitly.
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Envelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/CreatedMessageRef'
              example:
                status: ok
                message: Message created
                data:
                  id: 64a1b2c3d4e5f6a7b8c9d0e1
                  time: just now
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          description: >-
            Send limit reached. Errors filtered by code 429 from the message
            class — the SMS or email quota for the org. This cannot be caught by
            the pre-flight `limitCheck()`, because that check cannot know how
            many contacts the new message targets. `data` carries the usage
            overview for the `sms` or `emails` limit.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - failed
                    description: Always `failed`.
                  message:
                    type: string
                    description: Human-readable explanation.
                  data:
                    type: object
                    description: >-
                      Usage overview for the limit that was hit — used, unused
                      and overage counts.
components:
  parameters:
    teams:
      name: teams[]
      in: query
      description: >-
        Team scope for the request, as one or more team ObjectIds. The brackets
        are required: PHP keeps only the last value for a repeated plain key, so
        `teams=A&teams=B` silently resolves to B alone. On requests with a JSON
        body you may send `teams` (no brackets) in the body instead.


        **Values that are not valid ObjectIds are silently ignored** — a
        mistyped team ID behaves as if no team was sent. See the [teams section
        of the API conventions guide](/guides/api-conventions#team-scoping).
      style: form
      explode: true
      schema:
        type: array
        items:
          type: string
      example:
        - 64a1b2c3d4e5f6a7b8c9d0ff
  schemas:
    Envelope:
      type: object
      description: The common response envelope shared by all ConveYour endpoints.
      properties:
        status:
          type: string
          enum:
            - ok
            - failed
          description: '`ok` on success, `failed` on error.'
        message:
          type: string
          description: Human-readable description of the result.
        data:
          description: >-
            The response payload — an object or an array depending on the
            endpoint.
    CreatedMessageRef:
      type: object
      description: >-
        Create returns only an id and a fixed placeholder time — not the message
        record.
      properties:
        id:
          type: string
          description: ID of the new message.
        time:
          type: string
          enum:
            - just now
          description: >-
            Always the literal string 'just now' — it is hardcoded, not a
            timestamp.
      required:
        - id
        - time
  responses:
    Forbidden:
      description: >-
        The token is missing or invalid, or the service account behind it lacks
        the permission this endpoint requires.
      content:
        application/json:
          example:
            status: failed
            message: Lacking necessary permission add_contacts
            data:
              permission: add_contacts
  securitySchemes:
    conveyourToken:
      type: apiKey
      in: header
      name: x-conveyour-token
      description: >-
        Your API key token. Contacts endpoints require a **Server-only — Full
        API** key — see [Authentication](/quickstart).

````

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