provider Segments PATCH
/api/v2/segments/{projectKey}/{segmentKey}/expiring-targets/{environmentKey} @utdk/launchdarkly
/api/v2/segments/{projectKey}/{segmentKey}/expiring-targets/{environmentKey} Update expiring targets for segment
Update expiring context targets for a segment. Updating a context target expiration uses the semantic patch format.
To make a semantic patch request, you must append `domain-model=launchdarkly.semanticpatch` to your `Content-Type` header. To learn more, read [Updates using semantic patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch).
If the request is well-formed but any of its instructions failed to process, this operation returns status code `200`. In this case, the response `errors` array will be non-empty.
### Instructions
Semantic patch requests support the following `kind` instructions for updating expiring context targets.
<details>
<summary>Click to expand instructions for <strong>updating expiring context targets</strong></summary>
#### addExpiringTarget
Schedules a date and time when LaunchDarkly will remove a context from segment targeting. The segment must already have the context as an individual target.
##### Parameters
- `targetType`: The type of individual target for this context. Must be either `included` or `excluded`.
- `contextKey`: The context key.
- `contextKind`: The kind of context being targeted.
- `value`: The date when the context should expire from the segment targeting, in Unix milliseconds.
Here's an example:
```json
{
"instructions": [{
"kind": "addExpiringTarget",
"targetType": "included",
"contextKey": "user-key-123abc",
"contextKind": "user",
"value": 1754092860000
}]
}
```
#### updateExpiringTarget
Updates the date and time when LaunchDarkly will remove a context from segment targeting.
##### Parameters
- `targetType`: The type of individual target for this context. Must be either `included` or `excluded`.
- `contextKey`: The context key.
- `contextKind`: The kind of context being targeted.
- `value`: The new date when the context should expire from the segment targeting, in Unix milliseconds.
- `version`: (Optional) The version of the expiring target to update. If included, update will fail if version doesn't match current version of the expiring target.
Here's an example:
```json
{
"instructions": [{
"kind": "updateExpiringTarget",
"targetType": "included",
"contextKey": "user-key-123abc",
"contextKind": "user",
"value": 1754179260000
}]
}
```
#### removeExpiringTarget
Removes the scheduled expiration for the context in the segment.
##### Parameters
- `targetType`: The type of individual target for this context. Must be either `included` or `excluded`.
- `contextKey`: The context key.
- `contextKind`: The kind of context being targeted.
Here's an example:
```json
{
"instructions": [{
"kind": "removeExpiringTarget",
"targetType": "included",
"contextKey": "user-key-123abc",
"contextKind": "user",
}]
}
```
</details>
- projectKey path required
- The project key
- string
- environmentKey path required
- The environment key
- string
- segmentKey path required
- The segment key
- string
Try it
Authentication
Configure credentials for LaunchDarkly REST API
Gateway
The gateway proxies requests and injects credentials server-side. Configure credentials above, then enter your gateway URL.
Saved automatically to browser storage.
Code snippet
Updates live as you fill in the form above.
TypeScript
import launchdarkly from '@utdk/launchdarkly';
await launchdarkly.patchexpiringtargetsforsegment()