Managing Execution Limits per User

Managing Execution Limits per User

This use case outlines how to manage the number of executions per user and automate stopping and restarting flows based on a specified execution limit. The flows are stopped once the limit is reached and restarted at the beginning of a new month. This guide explains the necessary API calls and steps to implement this behavior effectively.

Retrieve Execution Count

This API call retrieves the total number of executions associated with a specific user. It returns details that include the user ID, flows associated with the user, and the total execution count.

GET https://api.platform.openintegrationhub.com/icenter/executions

The following url parameters are supported:

Parameter

Description

start

The beginning of the time frame, in the format YYYY-MM-DD. Defaults to one month ago

end

The ending of the time frame, in the format YYYY-MM-DD. Defaults to today

groupby

Which field the counts should be grouped at. Currently supports user, flow, and component. Defaults to user

Response Properties

Properties

Description

id

the id is the internal FlowMate user ID

user

user is the internal FlowMate user ID

tenant

tenant is the ID of the FlowMate account

allFlows

List of all active flows per user

execution

The count of all actions for the defined time period

username

The identifier of the user that is transferred when integrating the Integration Center

Example GET Request

GET https://api.platform.openintegrationhub.com/icenter/executions?start=2024-11-16&end=2024-11-17&groupby=user

Response

{
        "_id": "636d0762bd257a7eb2373d6c",
        "user": "636d0762bd257a7eb2373d6c",
        "tenant": "636d0762bd257a7eb2373d6a",
        "allFlows": [
            "6732345d01bea099edcb9863",
            "6731feaf01bea099edcb977a",
            "67320a6e01bea099edcb97f2",
            "67125ff1a9cde94983184da4",
            "673230f301bea099edcb9844"
        ],
        "executions": 304,
        "username": "demo.oih@gmail.com"
    }

In this step, you will use the executions field to monitor the user's activity. If the number of executions reaches a predefined limit, you can proceed to the next steps, such as stopping flows or taking other actions. Remember that username is the user identifier from the customer's system, while user is an identifier given by FlowMate.

Stop User Flows

Once the execution limit for a user is reached, you can stop one or multiple flows to prevent further executions. The API provides options to stop individual flows or multiple flows simultaneously.

Option 1: Stop a single flow

Use this endpoint to stop a specific flow. Replace *FLOW_ID* with the unique ID of the flow obtained from the previous steps that you need to halt.

POST https://api.platform.openintegrationhub.com/flows/*FLOW_ID*/stop

Option 2: Stop a multiple flows

Use this endpoint to stop multiple flows in a single request. Provide an array of flow IDs obtained from the previous steps that you need to halt.

POST https://api.platform.openintegrationhub.com/flows/multiple/stop

Request Body Example

{
[
    "flow1",
    "flow2",
    "flow3"
]
}

Start Flows again, when fitting

  • start of new month (reset action limit)

  • new purchase of actions

  • new plan

There are different scenarios in which you will reactivate flows. Before managing flows, you must impersonate the user to gain the necessary permissions to modify their flows.

Impersonate the User

The impersonate call provides a token that authorizes you to manage the user's flows. This token must be included in subsequent API calls (such as starting flows) to authenticate your actions on behalf of the user. Use the username field to specify the external identifier of the user (the one passed by the customer).

POST https://api.platform.openintegrationhub.com/impersonate

Request Body Example

{
  "username": "abc123"
}

Response

{
  "token": "f9MPJQz6aRfQH4qVnkzUFbU3-4n-BAjiBXQKmED4_e15KK745Heq9KY2M7XknbGi-zO3XHF--OnbZUyqTHEO-qwXwzFX8K-isRZ2lclMzXDZiD_2DahQ1rfynbZHfn_VFi8VfHda5FiLfhcmxa20WL2TcPq82_lpgKN0nSTwCD4",
  "id": "62460554305401543e4e60c1"
}

Restarting User Flows

Once you have successfully impersonated the user and received a token, you can use that token to restart the flows. The API offers the option to start a single flow or multiple flows at once.

Option 1: Start a Single Flow

Use this endpoint to start a specific flow. Replace *FLOW_ID* with the unique ID of the flow you want to activate.

POST https://api.platform.openintegrationhub.com/flows/*FLOW_ID*/start

Authorization: Include the token from the impersonate call in the Authorization header.

Authorization Header example

"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Option 2: Start Multiple Flows at Once

Use this endpoint to start multiple flows in a single request. The request body should be an array containing the IDs of the flows you want to start.

POST https://api.platform.openintegrationhub.com/flows/multiple/start

Authorization: Use the same token from the impersonate call as a Bearer token in the Authorization header.

Authorization Header example

"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Request Body Example

{
[
    "flow1",
    "flow2",
    "flow3"
]
}

Last updated