Guides

Automated emails from your store or app

Send an email when something happens in your store, with a Shopify abandoned cart example.

Campaigns go to a whole list at once. An automated email goes to one person at the moment something happens in your store or app, such as a cart being left behind.

Example: abandoned cart from Shopify

Shopify records an abandoned checkout when a shopper enters their email at checkout and leaves without paying. This example sends them one reminder with their cart and a link back to it.

1. Create the template

In Email Templates, create a template called Cart reminder with these parts in the HTML body:

  • Hi {{first_name|there}}, for the greeting.
  • {{#each cart_items}}{{name}} x {{qty}}, {{price}}{{/each}} to list the products.
  • A button that links to {{checkout_url}}.
  • {{#if coupon}}Use code {{coupon}} at checkout.{{/if}} to show a code only when there is one.

Save it. In the Variables panel, mark checkout_url as required, so an email without the link is never sent. Note the template's ID from the template list; this example uses 12.

2. Create an API key

Open Settings, then API keys, create a key with the messages:send scope, and copy it. It is shown only once.

3. Send the request when a checkout is abandoned

Your developer, or a Shopify Flow workflow with a Send HTTP request action, sends this request about an hour after the checkout is abandoned:

Example
POST https://velosend.xavierapps.com/api/v1/templates/12/send
Authorization: Bearer vs_live_your_key
Content-Type: application/json

{
  "email": "riya@example.com",
  "first_name": "Riya",
  "variables": {
    "checkout_url": "https://yourstore.com/checkouts/abc123/recover",
    "cart_items": [
      { "name": "Running shoes", "qty": 1, "price": "₹2,999" },
      { "name": "Sports socks", "qty": 2, "price": "₹398" }
    ],
    "coupon": "COMEBACK10"
  },
  "idempotency_key": "shopify-checkout-1234567890-reminder"
}
FieldWhere it comes from
email, first_nameThe customer on the abandoned checkout.
checkout_urlThe checkout's abandoned_checkout_url from Shopify, which reopens their cart.
cart_itemsThe checkout's line items: product title, quantity, and price.
couponOptional. Leave it out and the coupon line is not shown.
idempotency_keyThe Shopify checkout ID plus the step name. If the call is retried, VeloSend sends the email only once.

4. Check it worked

VeloSend answers 201 with a send_id. GET /api/v1/sends/{id} shows whether the email was sent, delivered, opened, or clicked, and any variables that came out blank. VeloSend also saves the shopper as a contact, and it never emails someone who unsubscribed.

What comes next

A full flow has more steps, such as a second reminder a day later, or no reminder once the order is paid. Those follow-up steps will come with webhooks. Until then, each extra email is another call from your store with its own idempotency_key.

The same call works for other one-to-one emails: a welcome email on sign-up or an order confirmation, each with its own template.

Developer details

Send one email explains every field and error, Template variables covers variable types and defaults, and API security explains keys and rate limits. Share these with the developer who connects your store.