API Documentation

Endpoints

Affiliés

An affiliate is a WordPress user with at least one published coupon assigned to them. There is no separate affiliate table; these endpoints derive the entity the same way the admin list table does, and aggregate across all of an affiliate's coupons.

List affiliates

GET /wp-json/wcusage/v2/affiliates

Permission: admin, read scope.

ParamTypeDescription
recherchestringPartial match against user login, email or display name.
page / per_pageintegerStandard pagination.
[
  {
    "user": { "id": 1456, "display_name": "Sarah J", "login": "sarahj", "email": "[email protected]" },
    "coupons": [
      { "id": 8338, "code": "sarah10", "user_id": 1456, "date_created": "2023-05-02T10:11:12",
        "unpaid_commission": 40.46, "pending_order_commission": 0, "pending_payout_commission": 0 }
    ],
    "unpaid_commission": 40.46,
    "pending_payout_commission": 0
  }
]

Results are ordered by user ID ascending. Only users holding at least one published assigned coupon appear.

Get one affiliate

GET /wp-json/wcusage/v2/affiliates/{user_id}

Permission: admin, or the affiliate themselves. read scope.

Returns the list shape plus detail fields, and each coupon carries its cached all-time stats block:

Extra fieldTypeDescription
date_registeredstringWhen the WordPress account was created.
profileobjectRegistration profile fields: phone, website, promote, referrer.
groupsarrayAffiliate group roles the user holds.
mla_parentsobjectPRO only. Multi-level upline chain, keyed by tier. Absent entirely in the free build.

Affiliate stats

GET /wp-json/wcusage/v2/affiliates/{user_id}/stats

Permission: admin, or the affiliate themselves. read scope.

ParamTypeDescription
fromdateOptional start date (Y-m-d). When set, figures are recalculated from the orders for the range instead of read from the all-time cache.
àdateOptional end date. Defaults to today when from is set.
{
  "user_id": 1456,
  "from": null,
  "to": null,
  "totals": {
    "orders_count": 19,
    "total_sales": 1977.80,
    "total_discount": 197.78,
    "total_commission": 181.60,
    "unpaid_commission": 40.46,
    "pending_payout_commission": 0
  },
  "coupons": [
    { "id": 8338, "code": "sarah10", "orders_count": 19, "total_sales": 1977.80,
      "total_discount": 197.78, "total_commission": 181.60 }
  ]
}

The two balance figures in totals are always current balances; they are not affected by from/à.

Note
A ranged request recalculates every one of the affiliate's coupons from the order history, so one call costs as much as their whole trading history. Results are cached for 60 seconds per range, and an uncached range is limited to one per affiliate per minute — over that, the response is 429 wcusage_api_throttled.