Skip to main content

How to Generate API Payloads for Message Templates

Build message templates with variables filled in, then copy the exact cURL request to send via API. No more syntax guessing.

Updated over a week ago

Getting the payload structure right for WhatsApp message templates can be tricky. This feature lets you build the template visually, fill in variables, and grab the exact cURL request you need.

Why This Matters

Before this, you had to manually construct JSON payloads and guess at the right structure for buttons, quick replies, and parameters. Now you just fill out the template like you're sending a normal message, and Spur generates the API code for you.

How to Use It

Step 1: Open Any Template

Go to your Shared Inbox and click the template icon to open any approved message template.

Step 2: Fill in Variables

Fill in all the template variables just like you're about to send a real message:

  • Add header images/videos if the template has media

  • Fill in body variables (name, order number, discount code, whatever)

  • Fill in button variables if you have dynamic buttons

Step 3: Click "View cURL Request"

At the bottom of the template editor, you'll see a button that says View cURL Request. Click it.

Step 4: Copy the Request

A modal pops up with the complete cURL command. It includes:

  • The full API endpoint

  • Your bearer token (replace YOUR_BEARER_TOKEN with your actual API key)

  • The complete JSON payload with all parameters filled

  • Proper formatting for headers, body text, and buttons

Just hit Copy and paste it into your terminal or API client.

Step 5: Replace Placeholders

Before running it:

  • Replace YOUR_BEARER_TOKEN with your actual API key from Settings > API

  • Replace YOUR_PHONE_NUMBER with the recipient's number (include country code, no + sign)

That's it. Run the command and your template sends.

Common Use Cases

Testing Templates Fill out a template, grab the cURL, test it in your terminal before integrating it into your app.

Debugging Errors If you're getting errors like EC_INVALID_TEMPLATE_ARGS, use this to see the exact structure Spur expects. Compare it to what you're sending.

Onboarding Developers Instead of writing docs for your dev team, just show them this feature. They can see exactly how to format requests for any template.

Quick Replies vs Call to Action Buttons The payload structure is different for quick reply buttons vs URL/phone buttons. This shows you the exact syntax for whichever type your template uses.

Things to Know

Quick Reply Buttons Don't Need Params If your template has quick reply buttons, the payload field stays empty. Don't try to fill it. The cURL shows this correctly.

Hebrew (or RTL) Templates Work Fine Language code gets set automatically. You don't need to do anything special.

Images Must Be Hosted If your template has an image header, make sure the URL you use is publicly accessible. The example cURL uses a Spur hosted image, but you can replace it with your own.

Button Index Matters Buttons are indexed starting at 0. If you have two buttons, they're index: 0 and index: 1. The cURL shows this correctly.

Troubleshooting

"Authorization: bearer YOUR_BEARER_TOKEN"

This is a placeholder. Go to Settings > API, copy your actual key, and replace it in the cURL command.

"EC_MEDIA_UNSUPPORTED"

Your image/video/PDF URL isn't accessible or the format isn't supported. Try using a direct link to a publicly hosted file.

Single Tick, No Delivery

If the message sends (you see a single tick) but doesn't deliver, check if the phone number is correct and if the recipient's WhatsApp is active.

Example

Here's what a filled template looks like:

Template: repeat_purchase_offer_spur

Header: Image (product photo)

Body: "Hello {{1}}, thank you for being a loyal customer of {{2}}. Buy more and get an exclusive {{3}} discount on your next order."

Buttons: Two quick replies ("Copy offer code" and "Start Shopping")

After filling:

  • {{1}} = "Rohan"

  • {{2}} = "Spur"

  • {{3}} = "15%"

Click View cURL Request, copy the command, replace the token and phone number, run it. Done.


That's it. No more guessing at payload structure or debugging mysterious API errors. Fill it out, grab the code, send it.

Did this answer your question?