Workflows ‐ Getting started - kangaroorewards/api-docs GitHub Wiki
Prerequisite: Register an App with Kangaroo Rewards
Before you can start making API calls, you need to register an app with Kangaroo Rewards. Here's how to do it:
- Go to the Developer Portal.
- Click on the “Register a new Application” button.
- Fill in the required fields such as Application name, Authorization callback URL, and Application description.
- Once the application is created, it will have a Client ID and Client Secret associated with it. Keep these safe as you'll need them for making > API calls.
- Contact Support and wait for the application to be approved.
Obtain an Access Token
The first step is to obtain an access token. You can do this by sending a POST request to the Kangaroo Rewards API. Here's an example using curl:
curl -v -X POST https://api.kangaroorewards.com/oauth/token \
-H "Accept: application/x-www-form-urlencoded" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "X-Application-Key: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." \
-d "grant_type=authorization_code \
&code=def502009ac5c81 \
&client_id=12345 \
&client_secret=8fysa8dfds9fj283 \
&redirect_uri=https://example.com/callback \
&scope=admin"
The response will be a JSON array containing your access token.
List All Main Actions
Once you have your access token, you can use it to list all main actions. To list all main actions make a get request to GET /workflow-main-actions
endpoint. Here's an example:
curl -X GET https://api.kangaroorewards.com/workflow-main-actions \
-H "Authorization: Bearer <access_token>" \
-H "X-Application-Key: <X-Application-Key>" \
-H "Accept: application/vnd.kangaroorewards.api.v1+json;" \
-H "Content-Type: application/json"
Replace <access_token> and with your actual access token and application key.
Example response:
{
"data": [
{
"id": 1,
"action_name": "Email"
},
{
"id": 2,
"action_name": "Send SMS"
},
{
"id": 3,
"action_name": "Reward Points"
},
{
"id": 4,
"action_name": "Wait"
}
]
}
List All Main Triggers
Once you have your access token, you can use it to list all main triggers. To list all main triggers, make a get request to GET /workflow-main-triggers
endpoint. Here's an example:
curl -X GET https://api.kangaroorewards.com/workflow-main-triggers\
-H "Authorization: Bearer <access_token>" \
-H "X-Application-Key: <X-Application-Key>" \
-H "Accept: application/vnd.kangaroorewards.api.v1+json;" \
-H "Content-Type: application/json"
Replace <access_token> and with your actual access token and application key.
Example response:
{
"data": [
{
"id": 1,
"trigger_name": "Created Account",
"conditions": [
{
"id": 1,
"type": "list",
"label": "Branch",
"url": "https://api.kangaroorewards.com/branches?include=virtual_branch",
"relations": null
},
{
"id": 2,
"type": "list",
"label": "Specific Day",
"url": null,
"relations": [
{
"label": "Monday",
"value": 1
},
{
"label": "Tuesday",
"value": 2
},
{
"label": "Wednesday",
"value": 3
},
{
"label": "Thursday",
"value": 4
},
{
"label": "Friday",
"value": 5
},
{
"label": "Saturday",
"value": 6
},
{
"label": "Sunday",
"value": 7
}
]
}
]
}
]
}
List All Workflows
You can also list all workflows using your access token by making a request to GET /workflows
endpoint. Here's an example:
curl -X GET https://api.kangaroorewards.com/workflows?include=triggers,actions \
-H "Authorization: Bearer <access_token>" \
-H "X-Application-Key: <X-Application-Key>" \
-H "Accept: application/vnd.kangaroorewards.api.v1+json;" \
-H "Content-Type: application/json"
Again, replace <access_token> and with your actual access token and application key.
Create a Workflow
You can create a new workflow by sending a POST request to the API, POST /workflows
endpoint. Here's an example:
curl -X POST https://api.kangaroorewards.com/workflows \
-H "Authorization: Bearer <access_token>" \
-H "X-Application-Key: <X-Application-Key>" \
-H "Accept: application/vnd.kangaroorewards.api.v1+json" \
-H "Content-Type: application/json" \
-d '{
"name": "Example Flow",
"published_at": "2024-01-01 08:00:00",
"expires_at": "2028-12-31 23:00:00",
"targeted_flag": 0,
"triggers": [
{
"main_trigger_id": 1,
"frequency":
{
"freq": "hourly",
"interval": 1
},
"conditions":
[
{
"id": 1,
"operator": "eq",
"value": "123"
}
]
}
],
"actions": [
{
"main_action_id": 1,
"name": "Example action",
"action_key": "abc123",
"enabled": true,
"temp_id": 2,
"temp_parent_id": 1,
"relations":
{
"entity_id": 1,
"entity_type": "Transaction",
"value": "123",
"label": "Transaction Type"
}
}
]
}'