# Create a message

`POST /messages`

> This is a subset of the full specification, limited to the `POST /messages` operation.
>
> You can find the full specification here: /_bundle/docs/references/@2.12/rest-api/api.intercom.io.yaml

```yaml
openapi: 3.0.1
info:
  title: Intercom API
  version: '2.12'
  description: This is a subset of the full specification, limited to the `POST /messages` operation.
  contact:
    name: Intercom Developer Hub
    url: https://developers.intercom.com
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
servers:
  - url: https://api.intercom.io
    description: The production API server
  - url: https://api.eu.intercom.io
    description: The european API server
  - url: https://api.au.intercom.io
    description: The australian API server
security:
  - bearerAuth: []
tags:
  - name: Messages
    description: Everything about your messages
paths:
  /messages:
    post:
      summary: Create a message
      parameters:
        - name: Intercom-Version
          in: header
          schema:
            $ref: '#/components/schemas/intercom_version'
      tags:
        - Messages
      operationId: createMessage
      description: |-
        You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email.

        > 🚧 Sending for visitors
        >
        > There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

        This will return the Message model that has been created.

        > 🚧 Retrieving Associated Conversations
        >
        > As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

        **Messages from contacts**

        `from` should be an admin. A request with a user or lead as `from` is not rejected: it creates a conversation initiated by that contact, as the Create a conversation endpoint (`POST /conversations`) does, and the `to`, `cc` and `bcc` fields are ignored. To create a conversation initiated by a contact, use `POST /conversations`.
      responses:
        '200':
          description: admin message created
          content:
            application/json:
              examples:
                user message created:
                  value:
                    type: user_message
                    id: '403918141'
                    created_at: 1736201828
                    body: heyy
                    message_type: inapp
                    conversation_id: '147'
                lead message created:
                  value:
                    type: user_message
                    id: '403918142'
                    created_at: 1736201830
                    body: heyy
                    message_type: inapp
                    conversation_id: '148'
                admin message created:
                  value:
                    type: admin_message
                    id: '5'
                    created_at: 1736201832
                    subject: heyy
                    body: heyy
                    message_type: inapp
                    owner:
                      type: admin
                      id: '991266569'
                      name: Ciaran297 Lee
                      email: admin297@email.com
                      away_mode_enabled: false
                      away_mode_reassign: false
              schema:
                $ref: '#/components/schemas/message'
        '400':
          description: No body supplied for email message
          content:
            application/json:
              examples:
                No body supplied for message:
                  value:
                    type: error.list
                    request_id: 8ec40e30-ca6d-4047-ae2b-6f6ee8f639af
                    errors:
                      - code: parameter_invalid
                        message: Body is required
                No body supplied for email message:
                  value:
                    type: error.list
                    request_id: ac0ee304-4f40-4618-8d02-ecd3d0739d5d
                    errors:
                      - code: parameter_invalid
                        message: Body is required
              schema:
                $ref: '#/components/schemas/error'
        '401':
          description: Unauthorized
          content:
            application/json:
              examples:
                Unauthorized:
                  value:
                    type: error.list
                    request_id: 3dd7e761-88b8-4826-9a75-f88fcde370dc
                    errors:
                      - code: unauthorized
                        message: Access Token Invalid
              schema:
                $ref: '#/components/schemas/error'
        '403':
          description: API plan restricted
          content:
            application/json:
              examples:
                API plan restricted:
                  value:
                    type: error.list
                    request_id: a7caf632-2f93-4142-9a89-3fb740b23ca3
                    errors:
                      - code: api_plan_restricted
                        message: Active subscription needed.
              schema:
                $ref: '#/components/schemas/error'
        '422':
          description: No subject supplied for email message
          content:
            application/json:
              examples:
                No subject supplied for email message:
                  value:
                    type: error.list
                    request_id: 69655c1d-40e2-4483-ae98-98a587e7c1ed
                    errors:
                      - code: parameter_not_found
                        message: No subject supplied for email message
              schema:
                $ref: '#/components/schemas/error'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_message_request'
            examples:
              user_message_created:
                summary: user message created
                value:
                  from:
                    type: user
                    id: 677c56646abd011ad17ff584
                  body: heyy
                  referer: https://example.com/bob
              lead_message_created:
                summary: lead message created
                value:
                  from:
                    type: lead
                    id: 677c56666abd011ad17ff585
                  body: heyy
                  referer: https://example.com/bob
              admin_message_created:
                summary: admin message created
                value:
                  from:
                    type: admin
                    id: '991266569'
                  to:
                    type: user
                    id: 677c56686abd011ad17ff586
                  message_type: conversation
                  body: heyy
              no_body_supplied_for_message:
                summary: No body supplied for message
                value:
                  from:
                    type: admin
                    id: '991266571'
                  to:
                    type: user
                    id: 677c56696abd011ad17ff587
                  message_type: inapp
                  body: null
                  subject: heyy
              no_subject_supplied_for_email_message:
                summary: No subject supplied for email message
                value:
                  from:
                    type: admin
                    id: '991266572'
                  to:
                    type: user
                    user_id: '70'
                  message_type: email
                  body: hey there
              no_body_supplied_for_email_message:
                summary: No body supplied for email message
                value:
                  from:
                    type: admin
                    id: '991266573'
                  to:
                    type: user
                    id: 677c566b6abd011ad17ff589
                  message_type: email
                  body: null
                  subject: heyy
components:
  schemas:
    create_message_request:
      description: You can create a message
      type: object
      title: Create Message Request Payload
      nullable: true
      properties:
        message_type:
          type: string
          description: 'The kind of message being created. Values: `in_app` or `email`.'
          enum:
            - in_app
            - email
          example: in_app
        subject:
          type: string
          description: The title of the email.
          example: Thanks for everything
        body:
          type: string
          description: The content of the message. HTML and plaintext are supported.
          example: Hello there
        template:
          type: string
          description: The style of the outgoing message. Possible values `plain` or `personal`.
          example: plain
        from:
          type: object
          description: The sender of the message. If not provided, the default sender will be used.
          properties:
            type:
              type: string
              description: Always `admin`.
              enum:
                - admin
              example: admin
            id:
              type: integer
              description: The identifier for the admin which is given by Intercom.
              example: 394051
          required:
            - type
            - id
        to:
          type: object
          description: The sender of the message. If not provided, the default sender will be used.
          properties:
            type:
              type: string
              description: The role associated to the contact - `user` or `lead`.
              enum:
                - user
                - lead
              example: user
            id:
              type: string
              description: The identifier for the contact which is given by Intercom.
              example: 536e564f316c83104c000020
          required:
            - type
            - id
        created_at:
          type: integer
          description: The time the message was created. If not provided, the current time will be used.
          example: 1590000000
        create_conversation_without_contact_reply:
          type: boolean
          description: Whether a conversation should be opened in the inbox for the message without the contact replying. Defaults to false if not provided.
          default: false
          example: true
      anyOf:
        - title: 'message_type: `email`.'
          required:
            - message_type
            - subject
            - body
            - template
            - from
            - to
        - title: 'message_type: `inapp`.'
          required:
            - message_type
            - body
            - from
            - to
    error:
      type: object
      title: Error
      description: The API will return an Error List for a failed request, which will contain one or more Error objects.
      properties:
        type:
          type: string
          description: The type is error.list
          example: error.list
        request_id:
          type: string
          nullable: true
          format: uuid
          description: ''
          example: f93ecfa8-d08a-4325-8694-89aeb89c8f85
        errors:
          type: array
          description: An array of one or more error objects
          items:
            properties:
              code:
                type: string
                description: A string indicating the kind of error, used to further qualify the HTTP response code
                example: unauthorized
              message:
                type: string
                nullable: true
                description: Optional. Human readable description of the error.
                example: Access Token Invalid
              field:
                type: string
                nullable: true
                description: Optional. Used to identify a particular field or query parameter that was in error.
                example: email
            required:
              - code
      required:
        - type
        - errors
    intercom_version:
      description: Intercom API version.</br>By default, it's equal to the version set in the app package.
      type: string
      example: '2.12'
      default: '2.12'
      enum:
        - '1.0'
        - '1.1'
        - '1.2'
        - '1.3'
        - '1.4'
        - '2.0'
        - '2.1'
        - '2.2'
        - '2.3'
        - '2.4'
        - '2.5'
        - '2.6'
        - '2.7'
        - '2.8'
        - '2.9'
        - '2.10'
        - '2.11'
        - '2.12'
        - Preview
    message:
      type: object
      title: Message
      x-tags:
        - Messages
      description: Message are how you reach out to contacts in Intercom. They are created when an admin sends an outbound message to a contact.
      properties:
        type:
          type: string
          description: The type of the message
          example: user_message
        id:
          type: string
          description: The id representing the message.
          example: '1488971108'
        created_at:
          type: integer
          format: date-time
          description: The time the conversation was created.
          example: 1667560812
        subject:
          type: string
          description: 'The subject of the message. Only present if message_type: email.'
          example: Greetings
        body:
          type: string
          description: The message body, which may contain HTML.
          example: Hello
        message_type:
          type: string
          enum:
            - email
            - inapp
            - facebook
          description: The type of message that was sent. Can be email, inapp or facebook.
          example: inapp
        conversation_id:
          type: string
          description: The associated conversation_id
          example: '64619700005570'
      required:
        - type
        - id
        - created_at
        - body
        - message_type
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
```
