Sending Messages

Send a single message to a specific contact

POST https://a.loopmessage.com/api/v1/message/send/

You can use a contact ID or a phone number/email address (depending on what the user provided you with when subscribing).

Headers

Name
Type
Description

Authorization*

String

API Key. Required*.

Content-Type*

String

application/json

Request Body

Name
Type
Description

contact*

String

Phone number, Email, or Contact ID.

text*

String

Your message text

subject

String

Optional. Your message subject. A recipient will see this subject as a bold title before the text.

sender

String

Optional. ID of your sender name. Send message from a specific sender name.

attachments

Array

Optional. An array of strings. The string must be a full URL of your image. URL should start with

https://. HTTP links (without SSL) are not supported. This must be a publicly accessible file URL: we will not be able to reach any URLs that are hidden or that require authentication. Max length of each URL: 256 characters, max elements in the array: 3.

effect

String

Optional. Add effect to your message. Possible values: slam, loud, gentle, invisibleInk, echo, spotlight, balloons, confetti, love, lasers, fireworks, shootingStar, celebration.

You can check the Apple guide about expressive messages.

reply_to_id

String

Optional. The message_id that you got from the webhook.

You can check the Apple guide about the reply to feature.

passthrough

String

Optional. A string of metadata you wish to store with the checkout. Will be sent alongside all webhooks associated with the outbound message. Max length: 1000 characters.

{
    "message_id": "2BC4FD6A-CE49-439F-81DF-E895C09CA49C",
    "success": true,
    "contact": "+13231112233",
    "text": "text"
}

Phone number will be converted to the next format +13231112233, without spaces and brackets. Email will be converted into a lowercase format.

Supported phone number formats

Recipient phone numbers should be only in international formats with a country code. Otherwise will be impossible to verify a phone number.

Plus prefix + is optional. Spaces, dashes '-', brackets '(123)' - also optional.

Valid phone number format examples:

  • 13231234567

  • +13231111111

  • +1 (323) 1111111

  • +1 323 123 4567

  • 1 (323)-123-4567

Send single message to iMessage group

An example of how group chats look like in iMessage
An example of how group chats look like in iMessage

POST https://a.loopmessage.com/api/v1/message/send/

Headers

Name
Type
Description

Authorization*

String

API Key. Required*

Content-Type*

String

application/json

Request Body

Name
Type
Description

group*

String

iMessage group ID. You can only get this ID from the webhook: message_inbound.

text*

String

Your message text

subject

String

Optional. Your message subject. A recipient will see this subject as a bold title before the text.

sender

String

Optional. ID of your sender name. Send message from a specific sender name.

attachments

Array

Optional. An array of strings. The string must be a full URL of your image. URL should start with

https://..., http links (without SSL) are not supported. This must be a publicly accessible URL: we will not be able to reach any URLs that are hidden or that require authentication. Max length of each URL: 256 characters, max elements in the array: 3.

effect

String

Optional. Add effect to your message. Possible values: slam, loud, gentle, invisibleInk, echo, spotlight, balloons, confetti, love, lasers, fireworks, shootingStar, celebration.

You can check the Apple guide about expressive messages.

reply_to_id

String

Optional. The message_id that you got from the webhook.

You can check the Apple guide about the reply to feature.

passthrough

String

Optional. A string of metadata you wish to store with the checkout. Will be sent alongside all webhooks associated with the outbound message. Max length: 1000 characters.

{
    "message_id": "2BC4FD6A-CE49-439F-81DF-E895C09CA49C",
    "success": true,
    "group": {
        "group_id": "2BC4FD6A-CE49-439F-81DF-E895C09CA49C",
        "name": "String",  # Optinal field
        "participants": ["+13231112233", "+13232223344"]
    },
    "text": "text"
}

You can't create an iMessage Group, change its name, or add/remove participants to it via the API. You can only receive and reply to incoming messages/attachments.

Send a voice message

An example of how voice/audio messages look in iMessage

