Skip to main content

Campaigns API

Manage campaigns programmatically. Requires authentication via JWT token or API key (X-API-Key).

List Campaigns

Brand campaigns are accessed via the brand-scoped endpoint. For affiliates or cross-user views, use the compatibility endpoint.

Brand Campaigns (Brand-scoped)

curl https://api.affilync.com/api/brand/campaigns \
-H "Authorization: Bearer YOUR_TOKEN"

Query Parameters:

ParameterTypeDefaultDescription
statusstringNoneFilter by status: draft, active, paused, completed, archived
campaign_typestringNoneFilter by type: sale, lead, click, call, whatsapp, etc.
searchstringNoneSearch by campaign name or description
pageint1Page number
per_pageint20Results per page (max 100)
limitintNoneAlternative to per_page for explicit limit (up to 1000)
sort_bystringcreated_atSort field: created_at, name, commission_rate, start_date, status
orderstringdescSort order: asc or desc

Response (200):

{
"success": true,
"data": {
"campaigns": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Spring Sale 2026",
"description": "Promote our new spring collection",
"status": "active",
"campaign_type": "sale",
"commission_rate": 25.00,
"budget": 5000.00,
"spent": 1234.56,
"start_date": "2026-03-01T12:00:00Z",
"end_date": "2026-04-30T23:59:59Z",
"created_at": "2026-03-01T12:00:00Z",
"metrics": {
"clicks": 4521,
"conversions": 143,
"revenue": 3567.89,
"affiliates": 12,
"roi": 187.45,
"conversion_rate": 3.16
}
}
],
"pagination": {
"total": 42,
"page": 1,
"per_page": 20,
"pages": 3
}
},
"message": "Campaigns retrieved successfully"
}

General Campaigns (User-scoped)

curl https://api.affilync.com/api/campaigns \
-H "Authorization: Bearer YOUR_TOKEN"

Automatically returns:

  • For brands: Campaigns they have created
  • For affiliates: Active campaigns they can join

Query Parameters:

ParameterTypeDefaultDescription
statusstringNoneFilter: active, paused, completed
pageint1Page number
per_pageint20Results per page (max 100)
sort_bystringcreated_atSort field: name, performance, created_at
orderstringdescSort order: asc or desc

Get a Campaign

curl https://api.affilync.com/api/brand/campaigns/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer YOUR_TOKEN"

Response (200):

{
"success": true,
"data": {
"campaign": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Spring Sale 2026",
"description": "Promote our new spring collection",
"status": "active",
"campaign_type": "sale",
"commission_rate": 25.00,
"commission_type": "percentage",
"budget": 5000.00,
"spent": 1234.56,
"start_date": "2026-03-01T12:00:00Z",
"end_date": "2026-04-30T23:59:59Z",
"created_at": "2026-03-01T12:00:00Z",
"updated_at": "2026-03-15T09:30:00Z"
}
},
"message": "Campaign retrieved successfully"
}

Create a Campaign

curl -X POST https://api.affilync.com/api/brand/campaigns \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Summer Launch",
"description": "Promote our new summer collection",
"campaign_type": "sale",
"commission_rate": 30.00,
"commission_type": "percentage",
"budget": 10000.00,
"start_date": "2026-06-01T00:00:00Z",
"end_date": "2026-08-31T23:59:59Z",
"launch_mode": "now",
"auto_approve_affiliates": false
}'

Request Fields:

FieldTypeRequiredDescription
namestringYesCampaign name (1-200 chars)
descriptionstringNoCampaign description
campaign_typestringYesCampaign type: sale, lead, click, call, whatsapp, impression, subscription, app_install, custom, self_tracking
commission_ratefloatYesCommission percentage (0-100) or fixed amount
commission_typestringNopercentage (default) or fixed
budgetfloatYesTotal campaign budget
start_datestringNoCampaign start date (ISO 8601)
end_datestringNoCampaign end date (ISO 8601)
launch_modestringNonow to activate immediately; otherwise creates as draft
auto_approve_affiliatesbooleanNoAuto-approve affiliate applications (default: false)
alert_configobjectNoPerformance alert configuration
use_templatestringNoTemplate ID to use as base
requirementsarrayNoCampaign requirements for affiliates

