Send Your Own HTML Designs Through the API and MCP
You can send a complete HTML page as the design of a postcard, MagnaCard, letter, notecard, or gift card, and thanks.io prints it at full print size. It works through API v2's /send/* endpoints and through an AI assistant connected to the thanks.io MCP server, using two fields: front_html and background_html. Replacement variables in the page are filled in for each recipient, and QR codes you mark in it are tracked per recipient.
There is no HTML editor in the dashboard. To design there, build a creative instead. A saved creative sent by creative_id is still the simplest way to send, and the better choice for any design you'll mail again.
Which side each HTML field prints on
| Mailer | front_html prints | background_html prints |
|---|---|---|
| Postcard (4x6, 6x9, 6x11) | The front | The back, under the message, return address, postage and recipient address |
| MagnaCard | The front | The back, under the message and addresses |
| Notecard | The outside | The inside, under the handwritten message |
| Gift card | The outside | Not accepted |
| Letter (windowed or windowless) | The page background, under the handwritten message | Not accepted |
On a letter, the message prints on top of the page background, so keep the area behind the text light. A gift card's inside holds the card itself, so it takes no HTML. Sending background_html for a letter or gift card is refused with a 422.
Each field replaces the other ways of setting the same side, and can't be sent alongside them:
front_htmlcan't be combined withfront_image_url,image_template,image_template_id,front_image_html_urlorfront_image_html_content, or withpdf_only_urlon a letter. To add a PDF after an HTML-designed letter page, useadditional_pages_url.background_htmlcan't be combined withcustom_background_image,custom_background_url,back_image_html_urlorback_image_html_content. It replaces any background a message template would supply.- Neither can be combined with
creative_id, because a creative carries its own design.
The message, handwriting, recipients, qrcode_url and every other send field work as usual. See the send endpoints at docs.thanks.io for the full request.
Canvas sizes and safe areas
Design each side at 96 CSS pixels per inch and size the page to the full canvas, which includes the bleed. Keep text and anything important about 0.25 inch inside the edges.
| Mailer | Front canvas | Back or inside canvas |
|---|---|---|
| 4x6 postcard | 6.25 x 4.25 in | 6.25 x 4.25 in |
| 6x9 postcard | 9.125 x 6.125 in | 9.125 x 6.125 in |
| 6x11 postcard | 11.125 x 5.925 in | 11.125 x 5.925 in |
| MagnaCard | 8.63 x 5.63 in | 8.63 x 5.63 in |
| Notecard and gift card | 6 x 4.38 in (outside) | 5.5 x 8.25 in (notecard inside) |
| Letter | 8.5 x 11 in | None |
On a postcard or MagnaCard back, thanks.io prints the address block and postage in the bottom-right corner. Leave that area empty:
- 4x6 postcard: 3.56 x 2.57 in
- 6x9 postcard: 4.2 x 3.19 in
- 6x11 postcard: 3.89 x 2.34 in
- MagnaCard: 3.88 x 2.16 in, and keep the top-right area clear for the magnet
Keep the area behind the handwritten message plain enough for the handwriting to read.
What an HTML page can and can't use
- No JavaScript runs. Build the layout with HTML and CSS only.
- Images and fonts must be public https URLs. Google Fonts works. Links to private or internal network addresses are blocked.
- Fonts without a web font print in a matching substitute: serif names such as Times New Roman and Georgia print in Liberation Serif, sans-serif names such as Arial and Helvetica in Liberation Sans, and monospace names in Liberation Mono. Load a web font when the exact typeface matters.
- The page can't redirect or navigate away from itself.
- Size limit: up to 524,288 characters per field through the API, and 100 KB (102,400 characters) per field through an AI assistant. Link images by URL instead of embedding them as
data:URIs. A stored send (/stored_send/*) holds at most 64 KB of request data in total, so a stored send with large HTML is refused; send it directly instead.
Why a design is refused instead of printed
thanks.io refuses a page that would print badly rather than mailing it. A request that is refused this way returns an error naming the problem (and the URLs involved), and nothing is charged. A page is refused when:
- An image, font, or other file it loads fails, is blocked, or returns an error.
- An
<img>doesn't decode as an image. - The page has nothing on it, such as plain text that isn't HTML.
- A tracked QR code element is too small, or there are more than 4 on one side (see below).
Personalize an HTML design with replacement variables
Write a replacement variable anywhere in the page as {{FIRST_NAME}} or %FIRST_NAME%, and thanks.io fills it in for each recipient. The names are the same ones a message takes, custom fields included ({{CUSTOM1}} to {{CUSTOM10}}).
<h1>Hi {{FIRST_NAME|Neighbor}},</h1>
<p>Homes on {{STREET_ONLY}} in {{CITY}} are selling fast. {{CUSTOM1}}</p>
<p>Call {{YOUR_FIRST_NAME}} at {{YOUR_PHONE}}</p>
- Fallbacks.
{{FIRST_NAME|Neighbor}}prints "Neighbor" for a recipient with nothing to put there. Without a fallback, an empty value prints nothing. - Unknown names print as written. Only real variable names are replaced, so
{{PRICE}}orwidth:50%stays exactly as you wrote it. A preview warns when a token looks like a misspelled variable, such as{{FRIST_NAME}}, and suggests the name you probably meant. - Sender variables must be set.
{{YOUR_FULL_NAME}},{{YOUR_FIRST_NAME}},{{YOUR_PHONE}},{{YOUR_EMAIL}},{{YOUR_AI_PHONE}}and the branding images below stop the send when the account hasn't set them, unless you give them a fallback.{{YOUR_COMPANY}}prints blank instead. Fill them in on your Branding page. - The proof shows the first recipient you sent (or a sample recipient for a send to mailing lists). Each printed piece is then rendered with its own recipient's values.
Image variables: Street View, map and branding
Five variables fill with an image URL, for an <img src> or a CSS url():
| Variable | Image |
|---|---|
{{STREET_VIEW}} | A Street View photo of the recipient's property, or the map view where Google has no photo |
{{MAP_VIEW}} | A satellite view of the same address |
{{YOUR_LOGO}} | Your logo from Branding (your symbol stands in when there is no logo) |
{{YOUR_SYMBOL}} | Your symbol from Branding (your logo stands in when there is no symbol) |
{{YOUR_HEADSHOT}} | Your headshot from Branding |
<img src="{{STREET_VIEW}}" style="width:100%; height:3in; object-fit:cover">
<img src="{{YOUR_HEADSHOT|https://example.com/me.jpg}}" style="width:1in">
{{STREET_VIEW}} and {{MAP_VIEW}} show the recipient's property (absentee) address when it has one, and otherwise the address the piece is mailed to. For a just listed or just sold mailing that should show one home on every card, put that home's address in each recipient's absentee address. See Neighbor Blast.
The Street View photo is about 625 x 425 pixels, so print it no larger than about half a postcard and crop it with object-fit. A branding image takes a fallback URL the same way a text variable takes fallback text.
Add a tracked QR code to an HTML design
Mark where a QR code goes with an empty element carrying data-qr-url, set to where scans should go, and place and size it with CSS:
<div data-qr-url="https://example.com/offer"
style="position:absolute; right:0.5in; top:0.5in; width:1in; height:1in"></div>
thanks.io prints a tracked QR code of its own inside that element for each recipient, so scans show in your results and trigger your scan notifications.
- An empty
data-qr-url=""sends scans to the send'sqrcode_url, or to your default scan page when there is none. - A destination saved in a custom field works too:
data-qr-url="{{CUSTOM1}}". - The destination must be a full
https://URL, or atel:,sms:ormailto:link. - Make each element at least 0.6 inch on each side, on a white background. A smaller one is refused with the size it would print at.
- A side can carry at most 4 tracked QR codes.
- Keep the elements in the page's
<body>, not inside<template>or<noscript>.
A QR code pasted into the HTML as an image or <svg> prints exactly as written and isn't tracked. A preview warns you when it finds one, with where it points.
Preview an HTML design before sending
Add "preview": true to the send request to get the proof images without placing an order. When the page holds an untracked QR code or a token that looks like a misspelled variable, the response also carries a warnings list explaining each one. Through an AI assistant, the assistant runs preview-order and shows you the proofs and total before it sends. See API overview.
If a single recipient's piece can't be rendered at print time, that piece fails with the reason Error Processing Image rather than printing with another recipient's details or an untracked QR code. The rest of the order still mails.
Send an HTML design through an AI assistant
An assistant connected to the thanks.io MCP server takes the same front_html and background_html fields on preview-order and every send tool, with the same rules and a 100 KB limit per field. Ask it for an HTML design when you supply the HTML yourself or want a design reproduced exactly; otherwise it uses a saved creative or designs one with ThanksAI Studio. Its list-replacement-variables tool lists every variable, what each one prints, and which of your sender variables are set, so it can check before writing the page. See AI Assistants (MCP).
For prompts you can copy and paste, see AI Prompts for HTML Designs.
FAQs
Can I design a mail piece in the dashboard with HTML?
No. HTML designs are sent through API v2 (front_html and background_html on the /send/* endpoints) or through an AI assistant connected to the thanks.io MCP server. In the dashboard, build the design as a creative instead.
Why was my HTML design refused?
thanks.io refuses a page that would print badly instead of mailing it: an image or font that failed to load, a URL pointing at a private address, an image that couldn't be read, or a page with nothing on it. The error names the problem and the URLs involved, and nothing is charged. Fix the page and send again.
Can my HTML design use replacement variables?
Yes. Write {{FIRST_NAME}} or %FIRST_NAME% anywhere in the page and it is filled in for each recipient, with an optional fallback such as {{FIRST_NAME|Neighbor}}. {{STREET_VIEW}}, {{MAP_VIEW}}, {{YOUR_LOGO}}, {{YOUR_SYMBOL}} and {{YOUR_HEADSHOT}} are filled with image URLs.
How do I put a tracked QR code in an HTML design?
Add an empty element with a data-qr-url attribute set to where scans should go, and size and place it with CSS at least 0.6 inch square. thanks.io prints a tracked code for each recipient inside it, up to 4 per side. A QR image pasted into the HTML prints untracked.