Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  How can I get the Group ID by Group Name using Python?

    Posted 10-16-2025 10:38

    I'm trying to get the Group Id by the Group Name using Python.

    For example, I have a Group called "TEST_GROUP_1" and I'm looking for the corresponding Group ID.

    I tried using the following Python code, but I don't know how to set the body object and the search request options.

    api_instance = PureCloudPlatformClientV2.SearchApi()
    body = PureCloudPlatformClientV2.GroupSearchRequest() # GroupSearchRequest | Search request options

    api_response = api_instance.post_groups_search(body)

    Please, can you help me?

    Thanks so much for the support.


    #PlatformAPI

    ------------------------------
    Giampy
    ------------------------------


  • 2.  RE: How can I get the Group ID by Group Name using Python?
    Best Answer

    Posted 10-16-2025 10:48

    You can use the /api/v2/scim/groups API and pass as a filter 'displayName eq TEST_GROUP_1'

    This code is from ApiExplorer:

    import PureCloudPlatformClientV2
    from PureCloudPlatformClientV2.rest import ApiException
    from pprint import pprint

    PureCloudPlatformClientV2.configuration.access_token = 'your_access_token'

    api_instance = PureCloudPlatformClientV2.SCIMApi();
    start_index = 1
    count = 25
    attributes = ['attributes_example']
    excluded_attributes = ['excluded_attributes_example']
    filter = 'displayName eq TEST_GROUP_1'

    try:
        api_response = api_instance.get_scim_groups(start_index=start_index, count=count, attributes=attributes, excluded_attributes=excluded_attributes, filter=filter)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SCIMApi->get_scim_groups: %s\n" % e)



    ------------------------------
    Debora Lopes
    ------------------------------



  • 3.  RE: How can I get the Group ID by Group Name using Python?

    Posted 10-20-2025 09:53

    It works great!
    Thank you so much.



    ------------------------------
    Giampiero Casu
    ------------------------------