Monetization by monday offers two different types of app pricing models: feature-based and seat-based. When using feature-based pricing, it's vital to track the number of operations an app completes so they don't exceed their allotted usage.
The app_subscription_operations object and its associated queries and mutations allow you to do just that by counting usage per operation type (kind) and per account. For annual and monthly subscriptions, the counter resets monthly based on the renewal date. For example, if a subscription renews annually on the 15th of the month, the counter will reset on the 15th of each month.
Using the increase_app_subscription_operations mutation, you can increase the operation counter based on an account's usage and then query app_subscription_operations to read the updated values. These queries and mutations will only work with access tokens generated for the app, and the account must have an active app subscription. Developer access tokens will not work.
Queries
You can use the app_subscription_operations query to retrieve app operation data via the API.
- Returns an object containing an operation count for feature-based apps
- Can only be queried directly at the root; can't be nested within another query
query {
app_subscription_operations(kind: "image_scan") {
counter_value
period_key
}
}import { ApiClient } from "@mondaydotcomorg/api";
const mondayApiClient = new ApiClient({ token: myToken });
const query = "query ($operationKind: String!) { app_subscription_operations (kind: $operationKind) { counter_value period_key }}"
const variables = {
operationKind: "image_scan",
};
const response = await mondayApiClient.request(query, variables);Arguments
You can use the following argument to reduce the number of app subscription operations returned.
| Argument | Description |
|---|---|
kind String | The operation's name. |
Fields
You can use the following fields to specify what information your app subscription operations query will return. Some fields support their own subfields.
Field | Description | Supported Subfields |
|---|---|---|
app_subscription | The account's app subscription details. | billing_period |
counter_value | The new counter value. The counter will restart each time a new app subscription period begins. | |
kind | The operation's name. | |
period_key | The unique window key (related to subscription periods). |
Mutations
The API allows you to increase and app subscription operations using the following mutation.
Increase app subscription operations
The increase_app_subscription_operations mutation increases the counter for a specific operation via the API. You can specify which fields to return in the mutation response. It will return an error if no active subscription exists for the supplied token.
mutation {
increase_app_subscription_operations(
kind: "image_scan"
increment_by: 2
){
counter_value
}
}import { ApiClient } from "@mondaydotcomorg/api";
const mondayApiClient = new ApiClient({ token: myToken });
const query = "mutation ($operationKind: String!, $value: Int!) { increase_app_subscription_operations (kind: $operationKind, increment_by: $value) { counter_value }}"
const variables = {
operationKind: "image_scan",
value: 2
};
const response = await mondayApiClient.request(query, variables);Arguments
You can use the following arguments to specify which operation to increase and by how much. If you omit these arguments, it will default to a global kind and increment by 1.
| Argument | Description |
|---|---|
increment_by Int | The amount to increase the counter by. Must be a positive number. |
kind String | This can be an alphanumeric string of up to 14 characters, including the - and _ symbols. |
