API Documentation

Developer Reference

Hooks & Filters

Behaviour filters

FilterDefaultPurpose
wcusage_api_rate_limit120 / 30Requests per minute. Receives the default and the bucket identity (key_*, user_*, ip_*).
wcusage_api_max_auth_failures20Invalid-key attempts allowed per address per 15 minutes. Zero or less disables the check.
wcusage_api_require_httpstrue outside local/devWhether bearer keys require HTTPS.
wcusage_api_max_order_rows5000How many referred orders one /coupons/{id}/orders request may consider.
wcusage_api_report_batch_size200How many coupons /reports/summary primes meta for at a time. Lower it on very large programs with tight memory.
wcusage_api_openapi_publicverdaderoWhether /openapi is publicly readable.
wcusage_api_webhook_require_httpstrue outside local/devWhether webhook URLs must be HTTPS.
wcusage_api_webhook_max_attempts5Delivery attempts per event.
wcusage_api_webhook_max_failures25Consecutive failures before an endpoint is auto-disabled.
wcusage_api_webhook_eventsExtend or modify the webhook event catalog.
wcusage_api_auth_failure_buckets, wcusage_api_ip_buckets256How many buckets failed attempts and anonymous callers are spread across.

Enabling the API, and enabling individual endpoints, is done from Coupon Affiliates → Admin Tools → API rather than by a filter. Those settings live in the wcusage_api_settings option.

Response filters

FilterApplies to
wcusage_api_coupon_summaryEvery coupon object the API returns.
wcusage_api_prepare_affiliateAffiliate objects. Receives the detailed flag.
wcusage_api_prepare_payoutPayout objects.
wcusage_api_prepare_registrationRegistration objects.
wcusage_api_order_itemReferred-order rows — the place to add extra fields for a trusted integration.
wcusage_api_report_summaryEn /reports/summary payload.
wcusage_api_openapi_specThe generated OpenAPI document.
wcusage_api_webhook_payloadWebhook payloads, just before delivery.
// Add the affiliate's country to every coupon the API returns.
add_filter( 'wcusage_api_coupon_summary', function ( $data, $coupon_id ) {
    $user_id = (int) $data['user_id'];
    $data['country'] = $user_id ? get_user_meta( $user_id, 'billing_country', true ) : '';
    return $data;
}, 10, 2 );
Warning
These filters run for cada caller of the affected endpoint, not only for your own integration. Several of them cover endpoints an affiliate or a multi-level upline can reach, so anything you add there is disclosed to them too. Check who can call the endpoint before adding customer data, payout details or another affiliate's information — the omissions in the default responses are deliberate.

Actions

AcciónFires
wcusage_activity_recordedFor every lifecycle event, with ( $event, $event_id, $info, $actor_id ). This is the same funnel the webhook dispatcher listens to, and it fires whether or not database logging is enabled — hook it to build a custom integration with no polling and no HTTP.
add_action( 'wcusage_activity_recorded', function ( $event, $event_id, $info, $actor_id ) {
    if ( 'payout_request' === $event ) {
        // $event_id is the payout ID.
    }
}, 10, 4 );