Writing a script to bulk-create users from a CSV using the Genesys Cloud Python SDK. The goal is straightforward: read the CSV, map fields to the User model, and call api_instance.post_users(user).
The issue is the rate limit. The /api/v2/users endpoint has a strict limit, and my loop is getting hammered with 429 Too Many Requests after about 20-30 users.
client = PureCloudApi.init_client(client_id, client_secret)
api_instance = client.user_management_api()
for row in csv_data:
user = models.User(
name=row['name'],
email=row['email'],
... # other fields
)
try:
api_instance.post_users(user)
except ApiException as e:
if e.status == 429:
# wait and retry?
pass
I’ve tried adding time.sleep(2) between calls, but it’s still failing intermittently. Is there a batch endpoint I’m missing? Or is there a better way to handle the retry logic within the SDK itself? The docs don’t mention a bulk user creation endpoint, so I’m stuck with the loop. Any ideas on how to handle this without writing a complex retry queue?