business template

Coupon Voucher API

Send the discount, code, and brand details as JSON, get back a 1200x600 voucher PNG.

Coupon Voucher template preview, a business image generated by the HTML to Image API

E-commerce stores and partner programs use the coupon image generator to ship per-recipient voucher artwork rather than embedding plain promo codes in email body text. The 2:1 landscape ratio fits standard email body widths and renders cleanly inside SMS previews on iOS and Android. You post the discount text, the code, and the brand inputs as JSON, and the response holds a PNG ready to attach to a campaign or queue in your customer messaging tool.

Use cases

E-commerce email campaigns delivering personalized codes

Welcome flows, win-back campaigns, and birthday emails all benefit from a coupon image personalized to the recipient. Render with a unique code per customer (so you can track redemption back to the campaign), embed the URL in the email body, and the recipient sees an image that feels intentional rather than a generic broadcast. Riverside Bakery runs 4 personalized email campaigns per quarter through this template, each with 8,000 unique codes.

SMS marketing with one image per recipient

MMS supports image attachments for marketing messages, so a styled voucher image lands in the recipient's SMS inbox alongside the promo text. Render per recipient with a unique code, attach via your messaging provider (Twilio, MessageBird, Vonage), and the open rate climbs because the message stands out from plain SMS noise. Linden & Co's retail clients run quarterly SMS campaigns through this exact pattern.

Partner co-marketing programs

Two brands running a joint promotion benefit from a voucher image that carries both logos and a shared accent treatment. Render with both brand_name values combined ("Riverside x Northwind", for example) and a co-branded accent_color, then both partners can share the same image to their respective audiences. Halberd Software's partner program runs 6 co-marketing pushes per year using this template.

In-app rewards delivered as shareable images

Loyalty programs that issue rewards in-app benefit from voucher images that customers can screenshot and forward. Render per reward earned, store the URL on the user's rewards record, and the user has both an in-app display and a forwardable image to share. Wren Analytics built this for a 240,000-user loyalty program, and gift forwarding (one of the program goals) climbed measurably.

Refer-a-friend program rewards

Referral programs that reward both the referrer and the new customer benefit from voucher images that look like a finished product rather than a stitched email. Render one voucher per side of the referral, with personalized codes for each, and the program performs better because both sides receive a polished asset rather than a plain code. Northwind Studio's referral program ships 600 vouchers per month through this template.

Output specifications

Dimensions
1200x600
Color space
sRGB
Transparency
Not supported
File size range
50 KB to 160 KB

Matches the spec at 2:1 landscape ratio for email body and SMS preview.

How it works

1

Send a JSON payload

POST to the template endpoint with the values you want rendered. Authenticate with your API key.

2

We render the image

The template is rendered server-side as a 1200x600 PNG.

3

You get back a URL

Cache it, embed it in your page, attach it to an email.

Quick example

A single cURL call to render a Coupon Voucher as a PNG:

curl -X POST https://app.html2img.com/api/v1/templates/coupon-voucher \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"discount_text":"20% OFF","code":"SPRING20","brand_name":"Riverside Bakery","expiry":"Valid until June 30, 2026","terms":"One use per customer. Excludes wholesale orders.","accent_color":"#B45309","background_color":"#FFFBEB"}'

For the full PHP, Node and Python equivalents, plus every input the template accepts, see the Coupon Voucher API reference. Setting up your key is covered in the authentication guide.

Common pitfalls

Codes too small to read on mobile

A 12-character code rendered at 16-pixel type is hard to read or transcribe on a phone. Pick codes of at most 10 characters and the renderer prints them at a size that survives mobile screens, where most marketing email gets opened.

Expiry date format inconsistency across regions

A US-formatted expiry "06/30/26" reads as June for US customers and March for European ones. Pre-format the expiry string per market on your side ("Valid until June 30, 2026") so the meaning is clear regardless of locale conventions.

Contrast between code and background fails accessibility

A pastel accent_color over a similar background_color creates a code that vanishes for users with color-vision differences. Test contrast ratio above 4.5 between the code text and its background, since the code is the most actionable element of the voucher.

Inputs at a glance

A quick summary of what the Coupon Voucher template accepts. The full reference, with example values and array shapes, is in the docs.

Name Type Required
discount_text string Required
code string Required
brand_name string Required
expiry string Optional
terms string Optional
logo_url url Optional
accent_color string Optional
background_color string Optional

See the full inputs reference for descriptions, examples and validation rules.

Related templates

Related guides

FAQ

Try it free

25 renders a month on the free tier. See the pricing page for higher-volume plans.