Skip to main content
Python

Prepare the request

The script reads your API token from the LUMOS_API_TOKEN environment variable, so the token never appears in the code. Create a token on the API Tokens page. For details, see Authentication. The script uses Python 3 and the requests library (pip install requests).
get() sends each request and handles one failure itself. When a response is a 429, meaning you’re over the rate limit, it waits the number of seconds in the Retry-After header, then tries again. Any other error raises, so a bad token stops the script with a 401 instead of printing nothing.

Set the search string

Set SEARCH to the text to search for. List Groups returns every group whose name contains it. Set EXACT_MATCH to True to get only groups whose whole name is SEARCH. The search matches letters, digits, spaces, and the characters ., ,, -, and ' literally. Any other character matches any single character, so an exact search for R&D also finds a group named R/D. Check the names in the output before you rely on a match.

Read every page

A response holds one page of groups and a next_page_token:
Response
The loop sends next_page_token as page_token in the next call, and stops when next_page_token is missing or null. A page with fewer than page_size groups doesn’t mean it was the last page. Keep name, exact_match, and page_size the same on every call, because a page token works only with the parameters it came from. Pagination explains both rules.

Use what you found

Each group carries two IDs, for different jobs:
  • id is the Lumos ID. Pass it to Get Group and List Group Members.
  • integration_specific_id is the group’s ID in the app it comes from. It’s the value a condition matches in identity.groups[*].external_id. You can find a group by it with the integration_specific_id filter on List Groups.
app_id is the id of the app the group comes from, the same id that GET /v1/apps returns.