Affihub
DocsAPI ReferenceEvents

Events

Overview

Events are an audit log of everything that happens in your program — clicks, commissions, partner changes, webhooks, and payouts. Use the events API to build custom reporting or debug integration issues.

All endpoints require API key authentication.

List events

GET /api/v1/events

Query parameters

Param Type Default Description
page number 1 Page number
per_page number 20 Results per page (max 100)
type string Filter by event type
from string Start date (ISO 8601)
to string End date (ISO 8601)

Example

curl "https://api.affihub.com/api/v1/events?type=click&per_page=50" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "data": [
    {
      "id": "evt_abc123",
      "program_id": "prog_xxx",
      "type": "click",
      "payload": {
        "ref": "john",
        "landing": "/pricing",
        "referrer": "https://twitter.com/john"
      },
      "created_at": "2026-04-10T15:30:00Z"
    },
    {
      "id": "evt_def456",
      "program_id": "prog_xxx",
      "type": "commission.created",
      "payload": {
        "commission_id": "com_abc123",
        "partner_id": "par_abc123",
        "amount_cents": 1980
      },
      "created_at": "2026-04-10T15:35:00Z"
    }
  ],
  "total": 2,
  "page": 1,
  "per_page": 20
}

Event types

Type Description
click Referral link click recorded
commission.created New commission created
commission.updated Commission status changed
partner.created New partner added
partner.updated Partner details changed
partner.deleted Partner deactivated
payout.generated Payout records created
payout.paid Payout executed
webhook.stripe Stripe webhook received
webhook.paddle Paddle webhook received

Event payload

The payload field contains a JSON object with event-specific data. The structure varies by event type:

Click event

{
  "ref": "partner-slug",
  "landing": "/pricing",
  "referrer": "https://twitter.com/partner"
}

Commission event

{
  "commission_id": "com_abc123",
  "partner_id": "par_abc123",
  "amount_cents": 1980,
  "txn_amount_cents": 9900,
  "provider": "stripe"
}

Partner event

{
  "partner_id": "par_abc123",
  "email": "partner@example.com",
  "slug": "partner-slug"
}

Payout event

{
  "payout_id": "pay_abc123",
  "partner_id": "par_abc123",
  "amount_cents": 18500
}

Use cases

  • Debugging: Trace a referral from click → commission → payout by querying events for a specific partner
  • Analytics: Count clicks by day to track partner performance over time
  • Audit trail: Review all changes for compliance or dispute resolution
  • Custom reporting: Build reports that combine events with your own application data

Date range queries

Filter events by date using ISO 8601 format:

curl "https://api.affihub.com/api/v1/events?from=2026-04-01&to=2026-04-10&type=commission.created" \
  -H "Authorization: Bearer YOUR_API_KEY"