Note: This article relates to the REST API Extended pro add-on.

The REST API Extended add-on makes it possible to for you or other apps to interact with Arabianaffiliates programmatically.

Setup
Once installed and activated:

Go to Affiliates → Settings → REST API
Select the checkboxes for the types of endpoints you’d like to enable.
Click Save Changes
Your site now has a complete CRUD REST API for interacting with your affiliate data.

If you have not yet used the read-only REST API provided by the core Arabianaffiliates plugin, or you are unsure of how to authenticate with the REST API, please review the overview documentation for the base API.

Note: This article relates to the REST API Extended pro add-on.

The REST API Extended add-on opens a whole new world of flexibility when it comes to leveraging the services you rely on to run your affiliate program on the web.

Prior to Arabianaffiliates 1.9, integrating third-party services typically took one of two common paths:

Via inclusion as a core-supported integration, configurable via Affiliates → Integrations
Via inclusion of custom code or installing official or third-party add-ons
The key downside of both of those paths was that the code (in most cases) needed to live directly adjacent to Arabianaffiliates to be able to interact with it. That meant installing any number of add-ons on each site to get the desired functionality.

With the launch of a REST API in Arabianaffiliates, this requirement largely disappears. In fact, REST endpoints inherently encourage the idea of extending Arabianaffiliates from outside of the WordPress sphere.

A great example of this in action is the Zapier add-on, which currently makes it possible for events like adding new affiliates or referrals, generating payouts and more to trigger events on third-party services. Soon, the Zapier add-on will allow for two-way interaction too, such as triggering events in Arabianaffiliates when a third-party service does something. Exciting!

The possibilities enabled with this extended API are nearly endless. A few examples of possible applications include:

Visit and referral tracking from external websites, including non-WordPress sites
Referral tracking in custom and non-WordPress eCommerce systems
Synchronization of affiliate accounts across multiple databases and servers
Automatically updating affiliate accounts when changes are made from external applications
Creating referral records for affiliates each time an order is processed in an external payment processor
Custom affiliate areas hosted outside of WordPress

Note: This article relates to the REST API Extended pro add-on.

REST API Extended adds three endpoints, one each for creating, editing, and deleting affiliates on top of the two read-only endpoints already available in Arabianaffiliates core.

All five endpoints leverage the same two route patterns:

affiliates – When sent a GET request, a list of affiliates are returned and can be filtered with additional arguments. When sent a POST or PUT request, a new affiliate can be created.
affiliates/[ID] – When sent a GET, PATCH, or DELETE request, a single affiliate can be retrieved, edited, or deleted, respectively.
Both routes can also accept generic OPTIONS requests, which can be very helpful for discovering information about available endpoints, accepted request types and arguments, and item schema.

Whether you’re planning to read, write, edit, or delete affiliates, this add-on makes it possible.

All requests must be authenticated using API keys, which are generated and managed via the Affiliates → Tools → API Keys tab. Check out the REST API – Authentication article for more information.

Creating an Affiliate

The create endpoint accepts any of the following affwp_add_affiliate() arguments:

user_id – (integer) Every affiliate shares a 1:1 relationship with an existing WordPress user account. If no suitable user ID is available, the create_user argument can be passed to try creating an affiliate and a user account in the same step.
username – (string) Optional. Used to set the user_login when creating a new user account. If not provided, the payment_email will be used to generate the user_login of the generated WordPress user.
create_user – (boolean) Used to create a new user account, in lieu of user_id. Must be accompanied by a unique payment_email value, which is used when registering the user account.
rate – (integer) Affiliate rate to use. If not specified, the global default will be used.
rate_type – (string) Rate type. Default accepted types are’percentage’ or ‘flat’. If not specified, the global default will be used.
payment_email – (string) Affiliate payment email. If omitted, the user account email will be used on retrieval. Required when using create_user.
status – (string) Affiliate status. Accepts ‘active’, ‘inactive’, ‘pending’, or ‘rejected’. Default is ‘pending’.
notes – (string) Affiliate notes.

Note: This article relates to the REST API Extended pro add-on.

REST API Extended adds three endpoints, one each for creating, editing, and deleting creatives on top of the two read-only endpoints already available in Arabianaffiliates core.

All five endpoints leverage the same two route patterns:

