Python SDK bulk user creation CSV mapping error

Parsing a CSV to bulk-create users via the Python SDK. The loop calls user_management_api.post_users with a User object, but the API returns a 400 Bad Request. The error payload shows a validation failure on the routing_email_address field, even though the CSV data is valid. Here’s the relevant snippet.

from genesyscloud.user_management.api import UserManagementApi
from genesyscloud.user_management.model import User

user = User(
 email=row['email'],
 name=row['name'],
 routing_email_address=row['email'],
 username=row['email']
)
try:
 user_management_api.post_users(body=[user])
except Exception as e:
 print(e.body)

Output:

{
 "errors": [
 {
 "code": "VALIDATION_ERROR",
 "message": "routing_email_address must be a valid email address"
 }
 ]
}

The email is definitely valid. Is the SDK model stripping whitespace or encoding the string incorrectly?

You’re probably hitting a serialization issue with the SDK’s model builder. The Python SDK expects specific nested objects for address and email, not raw strings. If you pass a plain string to routing_email_address, the serializer might drop it or format it wrong, causing a 400.

Check if you’re instantiating the User object correctly. You need to use the Email model for the email field. Also, ensure the emails list isn’t empty if the schema requires it.

from genesyscloud.user_management.models import User, Email

# Correct way to set the email
email_obj = Email(email="user@example.com", type="work", primary=True)

new_user = User(
 emails=[email_obj],
 name="Test User"
)

The API is strict about the structure. If the CSV has the email as a string, wrap it in the Email class before adding it to the emails list. Don’t just pass routing_email_address="test@test.com". That field might be deprecated or handled differently in the current SDK version. Stick to the emails array.