Airfill Rewards API · v1
Send gift card rewards from your own stack.
Issue digital gift cards to customers, employees or partners the moment something happens in your product. Set up the reward once in the Airfill dashboard, then trigger it with one API call.
Base URL
https://api.airfill.com/v1
Quickstart
From zero to a delivered reward in four calls.
1. Create a template and an API key
In the Airfill dashboard, an organization admin creates a template (card currency, delivery method, product catalogue, expiry and branding) and an API key. Keys start with afr_ and are shown once.
2. Find the template ID
Call GET /templates and keep the id of the template you want to issue from.
3. Issue a campaign
Call POST /campaigns with the template, the number of cards, the value of each card and, for email delivery, the recipients. Send an Idempotency-Key derived from your own event so a retry never issues twice.
4. Wait for live, then deliver
Poll GET /campaigns/{id} until the status is live. Email campaigns are delivered by Airfill. For code campaigns, fetch the codes once with GET /campaigns/{id}/codes and hand them to your user.
Core concepts
Template
The fixed part of a reward, set up by your team in the dashboard: name, currency, delivery method, which gift cards recipients can pick, how long cards stay valid, and your branding. Editing a template only affects campaigns issued afterwards.
Campaign
One issue of a template: a number of cards of one value. Every issue request creates one campaign, and each card in it is redeemable for a gift card of the recipient's choice from the template's catalogue.
Delivery method
email: Airfill emails each recipient a card and a redemption link, one recipient per card. codes: you receive the codes and redemption links and deliver them in your own product.
Amounts and balance
Values are integers in minor units of the template's currency: 2500 is 25.00 USD. Each campaign is paid from your organization's prepaid Airfill balance when it launches.
Authentication
Send your API key as a bearer token on every request. A key belongs to the organization, not to the person who created it: it keeps working if they leave the team, until an admin revokes it or it reaches its expiry date.
Authorization: Bearer afr_your_api_key
Keep keys on your server. A key can spend your organization's balance. Never put it in a browser, a mobile app or a public repository. If one leaks, revoke it in the dashboard and create a new one.
Idempotency
Every POST /campaigns needs an Idempotency-Key header of up to 255 characters. Build it from the event you are rewarding, such as signup-48213 or order-10482-cashback, so it is the same every time you retry that event.
- Same key, same body: you get the first campaign back, whatever its status, with an
Idempotent-Replayed: trueheader. Nothing is charged twice, even when two requests arrive at the same time. - Same key, different body: refused with
409 idempotency_key_reused. - Request refused before launch (for example
insufficient_balance): nothing is kept, so you can fix the cause and retry with the same key.
Keys are scoped to your organization. Retry on network errors, timeouts and 5xx responses with the same key and exponential backoff.
Campaign lifecycle
An accepted request answers 202 with the campaign in launching. Cards are minted and paid in the background, usually within seconds. launching becomes live or launch_failed; a live campaign later becomes expired or cancelled.
| Status | Meaning | What to do |
|---|---|---|
launching | Accepted. Cards are being created and paid. | Poll every 2 to 5 seconds. |
live | Cards are active and email delivery has started; email_sent shows each recipient's status. | Fetch codes (code delivery) or show the result. |
launch_failed | Launch stopped. launch_error is insufficient_balance or internal_error. | Top up or contact support, then issue again with a new idempotency key. |
expired | The template's validity period ended. Unredeemed cards no longer work. | Nothing. |
cancelled | The campaign was cancelled. | Nothing. |
Webhooks Coming soon
Webhooks will notify your server when a campaign changes status, so you won't need to poll for it.
Until then, poll GET /campaigns/{id} every 2 to 5 seconds while the campaign is launching.
List templates
/templatesYour organization's active templates. Archived templates are not listed and cannot issue campaigns.
Query parameters
| Name | Description |
|---|---|
limit integer | Page size, 1 to 100. Default 100. |
start integer | Offset of the first result. Default 0. |
Template object
| Field | Description |
|---|---|
id string | Pass as template_id when issuing. |
name string | The name your team gave it. |
currency string | USD or EUR. Card values use this currency. |
distribution_mode string | email or codes. |
expires_after_days integer | null | Days a card stays valid after launch. null: never expires. |
curl "https://api.airfill.com/v1/templates?limit=20" \-H "Authorization: Bearer $AIRFILL_API_KEY"
{"meta": { "total": 2, "limit": 20, "start": 0 },"data": [{"id": "6741c9e2b8a4f01d2c3e5a77","name": "Referral reward","currency": "USD","distribution_mode": "email","expires_after_days": 365},{"id": "6741ca10b8a4f01d2c3e5a81","name": "In-app cashback","currency": "EUR","distribution_mode": "codes","expires_after_days": null}]}
Issue a campaign
/campaignsIssues cards from a template. The request is checked (template, recipients, catalogue, verification status, balance) before anything is charged; if a check fails you get a 4xx and nothing is created. Otherwise the answer is 202 Accepted and the launch runs in the background.
Headers
| Name | Description |
|---|---|
Idempotency-Key required | Up to 255 characters. See Idempotency. |
Content-Type required | application/json |
Body
| Field | Description |
|---|---|
template_id required string | An active template of your organization. |
count required integer | Number of cards, 1 to 5. |
value required integer | Value of each card in minor units of the template's currency, up to 50000 (500.00). |
recipients array | Email templates: required, exactly count entries with distinct emails. Code templates: leave out. |
recipients[].email string | Valid address, up to 254 characters. |
recipients[].name string | Shown in the email. Up to 100 characters, plain text. |
Returns the campaign object. A replayed request returns the same campaign with Idempotent-Replayed: true.
curl -X POST "https://api.airfill.com/v1/campaigns" \-H "Authorization: Bearer $AIRFILL_API_KEY" \-H "Content-Type: application/json" \-H "Idempotency-Key: referral-48213" \-d '{"template_id": "6741c9e2b8a4f01d2c3e5a77","count": 1,"value": 2500,"recipients": [{ "email": "ana@example.com", "name": "Ana Souza" }]}'
{"id": "6741d03f9b2e4a1c8d7f0b12","template_id": "6741c9e2b8a4f01d2c3e5a77","status": "launching","distribution_mode": "email","currency": "USD","count": 1,"value": 2500,"created_time": "2026-11-24T09:12:04.118Z","recipients": [{ "email": "ana@example.com", "name": "Ana Souza", "email_sent": false }]}
Retrieve a campaign
/campaigns/{id}The current state of a campaign issued through the API. Poll it after issuing until status leaves launching. It never contains card codes, so it is safe to poll and log. Campaigns created in the dashboard are not visible here.
Campaign object
| Field | Description |
|---|---|
id string | Campaign ID. |
template_id string | The template it was issued from. |
status string | launching, live, launch_failed, expired or cancelled. See lifecycle. |
launch_error string | Only with launch_failed: insufficient_balance or internal_error. |
distribution_mode string | email or codes. |
currency string | USD or EUR. |
count, value integer | As requested. value is in minor units. |
expiration_date string | ISO 8601. Set once live, when the template has an expiry. |
created_time string | ISO 8601. |
recipients array | Email campaigns: email, name, and email_sent once the card email went out. |
curl "https://api.airfill.com/v1/campaigns/6741d03f9b2e4a1c8d7f0b12" \-H "Authorization: Bearer $AIRFILL_API_KEY"
{"id": "6741d03f9b2e4a1c8d7f0b12","template_id": "6741c9e2b8a4f01d2c3e5a77","status": "live","distribution_mode": "email","currency": "USD","count": 1,"value": 2500,"expiration_date": "2027-11-24T09:12:09.402Z","created_time": "2026-11-24T09:12:04.118Z","recipients": [{ "email": "ana@example.com", "name": "Ana Souza", "email_sent": true }]}
Retrieve campaign codes
/campaigns/{id}/codesThe cards of a live campaign that uses code delivery. Each card has its code and a redemption link that opens the Airfill page with the code filled in. Call it once per campaign, store the result on your side, and deliver each card to its owner.
Codes are money. Treat them like card numbers: do not log them, do not send them to analytics, and show each one only to the person it is meant for. Every call to this endpoint is recorded on our side.
Responses
| Status | When |
|---|---|
200 | data: one entry per card with code, redemption_url, value (minor units) and currency. |
409 | campaign_not_live: still launching, failed, expired or cancelled. |
409 | codes_not_available: an email campaign. Airfill delivered the cards to the recipients. |
curl "https://api.airfill.com/v1/campaigns/6741d2a49b2e4a1c8d7f0b3c/codes" \-H "Authorization: Bearer $AIRFILL_API_KEY"
{"data": [{"code": "K7QM2XPD9WRT","redemption_url": "https://www.airfill.com/rewards/in-app-cashback-q4k3f9x2#code=K7QM2XPD9WRT","value": 1000,"currency": "EUR"}]}
Errors
Errors use standard HTTP status codes and always have the same body. Branch on error_code, which is stable; message is for people and may change.
{"message": "This Idempotency-Key was already used for a different request","error_code": "idempotency_key_reused"}
| HTTP | error_code | Meaning and fix |
|---|---|---|
| 400 | invalid_request | The body or a parameter is malformed, for example a value that is not a positive integer. |
| 400 | missing_idempotency_key | Add the Idempotency-Key header. |
| 400 | invalid_idempotency_key | The key is longer than 255 characters. |
| 400 | invalid_card_count | count must be an integer from 1 to 5. |
| 400 | card_value_too_large | value is above 50000 (500.00). |
| 400 | invalid_recipient | A recipient has an invalid email, an empty or too long name, or extra fields. |
| 400 | recipient_count_mismatch | An email template needs exactly one recipient per card. |
| 400 | duplicate_recipient_email | Each recipient of a campaign needs a different email. |
| 400 | recipients_not_allowed | Code templates take no recipients. Remove the field. |
| 400 | no_available_products | None of the template's gift cards can be sold right now. Review the template's catalogue in the dashboard. |
| 401 | unauthorized | No Authorization: Bearer header. |
| 401 | invalid_api_key | The key does not exist. |
| 401 | api_key_revoked, api_key_expired | Create a new key in the dashboard. |
| 403 | whitelabel_not_allowed | The template uses custom branding that your verification level no longer allows. |
| 404 | template_not_found | Unknown template ID, or it belongs to another organization. |
| 404 | not_found | Unknown campaign, or a campaign created in the dashboard. |
| 409 | insufficient_balance | Your balance does not cover the campaign. Top up, then retry with the same key. |
| 409 | idempotency_key_reused | The key was used for a different request. Use a new key for a new event. |
| 409 | template_archived | The template was archived. Pick an active one. |
| 409 | campaign_not_live, codes_not_available | See Retrieve campaign codes. |
| 409 | organization_disabled | Your organization is suspended. Contact support. |
| 429 | rate_limit_reached | Slow down. See Rate limits. |
| 500 | internal_error | Our side failed. Retry with the same idempotency key. |
| 503 | balance_unavailable | Your balance could not be checked right now. Retry with the same key. |
Rate limits
Limits use one-minute windows. Over a limit, you get 429 with error_code: "rate_limit_reached"; wait and retry with backoff.
| Scope | Limit | Applies to |
|---|---|---|
| Per API key | 120 requests / minute | All endpoints, from any number of servers. |
| Per API key | 30 requests / minute | GET /campaigns/{id}/codes |
| Per IP address | 300 requests / minute | All requests, before authentication. |
Limits
| What | Limit |
|---|---|
| Cards per request | 1 to 5 |
| Value per card | up to 500.00 (50000) |
| Currencies | USD, EUR (set by the template) |
| Idempotency key | up to 255 characters |
| Recipient email / name | 254 / 100 characters |
| Templates page size | up to 100 |
If your use case needs larger batches or higher values, talk to your account manager.