Docs
العربية Get your keys

JavaScript API

For order pages that send the order with fetch or AJAX instead of submitting a form.

On this page

Check an order before sending it#

Call Antiro.decide() when the shopper presses the order button, and send its token with the order. The script may not have loaded, so check for it first and send the order anyway: your server check still runs.

An order page that sends with JavaScript
async function placeOrder(order) {
  const check = window.Antiro
    ? await window.Antiro.decide({
        phone: order.phone,
        name: order.name,
        address: order.address,
      })
    : { act: 'allow', token: '' };

  // notice or block: the shopper saw a message
  if (check.act !== 'allow') return;

  await fetch('/api/orders', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      ...order,
      session_token: check.token,
    }),
  });
}

What decide returns#

Antiro.decide() resolves to { act, token }:

actMeaningWhat to do
allowThe order can go. Also returned on any failure.Send the order, with token as session_token.
noticeThe shopper was asked to change something on their side.Do not send. Call decide() again at the next press.
blockThe shopper saw the refusal message.Do not send.

Reference#

Antiro.decide(contact) Promise

Checks the order. contact holds phone, name and address, all optional. Each call runs one check, and a call made while a check is running shares its answer.

Antiro.token() string

The current order reference, to send as session_token.

Antiro.ready() Promise

Settles once the script has tried to start its session.

Antiro.verdict() string

bot when Antiro judged this tab automated, ok when it answered, otherwise unknown.

Antiro.version string

The script’s version.

Search by topic, field name or status code.