This article will walk you through our Partner API, which lets you set or get tasks limits per user.
You'll need your partner key to execute the below APIs as well your app-key, please get in touch with your Integry contact or if you're not enlisted as a partner, click here.
The functions that you perform around tasks, subscriptions, user, etc. are listed below.
1). Get current tasks of an individual user
The request returns the current tasks of a user.
GET https://app.integry.io/partners/api/insights/users/<id>/tasks/?app_key=APP_KEY_OF_ACCOUNT
Headers
api-key: <partner api key>
Response
{
"user_id":"test@example.com", // your user ID
"current_limit":10000,
"limit_period":"30", // in days
"tasks_consumed":5000,
"tasks_remaining":5000,
"limit_reset_after":10 // in days
}
2). Get current tasks for all users in an account
This request returns the tasks of all users in an account.
GET https://app.integry.io/partners/api/insights/users/tasks/?app_key=APP_KEY_OF_ACCOUNT
Headers
api-key: <partner api key>
Response
[
{
"user_id":"yasir@integry.io",
"current_limit":10000,
"limit_period":"30",
"tasks_consumed":5000,
"tasks_remaining":5000,
"tasks_consumed_percent":50,
"tasks_remaining_percent":50,
"limit_reset_after":10
}
]
3). Create a subscription for users tasks
The request creates a subscription for user tasks. You can subscribe to events for various levels for task consumption. We will notify you when that level is breached.
POST https://app.integry.io/partners/api/insights/subscriptions/
Headers
api-key: <partner api key>
Body:
{
"events":[
"user_tasks_limit_80",
"user_tasks_limit_100"
],
"callback_url":"https://example.com/callback"
}
Response
{
"subscription_id":"123-1234-1234-1234"
}
Example notification for task limit reached
Here is a sample payload of what we will send to your webhook URL when a user reaches a limit.
Headers:
subscription-id: <a valid subscription id> // it can be used to validate request
Payload:
{
"user_id":"yasir@integry.io",
"current_limit":10000,
"limit_period":"30",
"tasks_consumed":5000,
"tasks_remaining":5000,
"tasks_consumed_percent":50,
"tasks_remaining_percent":50,
"limit_reset_after":10
}
4). Delete a subscription
The request deletes a subscription.
DELETE https://app.integry.io/partners/api/insights/subscriptions/<subscription_id>/
Headers:
api-key: <partner api key>
Response:
{
"success":true
}
5). Set or Update task limit
The request sets the task limit for one or more users.
POST https://app.integry.io/partners/api/insights/users/tasks/?app_key=APP_KEY_OF_ACCOUNT
Headers
api-key: <partner api key>
Body:
[
{
"user_id":"yasir@integry.io",
"allowed_tasks":10000
},
{
"user_id":"test@integry.io",
"allowed_tasks":10000
}
]
Response
{
"success":"true"
}