Messages
Message Types
Section titled “Message Types”| Type | Description |
|---|---|
email | A “normal” email BCC’d into Sheep. |
templated | A templated message generated in Sheep, delivered by email. |
templated-in-app | A templated message generated in Sheep, delivered through the app. |
templated-sms | A templated message generated in Sheep, delivered through SMS. Additional costs apply. |
templated-post | (Future) A templated message generated in Sheep, printed on demand and posted. Additional costs apply. |
Message Status
Section titled “Message Status”| Status | Description |
|---|---|
draft | Initial / draft state. |
sent | Successfully handed off to the delivery system. |
received | Used for external emails. |
queued | Waiting to be handed to the delivery system. |
failed | The generation or delivery system reported a failure. |
failed_multi | The generation or delivery system reported a 2nd failure. |
fatal | A serious issue with message generation or delivery. |
Template Fields
Section titled “Template Fields”| Field | Description |
|---|---|
process_date | Rendering date/time. |
regarding | Additional data to use in the template rendering. |
acknowledgement_date | Date email acknowledged by user. |
date | Date on email. |
from | Email of user sending / system account. |
from_reference | sheepCRM contact reference of sender. |
html_message | The rendered template (HTML). |
text_message | The rendered template (plain text). |
raw | The raw template. |
status | See message status list above. |
subject | Email subject from template. |
to_reference | sheepCRM contact reference of recipient. |
type | Message delivery type. |
uid | System unique ID. |
requires_acknowledgement | For use with in-app messages to collect acknowledgement. |
External Email Fields
Section titled “External Email Fields”| Field | Description |
|---|---|
acknowledgement_date | Date email processed by sheepCRM. |
cc_reference | sheepCRM contact reference list. |
date | Date on email. |
files | List of file attachments (posted to S3). |
from | Email of sender (text). |
from_reference | sheepCRM contact reference of sender. |
html_message | Message body as HTML. |
text_message | Message body as text (HTML may be converted to text). |
raw | Raw message body. |
status | Will always be “received”. |
subject | Email subject. |
to | Message recipient (text). |
to_reference | sheepCRM contact reference of recipient. |
uid | IMAP message UID. |
Creating a Message
Section titled “Creating a Message”POST https://api.sheepcrm.com/api/v1/example/message/Authorization: Bearer $API_KEYContent-Type: application/json
{ "to_reference": "/example/person/5e7cf08e80859e2e284749a8/", "subject": "hello", "raw": "hi {{first_name}}", "type": "templated"}
HTTP/1.0 200 OK{ "bucket": "example", "data": { "date": "2021-06-29T10:03:10.311000", "delivery_status": null, "raw": "hi {{first_name}}", "status": "draft", "subject": "hello", "to_reference": [ { "display_value": "James Webster", "ref": "/example/person/5e7cf08e80859e2e284749a8/" } ], "type": "templated", "uid": null }, "uri": "/example/message/60daefde0a7750b55c83a257/"}The message record has been created as a draft. This can be previewed to check the body rendering:
GET https://api.sheepcrm.com/api/v1/example/message/60daefde0a7750b55c83a257/preview/Authorization: Bearer $API_KEY
HTTP/1.1 200 OK{ "bucket": "example", "data": { "content": { "/example/person/5e7cf08e80859e2e284749a8/": { "html": "<p>hi James</p>\n", "text": "hi James" } }, "emails": { "/example/person/5e7cf08e80859e2e284749a8/": "james@sheepcrm.com" }, "errors": { "/example/person/5e7cf08e80859e2e284749a8/": null }, "raw": "hi {{first_name}}", "status": "draft", "subject": "hello", "subjects": { "/example/person/5e7cf08e80859e2e284749a8/": "hello" }, "to_reference": [ { "display_value": "James Webster", "ref": "/example/person/5e7cf08e80859e2e284749a8/" } ], "type": "templated" }, "uri": "/example/message/60daefde0a7750b55c83a257/"}Sending a Message
Section titled “Sending a Message”Test send the message
Section titled “Test send the message”Test the message by sending to yourself (the email associated with the API key). The preview shows the rendering but to see the full email within the wider HTML template, send an actual test message and check it in your email client.
POST https://api.sheepcrm.com/api/v1/example/message/60daefde0a7750b55c83a257/testsend/Authorization: Bearer $API_KEYSend the message
Section titled “Send the message”POST https://api.sheepcrm.com/api/v1/example/message/60daefde0a7750b55c83a257/send/Authorization: Bearer $API_KEYQueue and send
Section titled “Queue and send”For large numbers of recipients, send asynchronously (each email is rendered and sent individually so sending is slow):
POST https://api.sheepcrm.com/api/v1/example/message/60daefde0a7750b55c83a257/queue_and_send/Authorization: Bearer $API_KEY