Trying to bulk-create users from a CSV using the Python SDK. Getting 409 Conflict on the users_api.post_users call even though the users don’t exist yet.
api_instance = gen_cloud_python_sdk.UsersApi(client)
body = gen_cloud_python_sdk.UserPostRequest(
address_line_1='123 Main St',
first_name=row['first'],
last_name=row['last'],
email=row['email'],
username=row['email']
)
api_instance.post_users(body)
What am I missing?
You’re hitting a duplicate constraint, likely on the username or email field, even if the user doesn’t exist. The 409 means the system thinks it’s already there.
- Check for existing users with the same email or username in a different environment or org. Genesys Cloud can be strict about global uniqueness depending on your setup.
- Ensure you’re not running this script twice. If the first run failed mid-way, those users might be in a “pending” or “created” state. Query
GET /api/v2/users with the specific email to verify.
- If you’re sure they’re new, the SDK might be caching a previous error or the payload is malformed. Try a single user creation via Postman to isolate the SDK issue.
Here’s a quick check to see if the user exists before posting:
try:
# Check if user exists
users, _, _ = api_instance.get_users(query=f'extension="{row["email"]}"') # or email={row["email"]}
if not users.entities:
api_instance.post_users(body)
else:
print(f"User {row['email']} already exists.")
except Exception as e:
print(f"Error: {e}")
The UserPostRequest looks fine, but the conflict is almost always data-related.