Create your first Offer through the API

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

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 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. Someone with the Developer role switches the Ad Portal to Test mode and creates a key under Manage API Keys. Test keys start pk_test_. The key is shown once, so copy it straight into a password manager or an environment variable.
  • An image for the Offer: JPG, PNG or GIF, up to 5 MB. Square works best, at least 1080 × 1080 pixels: the Offers list shows a square crop, and the Offer page shows the whole image.

Tip: keep the key out of your code. The examples below read it from an environment variable called AGILIS_API_KEY. Each key works in one mode only: a Test key can't touch Live Offers, and a Live key can't create Test ones.

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: Add free test funds

Test Offers are paid from your Test balance, which is never real money. A new business starts with nothing in it, so add free test funds first. There are two ways:

  • In the Ad Portal: switch to Test mode, open Balance and invoices and select Add £100 test funds. The button shows the amount in your billing currency.
  • With your Test key: send this request. It has no body.

Add test funds (curl)

curl -X POST "https://ads.agilis.dating/balance/test-funds" \
  -H "x-api-key: $AGILIS_API_KEY"

Each time, it adds a fixed amount in your billing currency: 100 for GBP, EUR, USD and CHF; 200 for CAD, AUD and NZD; 500 for PLN and AED; 1,000 for DKK, NOK and SEK; and 2,000 for MXN. Nothing is charged, no invoice is raised, and a Live balance never changes; a Live key is refused. The reply shows what was added and your new Test balance:

Reply: test funds added

{
  "return_code": "S1",
  "amount_added": 100,
  "currency": "GBP",
  "balance": 115,
  "organisation_balance": 120,
  "message": "Test funds added. Nothing was charged."
}

Step 2: Find your category

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

List categories (curl)

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:

Reply: categories

{
  "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 3: 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:

Price estimate (curl)

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:

Reply: price estimate

{
  "return_code": "S1",
  "price_estimate": 1149.5,
  "matching_users": 19,
  "ad_units": 1149.5,
  "ad_unit_price": 0.001,
  "estimated_cost": 1.15,
  "currency": "GBP",
  "exchange_rate_per_gbp": 1,
  "exchange_rate_date": null
}

estimated_cost is the money: £1.15 here. price_estimate and ad_units are a number of Ad Units, not money. If matching_users is 0, widen the radius or the targeting.

Step 4: 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 from Step 1, which is never real money.

Create a Test Offer (curl)

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:

Reply: Offer created

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

Check return_code, not only the HTTP status. Some refusals arrive with HTTP 200: E2 (the image was refused), E3 (the balance is too low) and E17 (a spending limit would be passed). Anything other than S1 means nothing was created or charged. In Test mode, an E3 reply says how to add free test funds.

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 5: 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. It runs every check a real create makes, image moderation included, and gives the same answer, or the same refusal, that the create would. It 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 balance_after. With payment_method=B, the dry run gives balance, the balance of the person who owns the API key, and balance_after, what it would be once the Offer is paid. A Live Offer is paid from that person's own balance; the Organisation balance in the Ad Portal is the total of everyone's balances, not a shared wallet. If the balance doesn't cover the price, the dry run is refused with E3, just as the real request would be, 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 dry run looks like this. The reply below is a real Test-mode one; a Live dry run has the same fields, with environment LIVE and your Live balance.

Dry run (curl)

curl -X POST "https://ads.agilis.dating/offers?dry_run=true" \
  -H "x-api-key: $AGILIS_LIVE_API_KEY" \
  -F "environment=LIVE" \
  -F "payment_method=B" \
  -F "image=@offer.jpg"
# ...and the other fields exactly as in Step 4

Reply: dry run

{
  "return_code": "S1",
  "dry_run": true,
  "message": "Dry run: the Offer passed every check. Nothing was created or charged.",
  "environment": "TEST",
  "status_if_created": "Scheduled",
  "matching_members": 19,
  "ad_units": 1149.5,
  "price": 1.15,
  "currency": "GBP",
  "payment_method": "B",
  "balance": 1991.22,
  "balance_after": 1990.07
}

The API never takes card details. Live Offers are paid from an existing balance, which you top up in the Ad Portal. If you'd rather pay for a single Offer by card, payment_method=E creates the Offer as Awaiting Payment and emails a secure payment link; the card is entered on the payment page, never sent through the API. The AI assistant connection (MCP) pays from the balance only.

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

Step 6: Read the results

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

Offer results (curl)

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

The reply has three parts:

  • 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.

Reply: Offer results (shortened)

{
  "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 }
      ]
    }
  }
}

Shortened: by_day has one entry per day and groups always has 18 entries.

To protect members, any age and gender group with fewer than 5 views or clicks is hidden: its count is null and hidden is true. Hidden groups are left out of the totals too, so they can't be worked out by subtraction. That's why the demographic total is usually a little lower than metrics.

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 once created, 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.

In short

  • Start with a Test key, free test funds and environment=TEST: it's free and members never see it.
  • Estimate the price; estimated_cost is the money.
  • Send an Idempotency-Key with every new Offer, and reuse it on retries.
  • Before Live, do a dry run and check balance_after, and set spending limits.
  • Read results by day and by age group and gender; small groups are hidden to protect members.

Next: use Agilis from an AI assistant, 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)