Skip to content

How to format text and send emoji via API?#

When sending text through an API or integration, sometimes difficulties arise with the formatting of the message. In this article we will answer the most common questions about working with text:

  1. How to format text and use reserved characters?
  2. How to send an emoji or other symbol?

1. How to format text and use control characters?#

Formatting messages and using control characters:

Formatting Usage Description
Italic text _Italic text_ Enclose text between two underscores (_)
Bold text *bold text* Enclose text between two asterisks (*)
Strikethrough text ~strikethrough text~ Enclose text between two tildes (~)
Monospace text ```fixed space text``` Enclose text between two triple apostrophes ("```")
Wrap text to new line Wrap text\nsymbol Without spaces, enter a backslash followed by a lowercase n ("\n") after the word where you want to break the text to a new line
Wrapping text with tabs Wrap text\ttabulation Without spaces, enter a backslash followed by a lowercase t ("\t") after the word where you want to tab
Move the cursor to the beginning Wrap text\rsymbol Without spaces, enter a backslash followed by a lowercase r ("\r") after the word where you want to rewrite the text at the beginning of the line

This information is described in detail in official WhatsApp help.

If you need to write exactly "_text_" and not "text", you should put the special character twice: "__text__".
The "\" sign allows you to isolate the character following it so that it does not end up in the message text and fulfills its official function. If you want to send exactly "\" as text, then you need to write it twice "\\".

2. How to send emoji or other symbol?#

The easiest way to do this is to use the emoji built into your operating system.

Unfortunately, this method does not work everywhere.

To do this, place the cursor in the text field and use the hotkeys:

  • For Windows: Win + .
  • For MacOS: control + command + space

Then select the symbol of interest in the pop-up window.

If the 'Hotkey' method does not work in your application, and the hotkeys are not functioning, sometimes the simplest solution is to copy emojis from a messenger, browser, or any other source.

Example: 😃😎🤯

Example of a site with emoji.

If the field does not support emoji insertion or if the inserted emojis do not display correctly, consider using a character encoding.

This method does not function directly in WhatsApp, WhatsApp Web, browsers, or Personal Accounts.
It is only applicable for sending raw text via the API (such as Postman, 1C processing, or within the body of an HTTP request)."

To send emoticons to WhatsApp from our API, we recommend using UTF-16. To do this, you need to represent the character as a hexadecimal number or a surrogate pair, two hexadecimal numbers.

\uD83D\uDE01 - an example of a surrogate pair

These numbers are in the Unicode character table..

The order in which a character is provided as hexadecimal numbers is:

  1. Click on the Unicode column value next to the selected emoji.

    sending-emoji-1c.png

  2. Then select the column with surrogate pairs, for example for the emoji 😁.

    sending-emoji-1c.png

  3. To indicate that text is in Unicode (Unicode), enter a backslash followed by a lowercase u ("\u") before each hexadecimal number. For example: D83D DE01 => \uD83D\uDE01


Example of sending 😁 through 1C processing

By sending such a string to API through 1C processing, you will send to WhatsApp - 😁:

Insert a surrogate pair for the desired emoticon, in this case: \uD83D\uDE01

sending-emoji-1c.png

WhatsApp display:

sending-emoji-1c.png


Using character spacing

Using a 16-bit character representation allows the use of invisible characters that indicate the spacing between letters or numbers. This makes it possible, for example, to send empty messages or more finely adjust the indentation.

Examples of interval symbols:

\u00A0 - Non-Breaking Space empty-message-whatsapp.png
\u2000 - En Quad
\u2001 - Em Quad
\u2002 - En Space
\u2004 - Three-Per-Em Space
\u2005 - Four-Per-Em Space
\u2006 - Six-Per-Em Space
\u2007 - Figure Space
\u2008 - Punctuation Space
\u2009 - Thin Space
\u200A - Hair Space
\u2028 - Line Separator
\u205F - Medium Mathematical Space
\u3000 - Ideographic Space