API reference
The monday apps framework has three interfaces to manage your app’s monetization:
- monday SDK: Handles subscriptions in a frontend app
- GraphQL API: Allows your backend to access subscription information and create mock subscriptions for testing
- Webhooks: Sends subscription information to your backend and custom actions
SDK methods
Frontend apps can use the following methods through the monday SDK.
Open plan selection
This execute method opens the plan selection page or billing tab so users can upgrade or pay for your app. It only works for live apps currently in the marketplace and cannot be tested.
Users can update their subscription when the tab opens by subscribing, upgrading, downgrading, or canceling. For example, users may want to use a feature not available on their plan. You can show them the billing tab so they can upgrade to the next plan tier.
If the isInPlanSelection
parameter is true
, the plan selection page will open. You should use this when you want the user to pay for the app first.
If the isInPlanSelection
parameter is false
, the app's billing section will open instead.
Code sample
monday.execute('openPlanSelection', {isInPlanSelection: true});
Session token
Every time your app loads, we will generate a session token signed with your app’s client secret. You can get this token with the method monday.get(‘sessionToken’)
. Your frontend should use this as the primary access to the current subscription.
Code sample
monday.get('sessionToken')
.then((token) => {
// send token to backend
// On backend, call jwt.verify(token.data, 'MY_CLIENT_SECRET')
}
Token structure
{
"exp": "2023-12-01T00:00:00Z",
"dat": {
"account_id": 1234567890,
"user_id": 9876543210
}
}
App Context
Your app’s context contains helpful information to manage your app’s state, such as the board it’s connected to or the current user. Check out the SDK to see all of the context objects that you can return!
In the context payload, we will include the subscription information for the current account – but only if the account is paying for your app (not on trial). You can access the context using the monday.get
and monday.listen
methods.
The context is convenient, but you should always verify the subscription details using the session token since it is signed.
Sample context object
{
"boardViewId": 19324,
"boardId": 3423243,
"mode": "fullScreen",
"theme": "light",
"subscription" : {
"plan_id" : "basic_tier_5",
"is_trial" : false,
"renewal_date" : "2021-08-27T00:00:00+00:00"
}
}
GraphQL Methods
App subscription
The app_subscription
query returns the subscription object for the current app and account based on the token used. This method does not accept any arguments and returns an array.
If an account has a mock subscription and a real one, it will only return the mock subscription.
Fields
The following fields will determine the data returned from your app_subscription
query.
Field | Description |
---|---|
plan_id String | The subscription’s plan tier (e.g., basic). |
is_trial Boolean | True if the account is still in the trial period. |
renewal_date Date | When the subscription renews. |
billing_period String | The billing period frequency (monthly or yearly). |
days_left Int | The number of days left until the subscription ends. |
Sample query
query {
app_subscription {
plan_id
is_trial
billing_period
days_left
}
}
Apps monetization status
The apps_monetization
status` query checks if an account supports monetization.
Fields
The following fields will determine the data returned from your apps_monetization_status
query.
Field | Description |
---|---|
is_supported Boolean | True if the account supports app monetization. |
Sample query
query {
apps_monetization_status {
is_supported
}
}
Set mock app subscription
The set_mock_app_subscription
mutation will create a mock subscription for an account and app based on the token you're using. It returns an app_subscription object
. Mock subscriptions disappear after 24 hours, and each account-app pair can create one mock subscription.
Please note that you may need to refresh your browser after creating a mock subscription so that it shows in your account.
The mutation takes an app_id
argument, which you can get from the URL of your app. Follow these steps o find your app_id
:
- Open the Developers section.
- Click on your app.
- The URL of the page will follow this format: myaccount.monday.com/apps/manage/{YOUR_APP_ID}/app_versions/12345/sections/appDetails
Arguments
Argument | Description |
---|---|
app_id Int! | The app’s unique identifier. |
partial_signing_secret String! | The last 10 characters of your app’s signing_secret. |
is_trial Boolean | Defaults to false. |
renewal_date String | The date the subscription renews. Defaults to one year in the future and follows UTC DateTime. If you use this argument, the mutation will fail if it is not a future date. |
plan_id Int | The developer's internal ID for the plan. |
billing_period String | The billing period frequency (monthly or yearly). |
pricing_version Int | The subscription's pricing version. |
Sample query
mutation {
set_mock_app_subscription (
app_id:12345,
partial_signing_secret: "abcde12345",
is_trial: true,
plan_id: "basic_plan_15_users"
) {
plan_id
}
}
Remove mock app subscription
The remove_mock_app_subscription
query removes the mock subscription for the current account. It will return an app_subscription
object or an error if no mock subscription exists.
Arguments
Argument | Description |
---|---|
app_id Int! | The app's unique identifier. |
partial_signing_secret String! | The last 10 digits of your signing secret. |
Webhooks
You can use the endpoint found in the webhooks section of your app's configuration screen to receive a notification when someone installs or uninstalls your app or creates, changes, renews, or cancels a subscription. Read more about the available webhooks here!
Updated 3 months ago