Lockally

      Use your API key in the examples

      Replaces lk_live_… in the code samples on this site so you can copy and run them. It is stored in this browser only and is never sent anywhere, including to Ask AI.

      It will be visible on the page. Use a test key if you are sharing your screen or taking screenshots.

      HTML template best practices

      Most advice about email HTML is generic. This page is about what this platform does to your markup, because that determines which of the generic advice applies to you.

      Your HTML is sent as authored

      The body you store is written into the MIME part byte for byte. Nothing is added, rewritten or stripped:

      • No CSS inlining. A <style> block stays a <style> block. If you want inline styles, inline them before you store the template.
      • No link rewriting. Your href values reach the recipient unchanged.
      • No tracking pixel. No open tracking, no click tracking, nothing injected into the body.
      • No sanitising. Markup you store is markup that is sent.

      The only transformation anywhere in the path is the HTML-escaping of substituted variable values, which protects the template from its own data and is described in Template variables.

      Delivery reporting is aggregate rather than per-open: see GET /v1/messages/stats for counts and rates by outcome, which is what exists instead of open and click tracking.

      Store both bodies

      What the recipient’s client receives depends on which fields the template fills:

      Template has Message is
      html and text multipart/alternative, plain text part first
      html only a single text/html part
      text only a single text/plain part

      An HTML-only template therefore has no plain-text alternative, for every message ever sent from it. Writing the text body once, when you create the template, is the cheapest thing on this page.

      Both parts are sent as UTF-8 with Content-Transfer-Encoding: 8bit.

      Write for the escaping

      Because variable values are escaped in the html field, a variable can never contribute structure. Put the structure in the template and only the content in the variable:

      <p>Hi {{first_name}}, your order <strong>{{order_id}}</strong> shipped.</p>

      Not this, which sends the tags as visible text:

      <p>Hi {{greeting_html}}</p>

      Keep the subject plain

      Subject values are not escaped and not sanitised. A variable carrying a newline will end the subject line early, so strip control characters from anything you interpolate into a subject.

      Subjects are limited to 255 characters at the template level, before substitution. A long variable can push the rendered subject past what any client will display, so keep variable subjects short and front-load the part that matters.

      Size

      Each of html and text is capped at 512 KiB in the template. That is far above anything sensible for an email: several clients truncate well below it, and a large body costs you on every single send.

      The rendered message is also subject to the send limits, which are separate and smaller. Message size limits has the ceilings that apply to the request as a whole.

      Practical checks before a template goes live

      1. Render it with every variable missing and read the result. That is what a caller with a typo produces, and it goes out without complaint.
      2. Render it with a long value in each variable. Most layout breakage is a value that is longer than the designer assumed.
      3. Send it to yourself on a test key and read the stored body, which is the exact text that would have been transmitted. See Testing rendered emails.