Closing Web Messaging Guest Session via API returns 404

I’m trying to build a backend process that automatically closes Web Messaging sessions for users who have been inactive for more than 10 minutes. We’re using the Guest API for our custom frontend, and I need to trigger the session closure from our Node.js server rather than relying on the client-side SDK. I found the DELETE /api/v2/conversations/{conversationId} endpoint in the docs, which seems like the right place to start, but I’m running into issues with authentication and resource identification. The guest token is ephemeral, so I’m using an OAuth2 client credentials flow to get an access token for my service account. I’m passing the conversation ID I captured from the initial POST /api/v2/conversations response, but the API keeps rejecting my request. I’ve verified the conversation ID is correct by checking the GET /api/v2/conversations list, and it shows as ‘active’.

Here’s the curl command I’m using to test this before integrating it into the code:

curl -X DELETE "https://api.mypurecloud.com/api/v2/conversations/conv-12345-abcde" \
 -H "Authorization: Bearer {my_service_account_token}" \
 -H "Content-Type: application/json"

The response is a 404 Not Found with the message {"code":"not_found","message":"Resource not found"}. This is confusing because the conversation definitely exists and is active. I also tried using the DELETE /api/v2/webmessaging/guests/{guestId} endpoint, but that requires the guest ID, which I don’t have stored in our database-only the conversation ID. Is there a specific permission my service account is missing, or is there a different endpoint I should be hitting to close the session from the backend? I’ve checked the role permissions, and the account has ‘full’ access to conversations, so that shouldn’t be the issue. Any ideas on why the DELETE request is failing?