EventBridge rule triggers but Genesys Cloud webhook returns 422

Trying to wire up a real-time event stream from Genesys Cloud to an AWS EventBridge bus. The Genesys side is configured with a webhook pointing to my EventBridge PutEvents API endpoint via a Lambda proxy.

The Lambda receives the payload, parses it, and pushes to the bus. But Genesys is returning a 422 Unprocessable Entity on the initial POST.

Here’s the raw request body Genesys sends:

{
 "eventType": "routing.queue.conversation",
 "data": {
 "conversationId": "abc-123",
 "timestamp": "2023-10-27T14:00:00Z"
 }
}

My Lambda handler looks like this:

def lambda_handler(event, context):
 client = boto3.client('events')
 client.put_events(
 Entries=[
 {
 'Source': 'genesys.cloud',
 'DetailType': event['eventType'],
 'Detail': json.dumps(event['data'])
 }
 ]
 )
 return {
 'statusCode': 200,
 'body': json.dumps('OK')
 }

The CloudWatch logs show the Lambda executing successfully with a 200 response. Yet Genesys retries and logs a 422. The docs say 422 means the payload format is wrong, but I’m just echoing the event back. Is there a specific header or content-type requirement for the EventBridge proxy that I’m missing? Or is the Detail field size limit kicking in?

422 usually means the payload schema is wrong. Genesys sends an array, not a single object. Your Lambda bably expects {} but gets []. Wrap the parsing in Array.isArray(body) ? body : [body]. Also, ensure the webhook target URL is public. EventBridge API endpoints often block non-HTTPS or internal IPs. Check the Lambda logs for the exact validation error.