Home  /  Insights  /  Advertising
Advertising

How an agency creates a local Offer through the Agilis Advertising API

A step-by-step guide for agencies and developers: get approved, estimate the price, create a Test Offer, move to Live safely and read the results.

An agency team works around a shared table covered in printed charts and marketing notes, two of them typing on laptops while a colleague stands and watches.

If you run local campaigns for clients, the Agilis Advertising API lets you create and manage Offers from your own code instead of the Ad Portal. An Offer is a deal from a local business, such as 20% off at a café, that Agilis members see when they're nearby. This guide walks through one Offer from start to finish. Everything happens in Test mode first, which is free and never shown to members. The figures in the example replies are illustrative: yours depend on your area, your targeting and your dates.

The API reaches only your own Offers, Events, balances and aggregated results. It never gives access to member profiles, messages or anything that identifies a member.

Before you start #

  • An approved business account. Register your business. Approval usually takes up to five working days.
  • The Advertising Terms accepted. An Org Admin accepts them in the Ad Portal. Until then, creating an Offer is refused with E9.
  • A Test API key. An Org Admin or Developer switches the Ad Portal to Test mode and creates a key under API keys. Test keys start pk_test_. The key is shown once, so copy it straight into a password manager or an environment variable.
  • A square image for the Offer: JPG, PNG or GIF, up to 5 MB. 1080 × 1080 pixels works well.

Every request goes to https://ads.agilis.dating with your key in the x-api-key header. You can follow along with curl, with one of the seven official SDKs, or with the command-line tool (npx @agilisdating/ads-cli). The API reference has every field and return code.

Step 1: Find your category #

Every Offer needs a category. Ask for the ones assigned to your organisation:

curl "https://ads.agilis.dating/categories" \
  -H "x-api-key: $AGILIS_API_KEY"

The reply lists each category's id and name. Note the category_id you want:

{
  "categories": [
    { "category_id": 54, "category_name": "Restaurants & Cafés" },
    { "category_id": 55, "category_name": "Bars, Pubs & Nightlife" },
    { "category_id": 56, "category_name": "Entertainment & Events" }
  ]
}

If you want to reach members with particular interests, GET /interests lists those too. It's optional.

Step 2: Estimate the price #

An Offer is priced by its reach and its length: the number of members it would reach, times the hours it runs, gives a number of Ad Units, and each Ad Unit costs £0.001 (or the same in your billing currency). Ask for an estimate before you create anything:

curl -X POST "https://ads.agilis.dating/offers/price-estimate" \
  -H "x-api-key: $AGILIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "start_datetime": "2027-07-10T08:00:00Z",
    "end_datetime": "2027-07-12T20:30:00Z",
    "location": [51.5074, -0.1278],
    "radius": 10
  }'

Times are in UTC, the location is latitude and longitude, and the radius is in miles, from 5 to 30. You can also target by gender and by interests (ids from GET /interests). Send the same targeting you'll use for the Offer, because narrower targeting reaches fewer members and costs less. The reply:

{
  "return_code": "S1",
  "price_estimate": 75020,
  "matching_users": 1240,
  "ad_units": 75020,
  "ad_unit_price": 0.001,
  "estimated_cost": 75.02,
  "currency": "GBP",
  "exchange_rate_per_gbp": 1,
  "exchange_rate_date": null
}

Step 3: Create a Test Offer #

An Offer is sent as a form with its image attached. Three things to get right:

  • environment=TEST, in capitals, to match your Test key.
  • An Idempotency-Key header, a value you make up for this Offer, such as a UUID. If the request times out and you send it again with the same key, you get the original reply instead of a second Offer.
  • payment_method=B, to pay from your balance. In Test mode that's your Test balance, which is never real money.
curl -X POST "https://ads.agilis.dating/offers" \
  -H "x-api-key: $AGILIS_API_KEY" \
  -H "Idempotency-Key: 3f1a9c7e-1b2d-4f9a-8c0e-2a6b5d4e7f10" \
  -F "category_id=54" \
  -F "title=20% off summer drinks" \
  -F "description=Show this Offer at the counter for 20% off any cold drink." \
  -F "terms_and_conditions=One per person. Not with other offers." \
  -F "advertised_name=Brighton Bakehouse" \
  -F "push_notification_title=20% off cold drinks" \
  -F "push_notification_message=Show this at the counter for 20% off any cold drink this weekend." \
  -F "button_preset=get_directions" \
  -F "url=https://www.example.com/summer" \
  -F "location[]=51.5074" \
  -F "location[]=-0.1278" \
  -F "radius=10" \
  -F "start_datetime=2027-07-10T08:00:00Z" \
  -F "expiry_datetime=2027-07-12T20:30:00Z" \
  -F "payment_method=B" \
  -F "environment=TEST" \
  -F "image=@offer.jpg"

