Create a context field
POST<your-unleash-url>/api/admin/context
Endpoint that allows creation of custom context fields
Request
- application/json
Bodyrequired
createContextFieldSchema
descriptionstring
A description of the context field
Example:
The user's subscription tier
stickinessboolean
true
if this field should be available for use with custom stickiness, otherwise false
Example:
false
sortOrderinteger
How this context field should be sorted if no other sort order is selected
Example:
2
legalValues object[]
namestringrequired
The name of the context field.
Example:
subscriptionTier
Responses
- 201
The resource was successfully created.
Response Headers
- application/json
- Schema
- Example (auto)
Schema
namestringrequired
The name of the context field
Example:
userId
descriptionstringnullable
The description of the context field.
Example:
Used to uniquely identify users
stickinessboolean
Does this context field support being used for stickiness calculations
Example:
true
sortOrderinteger
Used when sorting a list of context fields. Is also used as a tiebreaker if a list of context fields is sorted alphabetically.
Example:
900
createdAtdate-timenullable
When this context field was created
Example:
2023-06-29T10:19:00.000Z
usedInFeaturesintegernullable
Number of projects where this context field is used in
Example:
3
usedInProjectsintegernullable
Number of projects where this context field is used in
Example:
2
legalValues object[]
{
"name": "userId",
"description": "Used to uniquely identify users",
"stickiness": true,
"sortOrder": 900,
"createdAt": "2023-06-29T10:19:00.000Z",
"usedInFeatures": 3,
"usedInProjects": 2,
"legalValues": [
{
"value": "#c154c1",
"description": "Deep fuchsia"
}
]
}
Authorization: Authorization
name: Authorizationtype: apiKeyin: headerdescription: API key needed to access this API
- curl
- python
- go
- nodejs
- ruby
- csharp
- php
- java
- powershell
- CURL
curl -L '<your-unleash-url>/api/admin/context' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: <Authorization>' \
-d '{
"description": "The user'\''s subscription tier",
"stickiness": false,
"sortOrder": 2,
"legalValues": [
{
"value": "gold"
},
{
"value": "silver"
},
{
"value": "crystal"
}
],
"name": "subscriptionTier"
}'
ResponseClear