Richdale Affiliate
R
Richdale API Developers

API Reference

Welcome to the Richdale Affiliate API. You can use this API to programmatically read your platform's affiliate data, retrieve commissions, and securely handle real-time webhook events inside your own backend or via IPaaS tools like Zapier and Make.

Authentication

The Richdale API uses API keys to authenticate requests. You can view and manage your API keys in the Business Settings dashboard.

Authentication to the API is performed via HTTP Bearer Auth. Provide your API key as the bearer token in the Authorization header.

BASH
curl https://api.richdale.app/api/v1/business/{businessId}/affiliates \
  -H "Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxxxxx"
Warning: Your API keys carry many privileges. Keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, or public repositories.

Base URL

All API requests must be made over HTTPS. Calls made over plain HTTP will fail.

PLAINTEXT
https://api.richdale.app/api/v1/business/{businessId}

Webhooks & Security

Richdale can send webhook events that notify your application any time an event happens (e.g., when a commission is approved). To verify that a webhook was actually sent by Richdale and not a malicious third party, you must verify the HMAC signature included in the headers.

Verifying Signatures

The x-richdale-signature header contains a timestamp and a signature. Extract these values, compute an HMAC with the SHA256 hash function using your webhook's secret, and compare it.

JAVASCRIPT
const crypto = require('crypto');

// The headers and raw body from the incoming POST request
const signatureHeader = req.headers['x-richdale-signature'];
const rawBody = req.body; // Ensure this is the RAW JSON string, not parsed
const secret = 'whsec_live_...';

// Parse the header (format: t=1612345678,v1=abcdef123...)
const [tPart, v1Part] = signatureHeader.split(',');
const timestamp = tPart.split('=')[1];
const signature = v1Part.split('=')[1];

// Construct the signed payload string
const signedPayload = `${timestamp}.${rawBody}`;

// Compute expected signature
const expectedSignature = crypto
  .createHmac('sha256', secret)
  .update(signedPayload)
  .digest('hex');

if (signature === expectedSignature) {
  console.log("Valid Webhook!");
} else {
  console.error("Invalid Signature");
}

List Commissions

Returns a list of commissions generated for your business programs.

GET/api/v1/business/{businessId}/commissions
{ "data": [ { "id": "cm_8a7b6c...", "status": "approved", "saleAmountCents": 15000, "commissionAmountCents": 2250, "currency": "USD", "createdAt": "2024-03-12T10:30:00Z", "affiliateProgram": { "affiliateId": "af_123...", "programId": "pr_456..." } } ], "meta": { "total": 1, "page": 1, "totalPages": 1 } }