POST https://a.loopmessage.com/api/v1/message/send/

Headers

Name
Type
Description

Authorization*

String

API Key. Required*.

Content-Type*

String

application/json

Request Body

Name
Type
Description

contact*

String

Phone number or Email.

media_url*

String

The string must be a full URL of your audio file. URL should start with https://..., http links (without SSL) are not supported. This must be a publicly accessible URL: we will not be able to reach any URLs that are hidden or that require authentication. Max length of each URL: 256 characters.

Audio files of the following formats are supported: mp3, wav, m4a, caf, aac.

sender

String

Optional. Your dedicated sender name. This parameter will be ignored if you send a request to a recipient who is added as a sandbox contact. DON'T use a phone number as a value for this parameter.

passthrough

String

A string of metadata you wish to store in the request. Will be sent alongside all webhooks associated with the outbound message. Max length: 1000 characters.

{
    "message_id": "2BC4FD6A-CE49-439F-81DF-E895C09CA49C",
    "success": true,
    "recipient": "+13231112233",
    "text": "text"
}

Phone number will be converted to the next format +13231112233, without spaces and brackets. Email will be converted into a lowercase format.

To send a voice message to an iMessage group, you need to use the group field instead contact.

Send a reaction

An example of how tapback reactions looks like in iMessage

POST https://a.loopmessage.com/api/v1/message/send/

Headers

Name
Type
Description

Authorization*

String

API Key. Required*.

Content-Type*

String

application/json

Request Body

Name
Type
Description

contact*

String

Phone number or Email.

message_id*

String

The message_id that you got from the webhook.

reaction*

String

Possible values:

love, like, dislike, laugh, exclaim, question, -love, -like, -dislike, -laugh, -exclaim, -question. Reactions that started with - mean "remove" it from the message.

You can check the Apple guide about reactions and tapbacks.

Failed responses

If your request has a failed status, you will receive a JSON response with the following content:

{
    "success": false,
    "code": 100,
    "message": "string"
}

The message field is optional and briefly describes the reason for the error. Please do not pass this to the destination users/recipients. Use the "code" field to map errors and show localized error text to them.

Response example

{
    "message_id": "2BC4FD6A-CE49-439F-81DF-E895C09CA49C",
    "success": true,
    "recipient": "+13231112233",
    "text": "text"
}

Phone number will be converted to the next format +13231112233, without spaces and brackets. Email will be converted into a lowercase format.

Limits

Messages

  • Max text length in each message must be less than 10000 characters. Otherwise, all extra characters will be truncated. If you have larger requirements, we recommend breaking the message up into several smaller messages.

    You can use characters from any languages, emojis and \n for new lines. HTML tags aren't supported.

  • If you need to send messages to a few contacts who haven't recently sent you any inbound messages, you must keep a minimal interval of 2 minutes between each such message. Otherwise, your request may be rejected.

Attachments

  • When you send an attachment file for the first time, it takes a while for it to download into the cache before it's sent to the recipient. If your attachments are large (more than a couple of megabytes), it will take a while for them to be delivered to your contact. If you update your file but it still has the same URL, the cached version still be used. To avoid a cached version, you need to change the file URL (for example, by renaming the file name).

Best Practices

Handling failed cases

It's recommended to implement handling of the next failed/error cases:

  • If the response code for sending message is not equal 200. In most cases, it means that something is wrong with your parameters.

  • You receive a webhook with the type message_failed or message status is failed. This means that the message can't be delivered to this recipient. Check the error_code JSON field to better understand your case.

  • You receive a webhook with the type message_sent, but the success JSON field contains the false value. That means a message was successfully sent, but it was unsuccessfully delivered on the recipient side. Examples: your recipient blocked you or uses filters from unknown senders. This case equal to "Not delivered" status in the Messages app.

  • You receive a webhook with the type message_timeout or message status is timeout. This happens if you passed the timeout parameter in the request to send a single message. In this case, this means that we failed to deliver a message within the specified time and it was assigned the timeout status.

Last updated