I’m trying to automate user provisioning from a CSV file using the Python SDK. The goal is to create agents with specific skill assignments in one go.
I’m using genesyscloud_user.UserBulkCreate as documented. Here is the core loop where I build the payload:
from genesyscloud.users import UserBulkCreate
users_to_create = []
for row in csv_data:
new_user = {
'email': row['email'],
'name': row['name'],
'username': row['email'],
'user_type': 'agent',
'division_id': config['division_id'],
'roles': [{'id': 'a9876543-1234-5678-90ab-cdef12345678'}], # Standard Agent Role
'skills': [{'id': row['skill_id'], 'proficiency': 5}]
}
users_to_create.append(new_user)
try:
response = api_client.user_bulk_create(users=users_to_create)
print(f"Created {response['id']} users")
except Exception as e:
print(f"Error: {e}")
The script runs without Python exceptions. The response I get back is a 400 Bad Request. The body contains:
{
"errors": [
{
"message": "Invalid request body",
"detail": "User 'john.doe@example.com' already exists in division 'main-division-id'"
}
]
}
I’ve verified the CSV. The email john.doe@example.com definitely does not exist in our Genesys Cloud instance. I even searched via the UI to be sure.
Is the user_bulk_create endpoint checking against a soft-deleted cache or something? Or am I formatting the UserBulkCreate object wrong? The docs are vague on the exact schema for the users array inside the bulk call.
Also, if I remove the skills field, the same user still fails with the same “already exists” error. So it’s not the skill assignment causing the conflict.
Any ideas on how to debug this specific 400? I need to know if the SDK is sending a different payload than I expect.