Trying to bulk-create users from a CSV using the Genesys Cloud Python SDK. Docs state: “The users API allows programmatic creation of users via POST /api/v2/users.” I’m hitting a 400 Bad Request on the second user in the loop. The first user creates fine. The second one fails. The error payload says “Invalid email format” but the email is valid. Checked the CSV. No hidden characters.
Here’s the snippet:
from genesyscloud import users_api
from genesyscloud.rest import ApiException
import csv
api = users_api.UsersApi(api_client)
with open('users.csv', 'r') as f:
reader = csv.DictReader(f)
for row in reader:
try:
user = api.post_users(
body={
'email': row['email'],
'name': row['name'],
'skills': [],
'wrap_up_code': None,
'routing_email_address': row['email']
}
)
print(f"Created {row['name']}")
except ApiException as e:
print(f"Failed {row['name']}: {e.reason} - {e.body}")
break
The error body is:
{
"code": "badRequest",
"message": "Invalid email format",
"status": 400
}
I’ve verified the email addresses in the CSV are correct. No spaces. No nulls. The first user creates without issue. The second one fails immediately. The API docs don’t mention rate limiting causing a 400 on the second request. OAuth token is valid. Client credentials grant. Token has 30 minutes left. Not expired.
Steps taken:
- Verified CSV encoding (UTF-8)
- Checked email format against RFC 5322
- Tested single user creation outside the loop - works
- Added logging to see exact payload sent - looks fine
- Tried adding a small delay between requests - same error
Why does the second request fail? The payload is identical in structure. Only the email and name change. The SDK isn’t reusing the same object reference, right? Or is there a hidden validation rule for bulk operations? The docs say nothing about this. Just “POST /api/v2/users”. No mention of batch limits or sequential validation quirks. Feels like a server-side state issue. Or maybe the SDK is caching something. Not sure where to look next.