Désolé, mais cet article d’aide n’est actuellement pas disponible en français. Si vous le souhaitez, vous pouvez consulter une traduction automatique effectuée par Google.
This resource supports the GET and POST methods.
URL Parameters
Label | Description |
---|---|
:document_identifier | The project's document identifier |
GET
Returns an array of all the messages in the project.
GET Request Query String Parameters
Name | Required | Description |
---|---|---|
fields | No | A comma-separated list of the keys you want returned for each message. Default is to return all keys. |
GET Response Status Codes
Code | Description |
---|---|
503 Service Unavailable | Server is undergoing maintenance and is unavailable |
429 Rate Limited | Rate limiting in effect, try again later |
404 Not Found | The resource could not be found or your API key has not been granted access to it |
403 Forbidden | Direct Mail account is disabled |
401 Unauthorized | API key, secret, or authentication method is incorrect |
200 OK | Success |
GET Response Headers
Name | Description |
---|---|
X-Total-Count | The total number of messages in the project |
GET Response Body
JSON representation of an array of objects. Each object in the array represents a message from the project. Please consult the /projects/:document_identifier/messages/:message_uuid
resource for a description of the object keys for each message.
GET Example
GET /api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages HTTP/1.1
Authorization: Basic QzFENDREMjEtNTA4MC00NTM3LUFFOD
Accept: application/json; charset=utf-8
Host: secure.directmailmac.com
HTTP/1.1 200 OK
Date: Wed, 22 Apr 2015 17:14:21 GMT
Content-Type: application/json; charset=utf-8
X-Total-Count: 2
[
{
"automatic_text_content": true,
"content_type": "text/html",
"date_created": "2015-04-22T16:35:27+0000",
"from_email": "jdoe@example.com",
"from_name": "John Doe",
"html_content": "<html>...truncated...</html>",
"links": [
{
"href": "https://secure.directmailmac.com/api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages/BE931519-6612-4DA2-9533-4AD5850E5D37",
"rel": "self"
},
{
"href": "https://secure.directmailmac.com/api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages/BE931519-6612-4DA2-9533-4AD5850E5D37/attachments",
"rel": "attachments"
},
{
"href": "https://secure.directmailmac.com/api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages/BE931519-6612-4DA2-9533-4AD5850E5D37/headers",
"rel": "headers"
}
],
"number_of_attachments": 0,
"number_of_headers": 0,
"subject": "This is a test email",
"text_content": "This is the text that will appear if the recipient cannot view HTML messages. Replace th...truncated",
"text_encoding": "auto",
"title": "untitled message",
"uuid": "BE931519-6612-4DA2-9533-4AD5850E5D37"
},
{
"automatic_text_content": true,
"content_type": "text/html",
"date_created": "2015-04-22T16:35:41+0000",
"from_email": "",
"from_name": "",
"html_content": "<html xmlns="http://www.w3.org/1999/xhtml">...truncated...</html>",
"links": [
{
"href": "https://secure.directmailmac.com/api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages/868110D2-0AA0-414F-BA86-2F860F19A8BE",
"rel": "self"
},
{
"href": "https://secure.directmailmac.com/api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages/868110D2-0AA0-414F-BA86-2F860F19A8BE/attachments",
"rel": "attachments"
},
{
"href": "https://secure.directmailmac.com/api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages/868110D2-0AA0-414F-BA86-2F860F19A8BE/headers",
"rel": "headers"
}
],
"number_of_attachments": 0,
"number_of_headers": 0,
"subject": "",
"text_content": "This is the text that will appear if the recipient cannot view HTML messages. Replace th...truncated",
"text_encoding": "auto",
"title": "untitled message 2",
"uuid": "868110D2-0AA0-414F-BA86-2F860F19A8BE"
}
]
POST
Adds a new message to the project.
POST Request Body
A JSON object representing the message.
Key | Required | Value | Description |
---|---|---|---|
title | No | String | Title of the message (different than the subject, only appears in Direct Mail user interface). Defaults to "untitled message". |
from_email | No | String | The "From" email address |
from_name | No | String | The "From" name |
subject | No | String | The subject of the message |
text_content | No | String | The plain-text content of the message |
html_content | No | String | The HTML content of the message |
automatic_text_content | No | Boolean | True if Direct Mail should automatically create the plain-text content from the HTML content when the message is sent. False is the message should use the string in text_content instead. Defaults to true. |
content_type | Yes | String | Either text/plain or text/html |
text_encoding | No | String | Either auto for automatic text encoding detection or an IANA text encoding name. Defaults to auto . |
POST Response Status Codes
Code | Description |
---|---|
503 Service Unavailable | Server is undergoing maintenance and is unavailable |
429 Rate Limited | Rate limiting in effect, try again later |
404 Not Found | The project could not be found |
403 Forbidden | Direct Mail account is disabled |
401 Unauthorized | API key, secret, or authentication method is incorrect |
400 Bad Request | One or more of the values in the request body is invalid |
202 Accepted | The request has been accepted for processing |
POST Response Body
A JSON object representing the merge task.
Key | Value | Description |
---|---|---|
links | Array of Object | URLs for the merge task and the inserted resource. |
POST Example
POST /api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages HTTP/1.1
Authorization: Basic QzFENDREMjEtNTA4MC00NTM3LUFFOD
Content-Type: application/json; charset=utf-8
Host: secure.directmailmac.com
Content-Length: 194
{
"content_type": "text/html",
"from_email": "api-test@example.com",
"from_name": "Joe User",
"html_content": "<html><body>This is a test</body></html>",
"subject": "Hello World!",
"title": "My Newsletter"
}
HTTP/1.1 202 Accepted
Date: Wed, 22 Apr 2015 18:07:37 GMT
Content-Type: application/json; charset=utf-8
{
"links": [
{
"href": "https://secure.directmailmac.com/api/v2/projects/187812f26ba37d9769d8691d2a83c95c/merge-task?s=18&m=POST&r=https%3A%2F%2Fsecure.directmailmac.com%2Fapi%2Fv2%2Fprojects%2F187812f26ba37d9769d8691d2a83c95c%2Fmessages%2F88EFF66F-5DC0-4290-930A-01365DDE448A",
"rel": "merge-task"
},
{
"href": "https://secure.directmailmac.com/api/v2/projects/187812f26ba37d9769d8691d2a83c95c/messages/88EFF66F-5DC0-4290-930A-01365DDE448A",
"rel": "resource"
}
]
}