Trying to update participant attributes mid-call via the Conversations API. The endpoint is /api/v2/conversations/{conversationId}/attributes. I’m sending a simple JSON payload like { "key": "user_type", "value": "vip" }. It returns a 400 Bad Request with message ‘Invalid attribute key format’. I’ve checked the docs and the key looks valid. Is there a regex constraint I’m missing?
// You need to pass an array of objects, not a single object
const payload = [
{
key: "user_type",
value: "vip",
// Optional: specify type if it's not a string
type: "string"
}
];
// Using PureCloudPlatformClientV2 (Node.js)
const conversationsApi = new PlatformClient.V2.ConversationsApi();
await conversationsApi.postConversationsAttributes(conversationId, payload);
The 400 is happening because the endpoint expects a JSON array, even if you’re only updating one attribute. The docs can be a bit sparse on the exact schema shape for the request body in the JS SDK examples.
Also, double-check the key format. Genesys is strict about this. Keys must start with a letter, contain only alphanumeric characters, underscores, or dots, and usually need to be lowercase. If you’re injecting dynamic keys from a webhook, make sure you’re sanitizing them first. No spaces or special chars allowed there.
I’ve burned hours on this before thinking it was a permissions issue. It’s just the array wrapper missing. Try wrapping that object in [] and it should fly right through.