readyDocs Open the appOpen the app

Templates

A template is a message you save once and send again. These are the same templates you see under Campaigns → Templates in the app. Every list shows only your account’s own templates.

Reading needs only a key. Creating, editing, deleting and counting a use need the send_sms permission. A test key can read templates but not change them: a write answers 403 test_key_not_allowed.

Saving a template doesn’t send anything. Ready checks the text with the same content policy it uses for a send, and a blocked save counts against your account the way a blocked send does.

#The Template object

List templates returns this object. Ignore fields you don’t recognize.

idinteger
The template id.
user_idinteger
The account that owns the template.
namestring
The template name. Names don’t have to be unique.
bodystring
The message text, as saved. Merge fields such as {{contact.first_name}} and spintax stay as written.
categorystring
A label you file the template under. Lower case letters, digits, dashes and underscores, at most 40 characters. general when you don’t set one.
is_sharedinteger
Always 0 for a template you create.
use_countinteger
How many times a use was counted with Count a template use.
last_used_attimestamp
When a use was last counted. null until the first one.
created_attimestamp
When the template was created.

#List templates

Returns your account’s templates, newest first. Not paginated.

Returns
dataobject[]
A list of Template objects. An empty list means you have no templates.
Errors
HTTPCodeWhen
500TEMPLATES_LOAD_FAILEDThe list couldn’t be read. Try again; it doesn’t mean you have no templates.

#Create a template

Saves a new template on your account. Needs send_sms. If you send the same name again within 10 seconds, you get the first template back with deduped: true and no second one is made.

Parameters

namestringRequired
The template name, up to 100 characters. Leading and trailing spaces are trimmed.
bodystringRequired
The message text, up to 1,600 characters. Saved as written, with merge fields and spintax kept.
categorystring
A label to file it under. Ready lowercases it, turns spaces into dashes, drops other characters and keeps the first 40. Empty or missing becomes general.
Returns
dataobject
The new template: id, user_id, name, body, category, is_shared (0) and use_count (0). On a repeat it holds only id, user_id, name and body of the first template.
dedupedboolean
true when this was a repeat within 10 seconds. Left out otherwise.
Errors
HTTPCodeWhen
400invalid_fieldname is missing or isn’t text.
400nonename or body is empty. The answer has an error sentence and no code.
400TEMPLATE_NOT_TEXTbody isn’t text.
400TEMPLATE_NAME_TOO_LONGname is over 100 characters.
400TEMPLATE_BODY_TOO_LONGbody is over 1,600 characters.
400CONTENT_BLOCKEDThe text breaks the content policy. Not saved. reasons and matched say what was flagged. A blocked save can lower your account’s daily sending limit.
500TEMPLATE_SAVE_FAILEDThe template couldn’t be saved. Try again.
503CONTENT_REVIEW_UNAVAILABLEThe content check couldn’t finish. Not saved, and nothing is wrong with the text. Try again shortly.

#Update a template

Changes a template’s name, text or category. Needs send_sms. Send only the fields you want to change; a missing or empty field keeps its saved value.

Parameters

idinteger, pathRequired
The template id.
namestring
The new name, up to 100 characters. Trimmed.
bodystring
The new text, up to 1,600 characters. New text goes through the content check; unchanged text does not.
categorystring
The new category, cleaned the same way as on create. A value with nothing usable left keeps the old category.
Returns
successboolean
true. The template isn’t returned; read it with List templates.
Errors
HTTPCodeWhen
400invalid_fieldid isn’t a whole number, or a body field is a list or an object.
400TEMPLATE_STARTER_READONLYThe id is a Ready starter template, not one of yours.
400TEMPLATE_NOT_TEXTname or body isn’t text.
400TEMPLATE_NAME_TOO_LONGname is over 100 characters.
400TEMPLATE_BODY_TOO_LONGbody is over 1,600 characters.
400CONTENT_BLOCKEDThe new text breaks the content policy. Nothing changed; the old version is still saved.
404TEMPLATE_NOT_FOUNDNo such template on your account, or it was deleted.
500TEMPLATE_LOAD_FAILEDThe template couldn’t be read. Nothing changed. Try again.
500TEMPLATE_SAVE_FAILEDThe change couldn’t be saved. Try again.
503CONTENT_REVIEW_UNAVAILABLEThe content check couldn’t finish. Nothing changed. Try again shortly.

#Delete a template

Deletes one of your templates. Needs send_sms. No body. Deleting it again answers 404 TEMPLATE_NOT_FOUND.

Parameters

idinteger, pathRequired
The template id.
Errors
HTTPCodeWhen
400invalid_fieldid isn’t a whole number.
400TEMPLATE_STARTER_READONLYThe id is a Ready starter template, not one of yours.
404TEMPLATE_NOT_FOUNDNo such template on your account, or it was already deleted.
500TEMPLATE_LOAD_FAILEDThe template couldn’t be read. Nothing was deleted. Try again.
500TEMPLATE_DELETE_FAILEDThe template couldn’t be deleted. Try again.

#Count a template use

Adds one to the template’s use_count and sets last_used_at to now. Needs send_sms. No body. It doesn’t send a message or fill in merge fields; call it after you send with the template if you want the count to stay accurate. Each call counts one more use.

Parameters

idinteger, pathRequired
The template id.
Errors
HTTPCodeWhen
400invalid_fieldid isn’t a whole number.
404TEMPLATE_NOT_FOUNDNo such template on your account, or it was deleted. Nothing was counted.
500TEMPLATE_LOAD_FAILEDThe template couldn’t be read. Nothing was counted. Try again.
500noneThe count couldn’t be saved. The answer has an error sentence and no code.

#List suggested templates

Returns up to five messages you send often that aren’t saved as templates yet. Ready reads the text of your recent campaigns (every A/B version) and drip steps as you wrote them, so merge fields and spintax stay in. Texts that match apart from case and spacing count as one. A text needs at least two uses to show up. The most used come first.

Returns
dataobject[]
The suggestions. An empty list means nothing you send often is unsaved.
data[].bodystring
The text, as in its most recent use.
data[].times_usedinteger
How many campaigns, A/B versions and drip steps used this text.
data[].namestring
A suggested name: the first few words, without merge fields or spintax.
data[].merge_fieldsstring[]
The merge fields in the text, for example contact.first_name.
data[].has_spintaxboolean
Whether the text has spintax.
Errors
HTTPCodeWhen
500TEMPLATE_SUGGESTIONS_LOAD_FAILEDThe suggestions couldn’t be read. Try again.