I'm currently working on real-time chat functionality for my application using AWS API Gateway for WebSockets, along with Lambda and Prisma. I'm facing a problem where, when I send a message, it gets stored in the database, but I encounter a 'forbidden exception' when trying to broadcast that message to other chat connections using the postToConnection function from my Lambda function. I've been troubleshooting this issue for two days now, and I can't seem to find a solution. If anyone has insights or suggestions, I would greatly appreciate your help, as this is quite urgent!
2 Answers
Could you share the full error message you're getting? It might help figure out the issue.
Your Lambda function might be missing some key permissions. You need to ensure that it has the right policy attached, like this:
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "execute-api:ManageConnections",
"Resource": "arn:aws:execute-api:REGION:ACCOUNT_ID:API_ID/*"
}
]
}
```
Make sure to replace REGION, ACCOUNT_ID, and API_ID with the actual values for your setup. Let me know if you still face issues after that!
I've already added that policy, but I'm still getting the same forbidden error.

Sure! Here's the error message I'm getting:
```json
{
"timestamp": "2025-11-01T20:07:24.111Z",
"level": "ERROR",
"requestId": "547f0132-005e-4a45-8b31-50d4bd2a1f50",
"message": "[sendMessage] Failed to send to connection TYU_DfTTgi0Adsw=: ForbiddenException: Forbidden"
}
```