Skip to content

Send a template for a record

Open .md

POST/v2/api/store/{team_slug}/setting/message_template/send

v2Operation ID v2_public_message_template_send

Fills a saved template from one record and sends it now. It reaches a real customer or vendor and can't be recalled.

  • Email templates send an email, with the template's attachments.
  • Text message templates send a text through your Twilio integration.

Who gets it: for an email, the record's message participants who receive mail and messages, or the record's contact if there are none. For a text, the participants who receive texts; with none, nobody is texted.

Email limit: if your team goes over the daily email limit for its plan (60 a day on a free plan or trial, more on paid plans), YoPrint blocks email sending for your whole team until YoPrint support lifts the block. Space out bulk sends.

The six saved email types have no subject line of their own: their compiled subject is empty.

Compile it first to check the result. The response has no data.

Permission

With a personal API key, any member of the team: no permission on the record is checked, even for members who can't see that order. AI apps need permission to message about that record.

Business rules

  • Purchase order templates need the "send purchase order email" feature in your plan (422 plan_limitation).
  • A team on a trial can send only when YoPrint has turned on email for its trial, and a paid team needs an active subscription (otherwise 422 email_feature_not_enabled_in_trial).
  • Every team has a daily email limit. Going over it blocks the team's email sending until YoPrint support lifts the block.

Side effects

  • Sends an email or a text message to the customer or vendor, and saves it with the record's messages.
  • Document attachments (such as the order PDF) are made from the record at the time of sending.
  • Spends money A text message is sent through your Twilio account and costs what Twilio charges.

Path parameters

  • team_slugstringrequired

    Your team slug, shown as Team ID next to your API key in Profile.

    • Example your-team

Request body

application/json, required.

  • idstringrequired

    The saved template's id.

  • object_idstringrequired

    The record it is about: a sales order or quote id for sales order and quote templates, a purchase order id for purchase order templates.

Response

200Successful response.

Errors

  • 401The API key is missing or wrong (unauthenticated).

  • 403You are not allowed to do this. api_access_not_in_plan: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only {"message": "Insufficient Permission"}. Other refusals use the error envelope, with unauthorized or user_is_not_authorized.

  • 404Not found. page_not_found: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. code: null, with a message that starts "No query results for": there is no record with that id.

    When
    No template of your team has this id.
    Fix
    Use an id from the template list.
  • 422The request was refused and changed nothing. validation_failed lists what to fix in error.fields; other codes name a business rule, explained in error.message. A few checks answer with only {"message": "..."}. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer connect_timeout ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.

    When
    object_id is missing (validation_failed).
    Fix
    Send the record's id.
    When
    object_id is not a record of your team of the right kind: error.code send_failed. Nothing is sent.
    Fix
    Send a sales order or quote id for those templates, a purchase order id for purchase order templates.
    When
    Your plan doesn't allow purchase order emails (plan_limitation), the trial doesn't allow email (email_feature_not_enabled_in_trial), or the team is over its daily email limit (validation_error, "You are sending too many emails...").
    Fix
    Read error.message; contact YoPrint support if sending is blocked.