Genesys Cloud CX

 View Only
Discussion Thread View
  • 1.  Help bulk extracting the current presence of a large group of users via API

    Posted 02-02-2023 10:49
    Edited by David Perry 02-02-2023 10:49
    Hello everyone,

    We are trying to export the current presence details of each of our users via the API. I've included a snippet of our python code below. Executing this code works, but due to what I assume is API limitations the results fed back to us are throttled. It will do a few loops and then pause, it can take several minutes to get through all of the users.

    Is there another method or API call we can use to bulk request these details, or some way to get around the throttled result feed?

    We need each user's current presence as a starting point for a monitoring dashboard we are creating. We utilize the notifications system via webhooks to monitor for any presence changes throughout the day, but without knowing their initial presence when the webhook connects, our starting dataset will be inaccurate. We also need to be able to pull their current presence in case the notifications channel drops connection and we miss changes that occurred while disconnected.

    Any suggestions are welcomed!

    Python code snippet:
    from import ApiException
    import PureCloudPlatformClientV2
    client_id = *****
    client_secret = *****

    # Authenticate

            region = PureCloudPlatformClientV2.PureCloudRegionHosts.ca_central_1
   = region.get_api_host()

            api_client = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(client_id, client_secret)

    # usersApi = PureCloudPlatformClientV2.UsersApi(api_client)
    # create an instance of the API class
    api_instance = PureCloudPlatformClientV2.PresenceApi(api_client)

    divisions = get_division()
    agent_ids = get_agent_ids(divisions)

        for agent_id in agent_ids:
            # Get a user's Genesys Cloud presence.
            api_response = api_instance.get_user_presences_purecloud(agent_id)
    except ApiException as e:
        print("Exception when calling GetUserPresencesPurecloudRequest->get_user_presences_purecloud: %s\n" % e)


    David Perry
    Pizza Pizza Ltd.

  • 2.  RE: Help bulk extracting the current presence of a large group of users via API

    Posted 02-06-2023 17:29

    You are probably running into the API Rate Limit which is, I believe, something like 300 requests per application per minute. Exceeding this results in a 429 HTTP response code and a "Retry After" header (From memory, this is between 30 and 90 seconds). The library will be handling this for you, so you won't see it directly, but this is causing pauses, which you experience as "throttling".

    Unfortunately, I am not aware of an API call that will return all the presences in a single call - might be worth submitting an idea?

    Paul Simpson
    Eventus Solutions Group