π Campaigns
Reward your users with out-of-the-box business logic
Campaign API Overview
Co:Create's Campaign API aims to simplify the creation and management of reward campaigns by offering built-in business logic, resulting in improved user insights on how your web3 program is driving business value.
Campaigns form an integral part of user engagement and retention strategies. They offer a way to reward users for taking specific actions, thus encouraging desired behaviors and fostering a sense of loyalty. However, designing and managing these campaigns can be a complex and time-consuming process. This is where the Co:Create Platform's Campaign API come into play.
Streamlined Development Process
The Campaign API is designed to simplify the creation and management of reward campaigns. By offering built-in business logic, the API eliminates the need for you to build additional application logic yourself, saving significant time and resources. They are built on the foundation of Co:Create Platform's existing user and token management capabilities.
Imagine, for instance, a scenario where you're tasked with creating a system to reward users with tokens for following your brand on Twitter. Traditionally, this would involve setting up a Twitter developer account, implementing the OAuth connection flow within your application, integrating the Twitter API to check the user is following your account, and then distributing the token rewards by minting tokens to the user wallet. With the Campaign API, this process is streamlined - developers can easily set up the campaign, and the APIs will handle the tracking, validation, and reward distribution.
Enhanced User Insights
The value of the Campaign API extends beyond just simplifying the development process. The API is designed to provide valuable insights about end users to Co:Create Platform's developers. By leveraging the Campaign API, businesses can gain a better understanding of their users' behaviors and preferences. This, in turn, can inform strategic business decisions and help optimize future campaigns.
For instance, using the Campaign API, a business could discover that users are more likely to invite friends to join the platform when a certain type of reward is offered. This insight could help the business refine its reward strategy to further boost user referrals.
How It Works
Campaigns are created by you, with rewards claimed by your users (when eligible).
Campaign Structure
Campaigns are structured around two main fundamental objects: Conditions & Actions.
Object | Description | Example |
---|---|---|
Condition | A rule that the user must meet to be eligible for claiming the campaign | Hold a Main Character, Zaddy, or ZINE NFT |
Action | The task that will be triggered once the user claims the campaign | Mint 200 DIMES to user's Co:Create Wallet |
When creating a campaign, you will decide the type of condition you would like to have the user meet. You will also decide on the action which you want to take place as a user claims the campaign.
Campaign Conditions
Currently, the following conditions are available:
Condition | Description |
---|---|
sign_up | Reward a user for signing up for your program. |
profile_update | Reward a user for providing their name, address, or phone number. Choose one, two, or three criteria to be required. |
token_gated | Reward a user for holding tokens of a specified token contract -- ERC20, ERC721, or ERC1155. Supports Ethereum, Polygon, and Gnosis Chain. |
twitter_social_link | Reward a user for connecting their Twitter account to their Co:Create profile. (Requires use of Co:Create SDK.) |
discord_social_link | Reward a user for connecting their Discord account to their Co:Create profile. (Requires use of Co:Create SDK.) |
instagram_social_link | Reward a user for connecting their Instagram account to their Co:Create profile. (Requires use of Co:Create SDK.) |
Campaign Actions
Currently, the following actions are available:
Action | Description |
---|---|
mint | Mint Co:Create-issued tokens to a specified user's wallet. ERC20 & ERC721 tokens are supported today. |
Using the Campaign API
At a simplified level, the Campaign API workflow is the following:
- Create a campaign - Select your condition & action, providing specified parameters.
- Verify user eligibility - Provide the campaign ID & the user's email to get information about whether the user has met the conditions required to claim from the campaign.
- Claim campaign - Provide the campaign ID & the user's email to trigger the campaign action.
Endpoints
The base URL for the Campaign API is alpha/campaign
.
Endpoint | Type | Description |
---|---|---|
Create a campaign | POST | Create a campaign. |
List campaigns | GET | List all campaigns that have been created. |
Get campaign | GET | Retrieve a campaign by campaign ID, to fetch detailed information about a specific campaign. |
Update campaign | PATCH | Update an existing campaign to make modifications to a campaign after it has been created. |
Delete campaign | DELETE | Remove a campaign that is no longer needed. Deleting removes the campaign's data from the system. To terminate a campaign without removing its data, cancel the campaign instead of deleting it. |
Verify user eligibility for campaign | GET | Check if a specific user is eligible to claim a campaign to determine if a user meets the requirements for a particular campaign. |
Claim a campaign | POST | Claim a campaign and reward the user to reward users who have completed the necessary steps to claim a campaign. |
Pause campaign | POST | Temporarily suspend all activities for the specified campaign ID. |
Resume campaign | POST | Resume a paused campaign. Paused campaigns can be resumed later; canceled campaigns cannot be resumed. |
Cancel campaign | POST | Permanently terminate a campaign. Canceled campaigns cannot be resumed. The campaign's data remains available (compare the Delete endpoint above). |
For more information about the /pause
, /resume
, and /cancel
endpoints, see Campaign State Management.
Campaign Creation
To create a Campaign, make a POST request to https://api.testcocrt.xyz/alpha/campaign
with the body parameters listed below.
Request Body Parameters
The main body of the request has the following parameters.
Parameters | Format | Description |
---|---|---|
title* | string | The title of the campaign. |
subtitle* | string | The subtitle for the campaign. Primarily for use by your application to display further information about the campaign. |
description* | string | The description for the campaign. Primarily for use by your application to display further information about the campaign. |
media_url | string | An optional URL for a media file. Use it if you would like your application to display a piece of media with the campaign. |
condition* | object | An object representing the condition that must be met for a user to be eligible for the campaign. |
action* | object | An object representing the action that will be taken once a user claims the campaign. |
(*) denotes required.
Furthermore, conditions and actions objects are structured as follows:
Condition
Parameter | Format | Description |
---|---|---|
type* | enum | The type of condition the campaign will require. Current options are: - 'sign_up' - 'token_gated' - 'twitter_social_link' - 'discord_social_link' - 'instagram_social_link' |
name | string | An optional name for the condition. You can use this if you would like to display further information to your user about your condition, for instance, within a requirements component in your application. |
description | string | An optional description for the condition. You can use this if you would like to display further information to your user about your condition, for instance, within a requirements component in your application. |
Action
Parameter | Format | Description |
---|---|---|
type* | enum | The type of action to take. Current options are: - 'mint' |
token_type* | enum | The token type that will be minted. Current options are: - 'erc20' - 'erc721' |
id* | uuid | The UUID of the token provided when creating a new token. Can also be found with a List ERC20 or List ERC721 request. |
payout_amount* | number | The amount of tokens of the specified token id that will be minted to a user that claims the campaign. |
Example Request
curl --request POST \
--url https://api.testcocrt.xyz/alpha/campaign \
--header 'Authorization: Bearer <YOUR_KEY_HERE>' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"condition": {
"type": "sign_up",
"name": "Sign up for my test",
"description": "Description for signing up for my test"
},
"action": {
"type": "mint",
"token_type": "erc20",
"id": "782f9579-6674-4b42-b4bf-49ef0079d64e",
"payout_amount": 123
},
"title": "Campaign Test 1",
"subtitle": "Testing my first campaign",
"description": "Description for testing my first campaign"
}
'
Creation Response
A successful request will return a 200 OK response with a JSON object containing the campaignId
of the newly created campaign.
Example 200 Response
{
"data": {
"id": "a158c590-f7eb-4bf7-9442-3c8a80f60855",
"title": "Campaign Test 1",
"subtitle": "Testing my first campaign",
"description": "Description for testing my first campaign",
"media_url": "",
"action": {
"type": "mint",
"token_type": "erc20",
"id": "782f9579-6674-4b42-b4bf-49ef0079d64e",
"payout_amount": 123
},
"condition": {
"type": "sign_up",
"name": "Sign up for my test",
"description": "Description for signing up for my test"
}
}
}
Verify Campaign Eligibility
All campaigns must be claimed for the action to take place. Before claiming, you may want to check the user's campaign eligibility -- for instance, if you would like to display this status within your application.
To verify a user's eligibility for claiming a campaign, make a GET request to https://api.testcocrt.xyz/alpha/campaign/{campaign_id}/verify
. Include the campaign_id
as a path param and the user email for whom you are checking as a query param.
Example Request
curl --request GET \
--url 'https://api.testcocrt.xyz/alpha/campaign/a158c590-f7eb-4bf7-9442-3c8a80f60855/verify?email=foo%40bar.com' \
--header 'Authorization: Bearer <YOUR_KEY_HERE>' \
--header 'accept: application/json'
Verify Response
A successful request will return a 200 OK response with a JSON object containing the following:
Name | Format | Description |
---|---|---|
campaign_status | enum | Describes the status of the campaign. Options are: - paused - active - inactive - complete |
condition | object | Object containing condition data. Includes meets_condition and type . |
meets_condition | boolean | Indicates whether the user has met the condition. |
type | enum | Describes the type of condition that the campaign was configured as. Contained within the condition object. Options are: - sign_up - token_gated - twitter_social_link - discord_social_link - instagram_social_link |
can_claim | boolean | Indicates whether the user can claim the campaign. |
has_claimed | boolean | Indicates whether the user has already claimed the campaign. |
Example 200 Response
{
"data": {
"campaign_status": "active",
"can_claim": true,
"condition": {
"meets_condition": true,
"type": "sign_up"
},
"has_claimed": false
}
}
Campaign Claiming
For a user to be rewarded for completing the campaign, they must claim the campaign.
To claim the campaign, make a POST request to https://api.testcocrt.xyz/alpha/campaign/{campaign_id}/claim
with the campaign_id
as a path param and the following in the body:
Parameter | Format | Description |
---|---|---|
string | The email for the user that is claiming the campaign | |
wallet_address | string | The wallet address the campaign's reward will be minted to |
Example Request
curl --request POST \
--url https://api.testcocrt.xyz/alpha/campaign/a158c590-f7eb-4bf7-9442-3c8a80f60855/claim \
--header 'Authorization: Bearer <YOUR_KEY_HERE>' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"email": "[email protected]",
"wallet_address": "0xa9989a7d4fba7b84fa798ee98b4df7c148516dcf"
}
'
Claim Response
A successful request will return a 200 OK response with a JSON object containing information about the reward.
Example Response
{
"data": {
"erc20_id": "782f9579-6674-4b42-b4bf-49ef0079d64e",
"contract_address": "0xbf0bccc77bc2bbaa4894ee6dffdc6db787b89403",
"num_tokens": [
123
],
"wallet_addresses": [
"0xa9989a7d4fba7b84fa798ee98b4df7c148516dcf"
]
}
}
Get Help
If you get stuck at any time, reach out to us on Discord or contact us via email at [email protected].
Updated 7 days ago