Skip to content

Affiliate stats


id: affiliatewp-affiliates-stats owner: affiliatewp method: GET path: /wp-json/headlesswp/v1/affiliates/stats title: Affiliate stats usedBySite: true

GET /wp-json/headlesswp/v1/affiliates/stats

Returns aggregate affiliate statistics for the current user.

Auth + CSRF

  • Auth: cookie session required.
  • Proxy nonce required: yes.

Request schema

  • Query params:
    • range (optional): 7d | 30d | 90d | all (default 30d).

Response schema

{
  "data": {
    "range": "string",
    "startAtUtc": "string",
    "endAtUtc": "string",
    "clicks": "number",
    "referrals": "number",
    "conversions": "number",
    "earningsMinor": "number",
    "earningsPaidMinor": "number",
    "earningsUnpaidMinor": "number",
    "currency": "string"
  }
}

Field semantics:

  • referrals: total referrals in range across all referral statuses.
  • conversions: referrals in range where status is unpaid or paid.

Error codes

StatusCodeNotes
401NOT_AUTHENTICATEDLogin required.
403AFFILIATE_NOT_ACTIVEAffiliate exists but is not active.
403AFFILIATE_TERMS_REQUIREDTerms acceptance required before stats access.
404AFFILIATE_NOT_FOUNDNo affiliate account for current user (or feature disabled upstream).
422VALIDATION_FAILEDInvalid range or forbidden scope override parameters.
500CONFIG_INVALID_AFFILIATE_TERMS_VERSIONTerms config invalid while gating active.
500UPSTREAM_UNAVAILABLEDynamic passthrough fallback code from AffiliateStatsService failures.