creatives – When sent a GET request, a list of creatives are returned and can be filtered with additional arguments. When sent a POST or PUT request, a new creative can be created.
creatives/[id] – When sent a GET, PATCH, or DELETE request, a single creative can be retrieved, edited, or deleted, respectively.
Both routes can also accept generic OPTIONS requests, which can be very helpful for discovering information about available endpoints, accepted request types and arguments, and item schema.

Whether you’re planning to read, write, edit, or delete creatives, this add-on makes it possible.

All requests must be authenticated using API keys, which are generated and managed via the Affiliates → Tools → API Keys tab. Check out the REST API – Authentication article for more information.

Note: This article relates to the REST API Extended pro add-on.

REST API Extended adds three endpoints, one each for creating, editing, and deleting payouts on top of the two read-only endpoints already available in Arabianaffiliates core.

All five endpoints leverage the same two route patterns:

payouts – When sent a GET request, a list of payouts are returned and can be filtered with additional arguments. When sent a POST or PUT request, a new payout can be created.
payouts/[id] – When sent a GET, PATCH, or DELETE request, a single payout can be retrieved, edited, or deleted, respectively.
Both routes can also accept generic OPTIONS requests, which can be very helpful for discovering information about available endpoints, accepted request types and arguments, and item schema.

All requests must be authenticated using API keys, which are generated and managed via the

Note: This article relates to the REST API Extended pro add-on.

REST API Extended adds three endpoints, one each for creating, editing, and deleting referrals on top of the two read-only endpoints already available in Arabianaffiliates core.

All five endpoints leverage the same two route patterns:

referrals – When sent a GET request, a list of referrals are returned and can be filtered with additional arguments. When sent a POST or PUT request, a new referral can be created.
referrals/[id] – When sent a GET, PATCH, or DELETE request, a single referral can be retrieved, edited, or deleted, respectively.
Both routes can also accept generic OPTIONS requests, which can be very helpful for discovering information about available endpoints, accepted request types and arguments, and item schema.

All requests must be authenticated using API keys, which are generated and managed via the Affiliates → Tools → API Keys tab. Check out the REST API – Authentication article for more information.

Note: This article relates to the REST API Extended pro add-on.

REST API Extended adds three endpoints, one each for creating, editing, and deleting visits on top of the two read-only endpoints already available in Arabianaffiliates core.

All five endpoints leverage the same two route patterns:

visits – When sent a GET request, a list of visits are returned and can be filtered with additional arguments. When sent a POST or PUT request, a new referral can be created.
visits/[id] – When sent a GET, PATCH, or DELETE request, a single visit can be retrieved, edited, or deleted, respectively.
Both routes can also accept generic OPTIONS requests, which can be very helpful for discovering information about available endpoints, accepted request types and arguments, and item schema.

All requests must be authenticated using API keys, which are generated and managed via the Affiliates → Tools → API Keys tab. Check out the REST API – Authentication article for more information.

Note: This article relates to the REST API Extended pro add-on.

Overview
The Arabianaffiliates REST API provides a powerful set of tools for interacting with the plugin and its data from afar.

One of the most common use cases (and the basis of some of our most popular requested features) have to do with being able to interact with Arabianaffiliates running on one WordPress-powered site via another WordPress-powered site.

The following examples cover how to send requests from one WordPress site to another WordPress site running Arabianaffiliates. We’ll cover how to build requests and analyze responses, as well as give a primer on what kind of experience to expect when interacting with the Arabianaffiliates REST API endpoints.

What you need to know
The following examples assume you have a baseline of knowledge about how WordPress handles sending remote requests and retrieving responses.

If you’re unfamiliar with the HTTP API or REST API, we recommend checking out the HTTP API article in the official plugin developer handbook as well as the REST API handbook.

Information Discovery
As outlined in the Managing Affiliates[ 1], Creatives[2], Payouts[3], Referrals[4], and Visits[5] articles, the REST API Extended add-on brings full CRUD (Create, Read, Update, and Delete) capabilities when interacting with Arabianaffiliates from afar.

For the most part, remote responses are structured consistently across object types. That said, depending on endpoint used, certain fields specific to the given object types will be required in various circumstances.

The easiest way to determine which fields are required or which parameters are accepted is to send an OPTIONS request to the endpoint; the response from the OPTIONS request should tell you everything you need to know.

For instance, the following is a section of the response of an OPTIONS request sent to the /v1/creatives/ endpoint with REST API Extended activated: