API Access
Programmatic access for owners and affiliates — API keys, authentication, endpoints, and filters.
The Afglo API lets owners and affiliates interact with affiliate program data from backend services, scripts, dashboards, or AI agents. Owners get full read/write access. Affiliates get read-only access to their own data.
API Key Types
| Prefix | Role | Access |
|---|---|---|
sk_ | Owner | Full read/write — campaigns, affiliates, commissions, payouts, analytics |
ak_ | Affiliate | Read-only — own campaigns, commissions, referrals, payouts, links |
Generating Keys
Owner keys
- Sign in as the program owner.
- Open Owner dashboard → account menu → API keys.
- Enter a label and select Create key.
- Store the
sk_key securely. The full secret is shown once.
Affiliate keys
- Sign in as an affiliate.
- Call
POST /api/v1/affiliate/api-key(session-authenticated). - Store the
ak_key securely. The full secret is shown once.
Keys can be revoked from the API keys table or settings. Revoked keys stop authenticating immediately.
Authentication
Use HTTP Basic Auth with the API key as the username and an empty password.
# Owner
curl "https://afglo.com/api/v1/campaigns" \
-u "sk_your_api_key_here:"
# Affiliate
curl "https://afglo.com/api/v1/affiliate/campaigns" \
-u "ak_your_api_key_here:"Do not put API keys in browser code, mobile apps, public repositories, or client-side environment variables.
Rate Limiting
45 requests per 30-second window per key. Exceeding the limit returns HTTP 429.
Pagination
Collection endpoints support page and limit (max 100, default 25).
{
"data": [],
"pagination": {
"page": 1,
"limit": 25,
"total_count": 384,
"total_pages": 16
}
}Filters
Date filters
Use ISO 8601 timestamps on most collection endpoints:
curl "https://afglo.com/api/v1/referrals?created_after=2026-01-01T00:00:00Z&created_before=2026-04-21T23:59:59Z" \
-u "sk_your_api_key_here:"Field filters
Filter by related IDs, emails, or status on supported endpoints:
campaign_id— filter by campaignaffiliate_id— filter by affiliate-campaign relationshipemail/customer_email— filter by emailstate— affiliate state (active,pending,disabled)status— commission or payout status (due,pending,paid,voided)
Expand
Use expand to include related objects inline instead of just IDs:
curl "https://afglo.com/api/v1/commissions?expand=sale,affiliate,campaign" \
-u "sk_your_api_key_here:"Owner Endpoints (sk_ keys)
Campaigns
| Method | Path | Description |
|---|---|---|
GET | /api/v1/campaigns | List campaigns |
GET | /api/v1/campaigns/:id | Get single campaign |
POST | /api/v1/campaigns | Create campaign |
PUT | /api/v1/campaigns/:id | Update campaign |
Create campaign body:
{
"name": "Summer Sale Affiliates",
"description": "Affiliate program for summer promotion",
"landing_page_url": "https://example.com",
"reward_type": "percent",
"commission_percent": 15,
"cookie_window_days": 90,
"minimum_payout_cents": 2000,
"payout_delay_days": 30,
"reward_cadence": "first_year",
"max_commission_period_months": 12,
"auto_approve_affiliates": true
}reward_cadence: "first_year" applies a 12-month commission period and no max commission count.
Affiliates
| Method | Path | Description |
|---|---|---|
GET | /api/v1/affiliates | List affiliates |
GET | /api/v1/affiliates/:id | Get single affiliate |
POST | /api/v1/affiliates | Enroll affiliate in campaign |
PUT | /api/v1/affiliates/:id | Update affiliate |
Filters: campaign_id, email, state
Enroll affiliate body:
{
"campaign_id": "campaign_id_here",
"first_name": "Jane",
"last_name": "Doe",
"email": "jane@example.com",
"state": "active"
}Affiliate Links
| Method | Path | Description |
|---|---|---|
GET | /api/v1/affiliate_links | List links |
GET | /api/v1/affiliate_links/:id | Get single link |
POST | /api/v1/affiliate_links | Create link |
PUT | /api/v1/affiliate_links/:id | Update link |
Filters: affiliate_id, campaign_id
Referrals
| Method | Path | Description |
|---|---|---|
GET | /api/v1/referrals | List referral visits |
Filters: affiliate_id, campaign_id, conversion_state, email, created_after, created_before
Leads
| Method | Path | Description |
|---|---|---|
GET | /api/v1/leads | List leads |
Filters: affiliate_id, campaign_id, email, created_after, created_before
Conversions
| Method | Path | Description |
|---|---|---|
GET | /api/v1/conversions | List conversions |
Filters: affiliate_id, campaign_id, customer_email, created_after, created_before
Commissions
| Method | Path | Description |
|---|---|---|
GET | /api/v1/commissions | List commissions |
GET | /api/v1/commissions/:id | Get single commission |
PUT | /api/v1/commissions/:id | Update commission status |
Filters: affiliate_id, campaign_id, status, created_after, created_before
Update commission body:
{
"status": "paid"
}Payouts
| Method | Path | Description |
|---|---|---|
GET | /api/v1/payouts | List payouts |
GET | /api/v1/payouts/:id | Get single payout |
POST | /api/v1/payouts/:id/mark_as_paid | Mark payout as paid |
Filters: affiliate_id, campaign_id, status, created_after, created_before
Analytics
| Method | Path | Description |
|---|---|---|
GET | /api/v1/analytics | Dashboard analytics |
Parameters: range (30d, 90d, 12m, all), campaign_id
Returns totals, trends (% change vs prior period), daily/monthly time series, source breakdown, top affiliates, and campaign breakdown.
curl "https://afglo.com/api/v1/analytics?range=30d" \
-u "sk_your_api_key_here:"Affiliate Endpoints (ak_ keys)
Affiliate endpoints return only data belonging to the authenticated affiliate. All are read-only.
| Method | Path | Description |
|---|---|---|
GET | /api/v1/affiliate/settings | Your profile — name, email, payout email, timezone |
GET | /api/v1/affiliate/campaigns | Campaigns you belong to, with links and stats |
GET | /api/v1/affiliate/commissions | Your commission history |
GET | /api/v1/affiliate/referrals | Your referral visits |
GET | /api/v1/affiliate/payouts | Your payout history |
GET | /api/v1/affiliate/links | Your tracking links with per-link stats |
Filters on affiliate endpoints: campaign_id, status, created_after, created_before (where applicable).
Common Queries
List your campaigns (affiliate):
curl "https://afglo.com/api/v1/affiliate/campaigns" \
-u "ak_your_api_key_here:"List due commissions (owner):
curl "https://afglo.com/api/v1/commissions?status=due&limit=100" \
-u "sk_your_api_key_here:"Enroll a new affiliate (owner):
curl -X POST "https://afglo.com/api/v1/affiliates" \
-u "sk_your_api_key_here:" \
-H "Content-Type: application/json" \
-d '{"campaign_id":"cmo2...","first_name":"Jane","last_name":"Doe","email":"jane@example.com"}'Mark a payout as paid (owner):
curl -X POST "https://afglo.com/api/v1/payouts/payout_id/mark_as_paid" \
-u "sk_your_api_key_here:"Error Responses
All errors return a JSON object with an error field:
{
"error": "Campaign not found."
}| Status | Meaning |
|---|---|
| 400 | Bad request — validation error or invalid date format |
| 401 | Invalid or missing API key |
| 404 | Resource not found |
| 409 | Conflict — duplicate or already exists |
| 429 | Rate limit exceeded |
| 500 | Server error |