Skip to content

AffiliateWP Automations

How to Create an AffiliateWP Referral When a Webhook Is Received

Not every sale happens in your WordPress store. To create an AffiliateWP referral when a webhook is received, use Zapify's free A webhook is received trigger with the Create a referral action. The affiliate gets credit for sales from a CRM, a payment platform or a script. AffiliateWP is a Zapify PRO integration.

What this automation does

The automation is one trigger plus one action:

  • Trigger: A webhook is received (WEBHOOK_RECEIVED, Webhooks)
  • Action: Create a referral (AFFWP_CREATE_REFERRAL, AffiliateWP)

When the outside service sends a webhook, Zapify creates a referral for the affiliate named in it, with the amount and the order reference.

PRO feature

AffiliateWP is a Zapify PRO integration, so this automation needs an active Zapify PRO licence.

No Connection needed for AffiliateWP

AffiliateWP runs on your own site, so there is no API key to paste for it and nothing to set up under Settings → Connections.

Before you start

  • AffiliateWP installed and active.
  • An outside tool that can send a webhook, and its documentation for what the webhook contains.

How to build the automation

Step 1: Create a new automation

  1. In the WordPress admin, go to Zapify → Automations.
  2. Click Add New to open the builder.
  3. Name it clearly, such as Record outside sales as referrals.

Create a new automation

Step 2: Add the "A webhook is received" trigger

  1. Click Add Trigger.

Add a trigger

  1. Choose Webhooks as the app.

Select Webhooks as the trigger

  1. Select A webhook is received.

Select A webhook is received

  1. Copy the endpoint URL the builder shows and paste it into the sending service's webhook settings. Treat the URL as a credential, because anyone who has it can send data to this automation.
  2. Click Listen, then send one test delivery from the service. Zapify captures it and builds the token list from the real fields, so you pick them rather than guess.

See Webhooks for signatures, sources and event types.

Step 3: Add the "Create a referral" action

  1. Click Add Action.

Add an action

  1. Choose AffiliateWP as the app.

Select AffiliateWP as the action

  1. Select Create a referral.

Select Create a referral

Step 4: Configure the action

Field Required What it does
Affiliate No An affiliate ID, or the email of an affiliate's user. Leave empty to use the affiliate account of the user this automation is running for.
Amount Yes The commission, as a number that is not negative.
Type Yes Sale, Opt-in, Lead or any type your site offers.
Status Yes Pending (the default), Unpaid, Paid or Rejected.
Description No A short note shown on the referral in AffiliateWP.
Reference No Usually the order or record the referral is for.
Context No Where it came from, such as woocommerce. Leave empty to file it under zapify.

Insert tokens from your captured sample:

  • Affiliate: the payload token that holds the affiliate's ID or email
  • Amount: the payload token that holds the commission
  • Type: Sale
  • Status: Unpaid if the sale is already confirmed, or leave on Pending
  • Reference: the payload token that holds the order number
  • Context: a short label such as crm

Step 5: Set the steps Live and save

Each trigger and action has its own Live / Off / Draft switch. A new automation starts as a Draft and does nothing until its steps are Live.

  1. Set the trigger and every action to Live.
  2. Click Save.

Set the automation live

Step 6: Test it

Send a test delivery from the outside service. Then open AffiliateWP → Referrals. Zapify → Logs shows Referral … was created for affiliate ….

Tokens you can use

Token What it holds
Received at / Raw body / Event type / External ID Always available.
One token per payload field Appear once you have captured a sample with Listen.

The action makes two tokens available to later actions: Referral ID and Affiliate ID.

Conclusion

With the A webhook is received trigger and the Create a referral action, any sale can earn commission. To send data out as well, see sending a webhook when a referral is created.

FAQs

Is this free in Zapify?

The trigger is free, but the AffiliateWP action is part of the AffiliateWP PRO integration and needs an active Zapify PRO licence.

What if the affiliate cannot be found?

The run fails and says no affiliate was found for that value. Use an affiliate ID or the email of the affiliate's user.

Is the webhook safe to leave open?

The URL carries a long random key and you can also require a signature. See Webhooks.

What happens if the amount is not a number?

The run fails and says the amount is invalid, and no referral is created.

Do I need to write any code?

No. Everything is configured visually in the Zapify builder.

Was this page helpful?