Python SDK bulk user creation failing with 409 Conflict on duplicate emails

We’re trying to onboard a batch of 500 agents from a CSV file using the Genesys Cloud Platform SDK for Python. The script reads the CSV, constructs the User objects, and calls create_user in a loop.

The issue is that if the CSV contains a user that already exists in Genesys Cloud (even if the email is slightly different or just a retry of the script), the whole batch fails or throws a 409 Conflict error. I need to handle this gracefully without stopping the entire run.

Here’s the core loop:

from platform_sdk.client import Client
from platform_sdk.models import User

client = Client(...)
users = [...] # list of User objects from CSV

for user in users:
 try:
 response = client.users.create_user(body=user)
 print(f"Created user: {response.id}")
 except Exception as e:
 print(f"Failed to create user: {e}")
 raise # This stops everything

The error message looks like this:
platform_sdk.exceptions.ApiException: (409) Reason: Conflict Details: Email address is already in use.

I’ve tried wrapping the call in a try/except block, but catching the generic Exception doesn’t seem to filter out the 409s cleanly enough for my logging needs. I want to skip the existing users and continue creating the new ones.

Environment:

  • Genesys Cloud Platform SDK for Python v1.23.0
  • Python 3.11
  • CSV file with ~500 rows, columns: name, email, division_id

Is there a better way to check for existing users before calling create_user? Or should I be parsing the ApiException to check the status code and message specifically? I’d rather not make a separate get_user_by_email call for every single row if I can avoid it, as that would double the API calls.

Any tips on handling bulk operations with the SDK?