# Create a message

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.

Endpoint: POST /messages
Version: 2.7
Security: bearerAuth

## Security:

  - `bearerAuth` (unknown)
    http bearer

## Header parameters:

  - `Intercom-Version` (string)

## Request fields (application/json):

  - `message_type` (string)
    The kind of message being created. Values: `in_app` or `email`.
    Enum: "in_app", "email"

  - `subject` (string)
    The title of the email.
    Example: Thanks for everything

  - `body` (string)
    The content of the message. HTML and plaintext are supported.
    Example: Hello there

  - `template` (string)
    The style of the outgoing message. Possible values `plain` or `personal`.
    Example: plain

  - `from` (object)
    The sender of the message. If not provided, the default sender will be used.

  - `from.type` (string, required)
    Always `admin`.
    Enum: "admin"

  - `from.id` (integer, required)
    The identifier for the admin which is given by Intercom.
    Example: 394051

  - `to` (object)
    The sender of the message. If not provided, the default sender will be used.

  - `to.type` (string, required)
    The role associated to the contact - `user` or `lead`.
    Enum: "user", "lead"

  - `to.id` (string, required)
    The identifier for the contact which is given by Intercom.
    Example: 536e564f316c83104c000020

  - `create_conversation_without_contact_reply` (boolean)
    Whether a conversation should be opened in the inbox for the message without the contact replying. Defaults to false if not provided.
    Example: true

## Request examples:

  - `user message created` (unknown)

  - `lead message created` (unknown)

  - `admin message created` (unknown)

  - `No body supplied for message` (unknown)

  - `No subject supplied for email message` (unknown)

  - `No body supplied for email message` (unknown)

## Response 200:

  - `200` (unknown)
    admin message created

## Response 200 fields (application/json):

  - `type` (string, required)
    The type of the message
    Example: user_message

  - `id` (string, required)
    The id representing the message.
    Example: 1488971108

  - `created_at` (integer, required)
    The time the conversation was created.
    Example: 1667560812

  - `subject` (string)
    The subject of the message. Only present if message_type: email.
    Example: Greetings

  - `body` (string, required)
    The message body, which may contain HTML.
    Example: Hello

  - `message_type` (string, required)
    The type of message that was sent. Can be email, inapp, facebook or twitter.
    Enum: "email", "inapp", "facebook", "twitter"

  - `conversation_id` (string)
    The associated conversation_id
    Example: 64619700005570

## Response 400:

  - `400` (unknown)
    No body supplied for email message

## Response 400 fields (application/json):

  - `type` (string, required)
    The type is error.list
    Example: error.list

  - `request_id` (string)
    Example: f93ecfa8-d08a-4325-8694-89aeb89c8f85

  - `errors` (array, required)
    An array of one or more error objects

  - `errors.code` (string, required)
    A string indicating the kind of error, used to further qualify the HTTP response code
    Example: unauthorized

  - `errors.message` (string)
    Optional. Human readable description of the error.
    Example: Access Token Invalid

  - `errors.field` (string)
    Optional. Used to identify a particular field or query parameter that was in error.
    Example: email

## Response 401:

  - `401` (unknown)
    Unauthorized

## Response 401 fields (application/json):

  - `type` (string, required)
    The type is error.list
    Example: error.list

  - `request_id` (string)
    Example: f93ecfa8-d08a-4325-8694-89aeb89c8f85

  - `errors` (array, required)
    An array of one or more error objects

  - `errors.code` (string, required)
    A string indicating the kind of error, used to further qualify the HTTP response code
    Example: unauthorized

  - `errors.message` (string)
    Optional. Human readable description of the error.
    Example: Access Token Invalid

  - `errors.field` (string)
    Optional. Used to identify a particular field or query parameter that was in error.
    Example: email

## Response 403:

  - `403` (unknown)
    API plan restricted

## Response 403 fields (application/json):

  - `type` (string, required)
    The type is error.list
    Example: error.list

  - `request_id` (string)
    Example: f93ecfa8-d08a-4325-8694-89aeb89c8f85

  - `errors` (array, required)
    An array of one or more error objects

  - `errors.code` (string, required)
    A string indicating the kind of error, used to further qualify the HTTP response code
    Example: unauthorized

  - `errors.message` (string)
    Optional. Human readable description of the error.
    Example: Access Token Invalid

  - `errors.field` (string)
    Optional. Used to identify a particular field or query parameter that was in error.
    Example: email

## Response 422:

  - `422` (unknown)
    No subject supplied for email message

## Response 422 fields (application/json):

  - `type` (string, required)
    The type is error.list
    Example: error.list

  - `request_id` (string)
    Example: f93ecfa8-d08a-4325-8694-89aeb89c8f85

  - `errors` (array, required)
    An array of one or more error objects

  - `errors.code` (string, required)
    A string indicating the kind of error, used to further qualify the HTTP response code
    Example: unauthorized

  - `errors.message` (string)
    Optional. Human readable description of the error.
    Example: Access Token Invalid

  - `errors.field` (string)
    Optional. Used to identify a particular field or query parameter that was in error.
    Example: email

## Response 200 examples:

  - `user message created` (unknown)

  - `lead message created` (unknown)

  - `admin message created` (unknown)

## Response 400 examples:

  - `No body supplied for message` (unknown)

  - `No body supplied for email message` (unknown)

## Response 401 examples:

  - `Unauthorized` (unknown)

## Response 403 examples:

  - `API plan restricted` (unknown)

## Response 422 examples:

  - `No subject supplied for email message` (unknown)

