Guest API POST /api/v2/conversations/messaging/contacts returns 401 despite valid token

Hey folks,

I’m trying to integrate a custom web chat interface into our internal WFM dashboard. The goal is to let supervisors send a quick message to an agent without opening the full Messenger widget. We want to keep the UI clean and just show a simple text box.

I’ve been following the Guest API documentation to create a guest contact and start a conversation. I’m using the Genesys Cloud JavaScript SDK to handle the OAuth2 client credentials flow. I can get a token successfully, but when I try to POST to the messaging endpoint, it fails.

Here’s the relevant part of my code:

const response = await fetch('https://api.mypurecloud.com/api/v2/conversations/messaging/contacts', {
 method: 'POST',
 headers: {
 'Authorization': `Bearer ${token}`,
 'Content-Type': 'application/json',
 'Accept': 'application/json'
 },
 body: JSON.stringify({
 "name": "Supervisor Bot",
 "email": "supervisor@company.com",
 "routingData": {
 "queueId": "12345-67890-abcde" // Valid queue ID
 }
 })
});

The response I’m getting back is a 401 Unauthorized. The JSON error payload says "error": "unauthorized", "message": "Invalid or expired token". This is confusing because I just generated the token five seconds ago. I’ve checked the token expiry in the JWT payload, and it’s definitely still valid.

I’ve also tried adding the X-Genesys-Application-Name header, but that didn’t change anything. Is there a specific scope I’m missing for the Guest API? My current scopes are conversation:view and conversation:write. I thought those would be enough to create a guest contact.

Any ideas why the token is being rejected for this specific endpoint? I’m using the US-Central region endpoint.