Call Campaign Fields (when campaign_type is call):

FieldTypeDefaultDescription
call_payout_typestringper_callper_call or per_minute
call_payout_amountfloatRequiredPayout amount per call or minute
call_min_durationint90Minimum call duration in seconds
call_max_durationint3600Maximum call duration in seconds
call_recording_enabledbooleantrueEnable call recording
call_whisper_enabledbooleanfalseEnable whisper message before call connects
call_whisper_messagestringNoneWhisper message to play
call_destination_numberstringNoneDestination phone number for forwarding
call_numbers_to_provisionint10Number of tracking numbers to provision (1-100)

Response (201):

{
"success": true,
"data": {
"campaign": {
"id": "550e8400-e29b-41d4-a716-446655440001",
"name": "Summer Launch",
"status": "active",
"campaign_type": "sale",
"commission_rate": 30.00,
"commission_type": "percentage",
"budget": 10000.00,
"created_at": "2026-06-01T14:00:00Z"
}
},
"message": "Campaign created successfully"
}

Update a Campaign

curl -X PUT https://api.affilync.com/api/brand/campaigns/550e8400-e29b-41d4-a716-446655440001 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"status": "active",
"commission_rate": 35.00,
"budget": 12000.00,
"name": "Summer Launch 2026"
}'

Request Fields (all optional):

FieldTypeDescription
namestringCampaign name (1-200 chars)
descriptionstringCampaign description
commission_ratefloatCommission percentage (0-100) or fixed amount
budgetfloatTotal campaign budget
end_datestringCampaign end date (ISO 8601)
statusstringCampaign status: draft, active, paused, completed, archived
requirementsarrayCampaign requirements for affiliates

Response (200):

{
"success": true,
"data": {
"campaign": {
"id": "550e8400-e29b-41d4-a716-446655440001",
"name": "Summer Launch 2026",
"status": "active",
"commission_rate": 35.00,
"budget": 12000.00,
"updated_at": "2026-06-15T10:30:00Z"
}
},
"message": "Campaign updated successfully"
}

Delete a Campaign

curl -X DELETE https://api.affilync.com/api/brand/campaigns/550e8400-e29b-41d4-a716-446655440001 \
-H "Authorization: Bearer YOUR_TOKEN"

Response (200 - Soft Delete):

{
"success": true,
"data": {
"campaign": {
"id": "550e8400-e29b-41d4-a716-446655440001",
"status": "archived"
}
},
"message": "Campaign deleted successfully"
}

Note: Campaigns are soft-deleted (status set to archived, marked as deleted) rather than permanently removed from the database. This preserves historical analytics and commission data. Child records (clicks, conversions, commissions) are preserved.

Campaign Object Fields

FieldTypeDescription
idstring (UUID)Unique campaign identifier
namestringCampaign display name
descriptionstringCampaign description
campaign_typestringCampaign type (see list above)
statusstringdraft, active, paused, completed, archived
commission_ratefloatCommission value (percentage or fixed amount)
commission_typestringpercentage or fixed
budgetfloatTotal campaign budget
spentfloatAmount spent to date
start_datestringCampaign start date (ISO 8601 timestamp)
end_datestringCampaign end date (ISO 8601 timestamp)
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp

Metrics Object (returned in list view):

FieldTypeDescription
clicksintegerTotal clicks from all affiliates
conversionsintegerTotal conversions
revenuefloatTotal revenue (sale amount)
affiliatesintegerNumber of active affiliate promoters
roifloatReturn on investment percentage
conversion_ratefloatConversion rate percentage

Tier Requirements

Campaign CRUD operations require at least the Starter tier or higher.

  • Free: No campaigns
  • Starter+: Full campaign management

Next Steps