400 Bad Request updating interaction wrap-up code via /api/v2/interactions/... using Python

import requests

payload = {
 "type": "voice",
 "wrapUp": {
 "code": "survey-nps-9",
 "comment": "Auto-assigned based on NPS score"
 }
}

response = requests.patch(
 f"https://api.mypurecloud.com/api/v2/interactions/{interaction_id}",
 headers={"Authorization": f"Bearer {token}"},
 json=payload
)

400 Bad Request. It’s a generic validation error. Payload looks clean though.

  • Running Python 3.9 in a Lambda.
  • Token is valid. Scopes include interaction:view and interaction:edit.
  • Wrap-up code survey-nps-9 exists in the org.

Tried stripping the comment field. Still 400.
Logs confirm the ID matches the event payload. Interaction state is completed.

Same payload works in Postman. No issues there. Suspect the API is choking on the state check when the request comes from the backend. Maybe the interaction needs to be “available” or something? Docs are light on details for this edge case.

Tried a minimal update to the routing object. Fails hard.
Even just patching the wrapUp.code without any extra fields hits the wall.

Error response is unhelpful.

{
 "message": "Validation failed",
 "errors": [
 "The interaction cannot be updated in its current state."
 ]
}

Token scope is correct.

import requests
import opentelemetry.trace as trace

tracer = trace.get_tracer("genesys-wrapp")
with tracer.start_as_current_span("patch-interaction") as span:
 payload = {
 "wrapUp": {
 "code": "survey-nps-9",
 "comment": "Auto-assigned based on NPS score"
 }
 }
 headers = {
 "Authorization": f"Bearer {token}",
 "traceparent": span.get_span_context().to_traceparent()
 }
 response = requests.patch(
 f"https://api.mypurecloud.com/api/v2/interactions/{interaction_id}",
 headers=headers,
 json=payload
 )

Problem
Throwing that type field into the root JSON trips the validator. The Genesys edge strictly validates PATCH operations against the interaction schema, so extra keys get flagged immediately. The endpoint treats interaction type as immutable once the leg spins up. Stripping it usually clears the path.

Code
See the snippet above. Removed the read-only property and injected a W3C trace header.

Error
You’ll hit a 400 validation_failed response pointing directly at the type key. The edge parser drops anything outside the expected wrap-up schema. Context propagation helps track exactly where the gateway rejects the payload. I’ve seen this exact pattern break when legacy scripts push full interaction objects instead of targeted patches.

Question
Have you hooked up a Zipkin backend to watch the request hop? I’m trying to map how the API layer handles partial updates when span context is missing. Might be worth testing the trace header to see where the validation drops off.