#7987·unleash

Update a Segment via API call

Author: theomeuhCreated Aug 27, 2024Updated Mar 19, 2025

Discussed in https://github.com/orgs/Unleash/discussions/7980

Originally posted by theomeuh August 26, 2024 I'm trying to migrate some data we have in Unleash and I need to automatically update Segment via API. I'm referring to this endpoint: https://docs.getunleash.io/reference/api/unleash/update-segment

Context

It says: "Any fields not specified will be left untouched", but if I try to PUT an empty body, I got a 400 Bad Request {"id":"1dd37e9f-2b75-458b-b7ca-1424e0561479","name":"BadDataError","message":"Request validation failed: your request body or params contain invalid data. Refer to the details list for more information.","details":[{"message":"\"name\" is required."}]}

Then let's add a "dummy name".. I got the same message but this time, it is the field "constraints" which is apparently missing.

My question: is the doc up-to-date ? It really looks like a PUT (like the endpoint verb says) and not a PATCH (like the description says), do you confirm ?

PS: what I really want is to update "constraints" but unfortunately, I have the "name is required" error when I try to just push a payload with only "constraints"

Current behavior

A PUT requests on api/admin/segments/:id with in body a json containing only the key constraints returns a 400, saying the field name is required

Expected behavior

A PUT requests on api/admin/segments/:id with in body a json containing only the key constraints must return a 200 (and update the constraints field)