advertised_name is the business name members see. Agencies use it to show their client's name instead of the agency's; you need the client's permission to use it, and invoices and results stay in your organisation's name. The notification title (5 to 50 characters) and message (5 to 150) go to members who chose to hear about Offers. The image and the notification text are checked by automated moderation before anything is created.

When it works, the reply gives you the Offer's id. Because this one starts in the future, it's Scheduled:

{
  "return_code": "S1",
  "offer_id": 281,
  "status": "Scheduled",
  "payment_url": null
}

To see the Offer, list your Test Offers (GET /offers?environment=test) or fetch it by id (GET /offers/281). Once created, a future Offer is listed as Active with its future start_datetime; members see it from that time. Test Offers are deleted automatically 30 days after they end.

Step 4: Move to Live safely #

When the Test run behaves as you expect, the same requests work in Live. Live is real: members see the Offer, and creating it is paid. These habits keep it safe.

  1. Use a Live key, kept apart. Create it with the Ad Portal in Live mode. Store it separately from your Test key, and send environment=LIVE.
  2. Do a dry run first. Add ?dry_run=true to POST /offers. The API checks everything and tells you what the Offer would cost, how many members it would reach and how it would be paid, without creating or charging anything.
  3. Check your own balance. A Live Offer with payment_method=B is paid from the balance of the person who owns the API key. The Organisation balance in the Ad Portal is the total of everyone's balances, not a shared wallet, so make sure the key owner's own balance covers estimated_cost. If it doesn't, the request is refused with E3 and nothing is charged.
  4. Set spending limits. An Org Admin can set limits per listing, per day and per month, for the organisation and for each person, in the Ad Portal under Settings. A Live request that would pass one is refused with E17, which says which limit and when it resets.
  5. Keep the same Idempotency-Key on retries, so a network hiccup never creates a second Offer.

A Live dry run of the same Offer looks like this (example figures):

curl -X POST "https://ads.agilis.dating/offers?dry_run=true" \
  -H "x-api-key: $AGILIS_LIVE_API_KEY" \
  ...the same fields as before, with environment=LIVE...
{
  "return_code": "S1",
  "dry_run": true,
  "message": "Dry run: the Offer passed every check. Nothing was created or charged.",
  "environment": "LIVE",
  "status_if_created": "Scheduled",
  "matching_members": 1240,
  "ad_units": 75020,
  "price": 75.02,
  "currency": "GBP",
  "payment_method": "B",
  "balance": 100,
  "balance_after": 24.98
}

Every change made with your keys is listed on the API activity page in the Ad Portal, with the key and the amount.

Step 5: Read the results #

Once the Offer is running, ask for its results over a period: 24h, 7d, 30d, 60d, 90d or all.

curl "https://ads.agilis.dating/offers/281/analytics?interval=7d" \
  -H "x-api-key: $AGILIS_API_KEY"

The reply has three parts. The figures below are an example, shortened: by_day has one entry per day and groups always has 18 entries.

  • metrics: views and clicks in the period. A view is a time a member opened your Offer; a click is a time they selected its button.
  • by_day: the same figures for each day, in the time zone set for the key owner's account in the Ad Portal (London time if none is set). Days with nothing are included as 0, so the days add up to the totals.
  • demographics: views and clicks by age group (18-24 up to 65+) and gender.
{
  "offer_id": 281,
  "interval": "7d",
  "metrics": { "views": 3933, "clicks": 853 },
  "time_zone": "Europe/London",
  "by_day": [
    { "date": "2027-07-10", "views": 212, "clicks": 41 },
    { "date": "2027-07-11", "views": 498, "clicks": 96 }
  ],
  "demographics": {
    "min_group_size": 5,
    "views": {
      "total": 3638,
      "has_hidden_groups": true,
      "by_gender": [
        { "gender": "Female", "count": 1864 },
        { "gender": "Male", "count": 1694 },
        { "gender": "Non-binary", "count": 80 }
      ],
      "groups": [
        { "age_group": "18-24", "gender": "Female", "count": 312, "hidden": false },
        { "age_group": "65+", "gender": "Non-binary", "count": null, "hidden": true }
      ]
    }
  }
}

Agilis counts views and clicks. It can't tell whether a click led to a sale or a visit, so track that on your own landing page.

Managing the Offer afterwards #

You can pause (POST /offers/{id}/pause) and resume (POST /offers/{id}/resume) an Offer, or delete it (DELETE /offers/{id}). Offers can't be edited through the API, and a deleted Offer can't be restored. Deleting a paid Offer credits the time it didn't run to your balance; try DELETE /offers/{id}?dry_run=true first to see the amount.

Next: connect an AI assistant to Agilis, browse the developer hub, or read the full API reference. Questions: help@agilis.dating.

Download

QR code to download the Agilis app
Download on the App Store Get it on Google Play
Two phones showing the Agilis app: a member's profile card and the Agilis logo

Socials

Agilis on Facebook Agilis on Instagram Agilis on LinkedIn Agilis on X Agilis on TikTok

We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. (View Cookie Policy)