Campagin API
This is the main API to interact with a Campaign. Campaigns are required to start creating referral links as one Campaign can host multiple referral links.
Create a Campaign
Required attributes
- Name
url
- Type
- string
- Description
This is the base URL for the referral links we generate. If you enter the URL as example.com, the referral links will be generated as example.com/?rapi_id=123.
- Name
name
- Type
- string
- Description
The name of this Campaign. This is only for internal purposes
Response
The response is a Campaign object as shown in the response to the right.
Campaign
curl --request POST \
--url https://api.referralapi.com/api/v1/campaign \
--header 'Content-Type: application/json' \
--header 'api-key: 1968aa57ccd72d208dbac95d6679e6389ecfd60e59f31163506474a9c766fb6d' \
--data '{
"url": "example.com",
"name": "My Campaign"
}'
Campaign Response Example
{
"id": "3a6a4dd0-1055-4c3c-a531-7036793e10ee",
"created_at": "2023-09-11_03-33-06",
"url": "https://example.com",
"name": "My Campaign",
"webhook_url": None,
}
Get a Campaign
Required attributes
- Name
id
- Type
- string
- Description
The ID of the Campaign as returned by the ReferralAPI API originally
Response
The response is a Campaign object, as shown in the response.
Request
curl --request GET \
--url https://api.referralapi.com/api/v1/campaign?id=3a6a4dd0-1055-4c3c-a531-7036793e10ee\
--header 'Content-Type: application/json' \
--header 'api-key: 1968aa57ccd72d208dbac95d6679e6389ecfd60e59f31163506474a9c766fb6d'
Campaign Response Example
{
"id": "3a6a4dd0-1055-4c3c-a531-7036793e10ee",
"created_at": "2023-09-11_03-33-06",
"url": "https://example.com",
"name": "My Campaign",
"webhook_url": None,
}
Update a Campaign
Note that we do not allow to change the url of a campaign. In this case, we recommend that you create a new campaign.
Required Query String Attributes
- Name
id
- Type
- string
- Description
The ID of the Campaign as returned by the ReferralAPI API originally
Optional Payload
- Name
name
- Type
- string
- Description
Change the internal name of the campaign
- Name
webhook_url
- Type
- string
- Description
Update an optional webhook url you want to hit when someone interacts with a referral link (visit, signup, etc.)
Response
The response is a Campaign object, as shown in the response.
Request
curl --request PATCH \
--url https://api.referralapi.com/api/v1/campaign?id=3a6a4dd0-1055-4c3c-a531-7036793e10ee\
--header 'Content-Type: application/json' \
--header 'api-key: 1968aa57ccd72d208dbac95d6679e6389ecfd60e59f31163506474a9c766fb6d' \
--data '{
"name": "Edited Campaign Name",
"webhook_url": "https://mywebhookurl.com/"
}'
Campaign Response Example
{
"id": "3a6a4dd0-1055-4c3c-a531-7036793e10ee",
"created_at": "2023-09-11_03-33-06",
"url": "https://example.com",
"name": "Edited Campaign Name",
"webhook_url": "https://mywebhookurl.com/"
}
Delete a Campaign
If you delete a campaign, we delete all referral links that are part of that campaign. This action cannot be undone.
Required Attributes
- Name
id
- Type
- string
- Description
The ID of the Campaign as returned by the ReferralAPI API originally
Response
The response is an empty 204
response, which means that your campaign and its referral links have been deleted.
Request
curl --request DELETE \
--url https://api.referralapi.com/api/v1/campaign?id=3a6a4dd0-1055-4c3c-a531-7036793e10ee\
--header 'Content-Type: application/json' \
--header 'api-key: 1968aa57ccd72d208dbac95d6679e6389ecfd60e59f31163506474a9c766fb6d'