API Documentation

Intégrations

AI Agents & Assistants

The API was designed with agents in mind: stable numeric IDs, plain JSON, self-describing errors, a machine-readable spec and a single "who am I" call.

Setting one up

  1. Create a WordPress user for the agent, at the access level it genuinely needs — an affiliate account for an affiliate-facing assistant, an admin account only for a program-management assistant.
  2. Create an API key against that user with the read scope only, and an expiry date.
  3. Give the tool the OpenAPI URL: https://example.com/wp-json/wcusage/v2/openapi. Custom GPT Actions, most agent frameworks and any OpenAPI-aware tool builder import it directly, generating one callable function per endpoint.
  4. Configure bearer authentication with the key.

For frameworks without OpenAPI import, hand-define a handful of tools instead — /me, /reports/summary, /affiliates/{id}/stats, /coupons/{id}/orders et /events cover the overwhelming majority of questions.

Prompting notes

  • Tell the agent to call /me first. It learns whether it is an admin or a single affiliate, and which scopes it holds, instead of guessing and hitting 403s.
  • Tell it to reference coupons by ID, not code.
  • Tell it that 404 can mean "not yours", so it should not conclude an ID is unused.
  • Tell it to respect retry_after on 429 rather than retrying immediately — otherwise a loop burns the whole rate limit.
  • Point it at /reports/summary for "how are we doing" questions. Left to itself an agent will happily page through every affiliate to compute a total the API already has.

Safety

An agent acts on the text it reads, and some of that text comes from outside your control — an applicant's "how will you promote us" answer, a campaign name, a website URL an affiliate typed in. An agent with write access can be steered by content like that into doing something you never asked for. Read-only access removes the problem entirely; anything more needs a person in the loop on the actions that matter.

Warning
Never give an agent the manage scope. A key holding it can mint further keys with any scope and point a webhook at any server — that is full account access, in the hands of something driven by text it reads from the outside world.

If an agent must act, grant write deliberately and remember what it can then do: approve or decline applications, create payout requests, and change payout statuses. Payout status changes never contact a gateway, but on a store with automatic payouts a created payout request can pay real money immediately. If that is a concern, switch the /payouts endpoints off on the API screen and let the agent read everything else.

Tip
An affiliate-facing assistant is the safest deployment by construction: give it a read-only key on the affiliate's own account, and the API itself guarantees it can never see anybody else's data, however it is prompted.