Trying to automate the creation of an outbound contact list via the REST API. The goal is simple. Create a list, add contacts, start a campaign. Stuck on the first step.
I’m using Python with the genesyscloud SDK. The documentation says the email field is required if the contact is email-based. I have the email in the payload. The API throws a 400 Bad Request.
Here is the code :
from genesyscloud.outbound import OutboundApi
api_instance = OutboundApi(configuration)
body = {
'name': 'Test List Auto',
'description': 'Created via API',
'contact_type': 'EMAIL',
'contact_list_type': 'EMAIL',
'contacts': [
{
'id': 'c-1',
'email': 'test@example.com',
'email_type': 'WORK'
}
]
}
try:
result = api_instance.post_outbound_contactlists(body=body)
print(f"List created: {result.id}")
except ApiException as e:
print(f"Status: {e.status}")
print(f"Response: {e.body}")
The error response is:
{
"message": "Invalid value for field 'email'",
"code": "INVALID_VALUE",
"status": 400
}
I’ve tried changing email_type to WORK_EMAIL. I’ve tried removing the contact_type field. I’ve tried passing the email as a string instead of an object in the array. Nothing works. The error always points to the email field being invalid.
The same payload works fine if I manually create the list in the UI and import a CSV. But the API rejects it immediately. Is there a specific format requirement for the email field in the POST body that isn’t documented? Or is the SDK serializing this incorrectly?