REST API
For developers. Everything else in this guide needs no code.
Cashback Tracker's admin screens are React, and they talk to the site over a REST namespace. That namespace is available to your own code too.
Namespace
/wp-json/cbtrkr/v1/Authentication
Every route requires the manage_options capability — administrator, in practice.
There is no public or member-facing part of this namespace. A member's own data reaches them through the account page, not through here.
From the admin screens, WordPress's cookie authentication and REST nonce apply, exactly as for core routes. From outside WordPress, use whatever your site already uses for authenticated REST — application passwords, for example.
These routes read and write money. Anything holding credentials for them holds the ability to change member balances — treat them as you would admin credentials, because that is what they are.
What is available
Grouped by what they are for. Each supports the usual page and per_page where a list is returned.
Shops
GET /advertisers the catalog
GET /advertisers/{module}/{advertiser} one shop
POST /advertisers/sync refresh shops
GET|POST|DELETE /advertisers/pages bulk page creation
GET|POST|DELETE /advertisers/logos bulk logo fetching
POST /advertisers/{module}/{advertiser}/page create one page
POST /advertisers/{module}/{advertiser}/logo fetch one logoMembers and money
Networks
Coupons
AI
Other
Orders, payouts, referrals and the overview have their own routes on the same namespace.
The postback endpoint is separate
Postbacks do not live here. They have their own endpoint, their own authentication, and they are off unless you switch them on.
See Postbacks.
Errors
Failures come back as normal WordPress REST errors — an HTTP status with a code and a message. The codes are stable enough to branch on; the messages are written for people and may be reworded between versions.
A refusal that is a rule rather than a fault uses a specific code — trying to reverse a payout, for instance, answers 409 with cbtrkr_reverse_payout rather than a generic failure.
A word of caution
This namespace exists to serve the admin screens. It is not a versioned public contract: routes may change between plugin versions, and shapes may gain fields.
For anything you intend to keep working, prefer the hooks — they are the stable extension surface. See Events and hooks.
Related
Last updated