Documentation

Markdown and HTML to WhatsApp formatting

WhatsApp has its own small formatting: bold, italic, strikethrough, monospace, lists and quotes. Convert Markdown or HTML (from an AI model, a CMS or an e-mail) into it, and cut long texts into messages of 4096 characters.

Text from an AI model, a CMS or an e-mail is often Markdown or HTML. WhatsApp does not read either: **bold** arrives with its stars, a link arrives as [text](url), and HTML tags arrive as text. app2email converts it into WhatsApp's own formatting.

What WhatsApp shows

WriteWhatsApp shows
*bold*bold
_italic_italic
~strikethrough~strikethrough
monospace a monospace block
`inline code`inline code
- item or * itema bulleted list
1. itema numbered list
> quotea quote

What the conversion does

MarkdownBecomes
**bold**, __bold__*bold*
*italic*_italic_
~~strike~~~strike~
# Heading*Heading* on its own line
- , * , + , 1. lists, > quoteskept, in WhatsApp's form
`code`, ``` blocks | kept (a block's language tag is dropped)
[text](https://...)text: https://... (just the address when both are the same)
![alt](https://...)alt: https://...
a tableone line per row: a | b
---removed

From HTML: b / strong, i / em, s / del, br, p, ul / ol / li, a, code and pre are converted the same way; every other tag is dropped, entities such as & are decoded, and script and style contents are removed. Nothing in the text is ever fetched.

Try it: POST /format

curl -X POST "https://api.app2email.com/v1/YOUR_NUMBER/format" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "**Order 1234** is on its way. Track it [here](https://shop.example.com/t/1234).", "from": "markdown"}'
{
  "success": true,
  "request_id": "f0rm1",
  "text": "*Order 1234* is on its way. Track it here: https://shop.example.com/t/1234.",
  "length": 75,
  "parts": ["*Order 1234* is on its way. Track it here: https://shop.example.com/t/1234."],
  "changes": ["1 bold text converted", "1 link written out"]
}

It sends nothing (a key with messages:read is enough). from is markdown (the default) or html. With "split": true, parts holds the text cut into messages of at most 4,096 characters (WhatsApp's limit): at a paragraph end, else a sentence end, and never inside a code block when there is another place to cut. The text may be up to 100,000 characters. AI agents use the MCP tool format_text.

Convert while sending

Add format to a text message, and split for long texts:

curl -X POST "https://api.app2email.com/v1/YOUR_NUMBER/messages" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to": "61412345678", "type": "text", "text": {"body": "## Your order\n\n**1234** ships today.", "format": "markdown", "split": true}}'

With split, a text longer than 4,096 characters goes as several messages, in order; the answer lists their message_ids. Each one counts as a message of your plan.

Errors

CodeStatusMeaning
invalid_format_request400text is missing, from is not markdown or html, or split is not true or false.
text_too_long_to_format413The text is longer than 100,000 characters.

The complete list is on the errors page.