Vision 6

getMessageById

Returns details for a specific Message.

getMessageById

Returns details for a specific Message.

Top ↑

Syntax

array getMessageById(
    string api_key,
    int message_id,
  [ bool retrieve_content ] 
);

Parameters

api_key (string)

The key required to access the API. See Getting Started for more information.

message_id (int)

The ID of the message to retrieve.

retrieve_content (bool - optional)

Whether or not to include the HTML and/or plain text content of the message in the return value.

Return Value

Returns an array containing a single associative array of Message details. See the remarks section below for a description of the values returned.

Examples

The following code gets Message ID 1111222 and returns its details, including the Message text.

PHP

$message_id = 1111222;     // See searchMessages()
$retrieve_content = true;

$api = new Api($url, 'YOURAPIKEY');
$messages = $api->invokeMethod('getMessageById', $message_id, $retrieve_content);

JSON Request

{
    "id": 5,
    "method": "getMessageById",
    "params": [
        "YOURAPIKEY",
        1111222,
        true
    ]
}

JSON Response

{
    "id": 5,
    "result": [
        {
            "id": "1111222",
            "name": "Newsletter 1234: January 2013",
            "from_name": "Example Co.",
            "from_address": "contact_us@example.com",
            "folder_id": "20214",
            "subject": "An Important Message from your Bank",
            "reply_to": "reply@example.com",
            "type": "email",
            "email_type": "html",
            "size": "64",
            "creator_user_id": "30559",
            "creation_time": "1359698853",
            "last_modified_time": "1359698854",
            "show_unsubscribe_link": true,
            "show_update_profile_link": false,
            "update_profile_list_id": "0",
            "update_profile_webform_id": "0",
            "unsubscribe_list_id": "0",
            "unsubscribe_webform_id": "0",
            "creator_name": "John Smith",
            "authorised_sender": "Example Co.",
            "postal_address": "66 North Street\r\nSouth Side\r\nMiddleton\r\nQLD 4001\r\nAustralia",
            "html_content": "<html><body><p>Welcome to newsletter 1234 ....<\/p><\/body><\/html>",
            "text_content": "<html><body><p>Welcome to newsletter 1234 ....<\/p><\/body><\/html>"
        }
    ],
    "error": null
}

Remarks

The following table shows the values that are returned.

Key Type Description
id int ID of the Message.
name string The name of the Message.
type string The type of Message to be added. Can be either sms or email.
email_type string The Email type for email Messages. Valid values are html, plain-html, plain or raw_html.
subject string The Email subject for email Messages.
reply_to string An Email address or Email wildcard (variable.) Only used for email Messages.
size int The size of the Message in bytes.
creator_user_id int The ID of the User who created the Message.
creator_name string The name of the User who created the Message.
creation_time int Timestamp indicating when the Message was created.
last_modified_time int Timestamp indicating when the Message was last modified.
from_address string For email Messages, an Email address or Email wildcard (variable). For sms Messages, a mobile phone number or a phone number wildcard.
from_name string The name of the sender for email Messages.
postal_address string The postal address of the sender for email Messages.
authorised_sender string The authorised sender of the Email for email Messages.
show_update_profile_link bool Whether or not to show an update profile link for email Messages.
show_unsubscribe_link bool Whether or not to show an unsubscribe link for email Messages.
unsubscribe_list_id int The ID of the List accessed by unsubscribe links for email Messages.
unsubscribe_webform_id int The ID of the web form accessed by unsubscribe links for email Messages.
update_profile_list_id int The ID of the List accessed by update profile links for email Messages.
update_profile_webform_id int The ID of the web form accessed by update profile links for email Messages.
folder_id int The ID of the Folder that contains the Message.
html_content string If retrieve_content is set to true, the HTML content for email Messages.
text_content string If retrieve_content is set to true, the text content for email or sms Messages.

Error Codes

This method may return the following error code in addition to the standard error codes:

Code Error Description
307 Unable to Load Message message_id is not a valid Message.

See Also