Interaction Metrics API - Batch Create Failing

running against the external metrics definitions endpoint.
we’re on Genesys Cloud,
python client,
version 6.1.0.

it’s blowing up with a 422
on the first metric in the payload.
the error body
just says
{"message":"Bad Request"}.
fwiw,
it’s not the schema.
validated against
the openapi spec.

the payload is a list of metric definitions,
each with a name, dimension, and metricType.
simple stuff.
if it helps,
the dimensions are all pre-existing.
no custom dimensions being created here.
the metricType is “sum”.

i’ve tried
a single metric,
different dimensions,
even stripping down
to the bare minimum
required fields.
still 422.
the same metric
works fine
through the UI.
generator’s template
is standard,
no customisations.
it’s weird.
might be something
on the backend.

1 Like

That 422 usually pops up when there’s a mismatch in the dimension naming or a duplicate definition already exists. In CIC we used to just jam everything into the reporting tables and it’d mostly work, but GC is way more strict about the unique constraints on these definitions. Check if you’ve got a metric with the same name already live in the org.

If you’re trying to push a bunch at once, you might want to loop through a POST to /api/v2/employeeperformance/externalmetrics/definitions instead of a batch attempt. It’s a bit slower but you’ll actually get a decent error message for the specific metric that’s failing. Try this in your python script:

for metric in metrics_list:
 try:
 api.post_employeeperformance_externalmetrics_definitions(metric)
 except Exception as e:
 print(f"Failed on {metric['name']}: {e}")
1 Like

The POST /api/v2/employeeperformance/externalmetrics/definitions endpoint is very picky about how the body is structured when you’re doing batch operations. At my last shop, we had a similar situation where the API returned 422 because we were sending a list of objects when the endpoint expected a single object per request, or the internal IDs were clashing in a way that wasn’t obvious in the logs.

Are you using a loop to call the create endpoint for each metric or are you trying to pass an array in a single request body? At my last shop, we found that the Python sometimes handles the serialization differently than the raw HttpClient calls we did in C#, so it’s worth checking if the payload is actually being sent as a JSON list.

1 Like