Skip to main content

Create a context field

POST <your-unleash-url>/api/admin/context

Authorization

name: Authorizationtype: apiKeyin: headerdescription: API key needed to access this API

Endpoint that allows creation of custom context fields

Request

Body

required

createContextFieldSchema

  • description string

    A description of the context field

  • stickiness boolean

    true if this field should be available for use with custom stickiness, otherwise false

  • sortOrder integer

    How this context field should be sorted if no other sort order is selected

  • legalValues object[]

    A list of allowed values for this context field

  • Array [
  • value string required

    The valid value

  • description string

    Describes this specific legal value

  • ]
  • name string required

    The name of the context field.

Responses

The resource was successfully created.

Response Headers
  • location string

    The location of the newly created resource.

Schema
  • name string required

    The name of the context field

  • description string nullable

    The description of the context field.

  • stickiness boolean

    Does this context field support being used for stickiness calculations

  • sortOrder integer

    Used when sorting a list of context fields. Is also used as a tiebreaker if a list of context fields is sorted alphabetically.

  • createdAt date-time nullable

    When this context field was created

  • usedInFeatures integer nullable

    Number of projects where this context field is used in

  • usedInProjects integer nullable

    Number of projects where this context field is used in

  • legalValues object[]

    Allowed values for this context field schema. Can be used to narrow down accepted input

  • Array [
  • value string required

    The valid value

  • description string

    Describes this specific legal value

  • ]

Authorization

name: Authorizationtype: apiKeyin: headerdescription: API key needed to access this API

Request

Base URL
<your-unleash-url>
Security Scheme
apiKey
Body required
{
"description": "The user's subscription tier",
"stickiness": false,
"sortOrder": 2,
"legalValues": [
{
"value": "gold"
},
{
"value": "silver"
},
{
"value": "crystal"
}
],
"name": "subscriptionTier"
}
curl / cURL
curl -L -X POST '<your-unleash-url>/api/admin/context' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: <API_KEY_VALUE>' \
--data-raw '{
"description": "The user'\''s subscription tier",
"stickiness": false,
"sortOrder": 2,
"legalValues": [
{
"value": "gold"
},
{
"value": "silver"
},
{
"value": "crystal"
}
],
"name": "subscriptionTier"
}'