Skip to main content

Update segment by id

PUT 

<your-unleash-url>/api/admin/segments/:id

Updates the content of the segment with the provided payload. Requires name and constraints to be present. If project is not present, it will be set to null. Any other fields not specified will be left untouched.

Request

Path Parameters

    id integerrequired

    a segment id

Bodyrequired

upsertSegmentSchema

    namestringrequired

    The name of the segment

    Example: beta-users
    descriptionstringnullable

    A description of what the segment is for

    Example: Users willing to help us test and build new features.
    projectstringnullable

    The project the segment belongs to if any.

    Example: red-vista
    constraints object[]required

    The list of constraints that make up this segment

  • Array [
  • contextNamestringrequired

    The name of the context field that this constraint should apply to.

    Example: appName
    operatorstringrequired

    The operator to use when evaluating this constraint. For more information about the various operators, refer to the strategy constraint operator documentation.

    Possible values: [NOT_IN, IN, STR_ENDS_WITH, STR_STARTS_WITH, STR_CONTAINS, NUM_EQ, NUM_GT, NUM_GTE, NUM_LT, NUM_LTE, DATE_AFTER, DATE_BEFORE, SEMVER_EQ, SEMVER_GT, SEMVER_LT]

    Example: IN
    caseInsensitiveboolean

    Whether the operator should be case sensitive or not. Defaults to false (being case sensitive).

    Default value: false
    invertedboolean

    Whether the result should be negated or not. If true, will turn a true result into a false result and vice versa.

    Default value: false
    valuesstring[]

    The context values that should be used for constraint evaluation. Use this property instead of value for properties that accept multiple values.

    Example: ["my-app","my-other-app"]
    valuestring

    The context value that should be used for constraint evaluation. Use this property instead of values for properties that only accept single values.

    Example: my-app
  • ]

Responses

This response has no body.

Authorization: Authorization

name: Authorizationtype: apiKeyin: headerdescription: API key needed to access this API
curl -L -X PUT '<your-unleash-url>/api/admin/segments/:id' \
-H 'Content-Type: application/json' \
-H 'Authorization: <Authorization>' \
-d '{
"name": "beta-users",
"description": "Users willing to help us test and build new features.",
"project": "red-vista",
"constraints": [
{
"contextName": "appName",
"operator": "IN",
"caseInsensitive": false,
"inverted": false,
"values": [
"my-app",
"my-other-app"
],
"value": "my-app"
}
]
}'
Request Collapse all
Base URL
<your-unleash-url>
Auth
Parameters
— pathrequired
Body required
{
  "name": "beta-users",
  "description": "Users willing to help us test and build new features.",
  "project": "red-vista",
  "constraints": [
    {
      "contextName": "appName",
      "operator": "IN",
      "caseInsensitive": false,
      "inverted": false,
      "values": [
        "my-app",
        "my-other-app"
      ],
      "value": "my-app"
    }
  ]
}
ResponseClear

Click the Send API Request button above and see the response here!