POST
/api/v1/affiliatesRegister a new affiliate in your program. If the email belongs to an existing Anderro user, they are added to your program without creating a new account. Optionally sends a welcome email notification.
Request body
| Parameter | Type | Description |
|---|---|---|
emailrequired | string | Email address of the affiliate. Must be a valid email. |
name | string | Full name of the affiliate (1-200 characters). |
notify | boolean | Send a welcome email to the affiliate. Defaults to true. |
referralCode | string | Custom referral code (3-50 chars, alphanumeric with hyphens/underscores). Auto-generated if omitted. |
Example request
bash
curl -X POST https://anderro.com/api/v1/affiliates \
-H "Content-Type: application/json" \
-H "x-api-key: sk_your_secret_key" \
-d '{
"email": "[email protected]",
"name": "Jane Smith",
"notify": true,
"referralCode": "jane-smith"
}'
Responses
201Affiliate registered successfully
json
{
"affiliate": {
"id": "cuid_abc123",
"email": "[email protected]",
"name": "Jane Smith",
"isNew": true
},
"partnership": {
"id": "cuid_xyz789",
"status": "active",
"referralCode": "jane-smith"
}
}
The isNew field indicates whether a new user account was created (true) or an existing user was added to your program (false).
200Previously removed affiliate reactivated
json
{
"affiliate": {
"id": "cuid_abc123",
"email": "[email protected]",
"name": "Jane Smith",
"isNew": false
},
"partnership": {
"id": "cuid_xyz789",
"status": "active",
"referralCode": "jane-smith"
}
}
409Affiliate is already in your program
json
{
"error": "Affiliate is already in this program"
}
400Validation error
json
{
"error": "Validation failed",
"details": {
"fieldErrors": {
"email": ["Invalid email address"]
},
"formErrors": []
}
}