Skip to content

Affiliate apply


id: affiliatewp-affiliates-apply owner: affiliatewp method: POST path: /wp-json/headlesswp/v1/affiliates/apply title: Affiliate apply usedBySite: true

POST /wp-json/headlesswp/v1/affiliates/apply

Allows a logged-in user to submit an affiliate application.

Auth + CSRF

  • Auth: cookie session required.
  • Proxy nonce required: yes.

Request schema

{
  "firstName": "string (required)",
  "lastName": "string (required)",
  "email": "string (required, valid email)",
  "website": "string (required, non-empty, valid URL; https:// is prefixed when scheme is missing)",
  "promotionMethod": "string (required, non-empty)",
  "partnerMarketingOptIn": "boolean (optional; missing/null treated as false)"
}

Unknown fields are rejected with 422 VALIDATION_FAILED. Contract notes:

  • website is mirrored to the WordPress user profile user_url so AffiliateWP admin displays the value on the user edit screen.
  • promotionMethod is persisted to AffiliateWP meta under promotional_methods (with promotion_method fallback for compatibility) for staff review.
  • Marketing consent persistence is deterministic for both customer and partner campaigns:
    • user meta headlesswp_marketing_opt_in / headlesswp_marketing_opt_in_at always remain explicit ('yes'|'no'; timestamp only when 'yes').
    • user meta headlesswp_partner_marketing_opt_in / headlesswp_partner_marketing_opt_in_at are written from partnerMarketingOptIn ('yes'|'no'; timestamp only when 'yes').
    • affiliate meta keys include both consent families: marketing_opt_in* and partner_marketing_opt_in*.
    • notes are updated idempotently to contain one line for each consent: Marketing opt-in: yes|no and Partner marketing opt-in: yes|no.
    • WordPress user bio (description) is overwritten with a deterministic consent block that includes both customer and partner consent status/timestamps.

Response schema

{
  "data": {
    "affiliate": {
      "id": "number",
      "userId": "number",
      "email": "string",
      "firstName": "string",
      "lastName": "string",
      "website": "string",
      "promotionMethod": "string",
      "status": "string (defaults to pending when blank)"
    }
  }
}

Error codes

StatusCodeNotes
401NOT_AUTHENTICATEDLogin required.
403AFFILIATE_TERMS_REQUIREDTerms acceptance required before application submission.
409AFFILIATE_EXISTSExisting affiliate account; includes details.affiliateId.
422VALIDATION_FAILEDField validation or unknown fields failed.
400APPLICATION_FAILEDAffiliateWP rejected/failed application creation.
500CONFIG_INVALID_AFFILIATE_TERMS_VERSIONTerms config invalid while gating active.
503DEPENDENCY_UNAVAILABLEAffiliateWP dependency missing/unavailable.