Snippet first.
import csv
from genesyscloud import PlatformClient, PlatformClientBuilder
client = PlatformClientBuilder().with_client_id_secret(CLIENT_ID, SECRET).build()
users_api = client.get_users_api()
with open('new_agents.csv') as f:
reader = csv.DictReader(f)
for row in reader:
user_req = {
"name": row['name'],
"username": row['email'],
"email": row['email'],
"roles": [{"id": row['role_id']}]
}
users_api.post_users(body=user_req)
Running this against our prod tenant. The script crashes after about 12 users with a 429 Too Many Requests. I know the API has rate limits, but I’m not seeing a clear way to handle the backoff in the Python SDK without wrapping every call in a try/except block that sleeps for a random interval.
Is there a bulk endpoint I’m missing? Or a recommended pattern for throttling these requests in the SDK? The current approach feels fragile. If I add a hard sleep(1) between calls it works but takes forever for a file with 500 rows.
Looking for the cleanest way to handle this volume.