Skip to content
AutomatedOn Help Centre

Write an API request body with tokens and expressions

An API request's Body is filled in for each record before it's sent. This guide explains how values are inserted, how to add dates relative to now, and how to use a simple condition to choose a value.

Inserting values into JSON

If the body starts with { or [, AutomatedOn treats it as JSON. Each value is made safe for JSON as it goes in: quotes, backslashes and line breaks are escaped so they can't break the body. Quotes are not added for you, so put a text token inside quotes:

{ "name": "$$StudentName$$", "notes": "$$Notes$$" }

For a number or true/false value, leave the quotes off:

{ "age": $$Age$$ }

If the body doesn't start with { or [, values are inserted exactly as they are.

Dates relative to now

You can use these tokens in the API Endpoint and Body. Each one is worked out, in UTC, at the moment the request is sent:

TokenBecomes
{aoDynamicMinutes:N}Now, plus N minutes
{aoDynamicHours:N}Now, plus N hours
{aoDynamicDays:N}Now, plus N days
{aoDynamicDaysAtMidnight:N}Midnight (UTC) today, plus N days

Use a negative N for the past, for example { "since": "{aoDynamicDays:-7}" }. The result looks like 2026-07-14T09:30:00Z.

Choosing a value with a condition

When the body is valid JSON, any text value written as a simple condition is worked out and replaced with the result:

{ "isActive": "$$Status$$ == 'Active' ? 'true' : 'false'" }

For a record whose Status is Active, this is sent as {"isActive":true}.

How it works:

  • A value is only treated as a condition if it contains == or !=, plus both ? and :. Anything else is left as plain text.
  • The format is value == value ? result-if-true : result-if-false. Use != for "not equal".
  • Put fixed text in single quotes, such as 'Active'.
  • Comparisons are exact and case-sensitive, except that true/false values match whatever their capitalisation (True equals 'true').
  • An empty value compares as empty text, so $$Status$$ == '' ? 'none' : 'some' works.
  • You can chain conditions: $$Grade$$ == 'A' ? 'top' : $$Grade$$ == 'B' ? 'good' : 'other'.
  • The result is sent with the right type: true and false become true/false values, numbers become numbers, and anything else becomes text.

Things to watch:

  • If a record value itself contains ==, !=, ? or :, the condition can be misread. Quote your fixed values to reduce the risk.
  • Conditions only work in the Body, not the API Endpoint.
  • Once the body has been checked as JSON, it is sent in compact form, without the spacing you typed.

When the request isn't sent

The request is not sent, and the record fails, if:

  • a token in the endpoint or body has no value
  • the body looks like it contains a condition but isn't valid JSON
  • a condition can't be worked out, for example a ? with no matching :

The Test tab shows these problems as issues before you go live. See Why did my API request fail? for the exact messages.

Was this guide helpful?