For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • REST API overview
    • Access Tokens
    • Account Members
    • Account Usage Beta
    • AI Configs
    • Announcements
    • Applications Beta
    • Approvals
    • Approvals Beta
    • Audit Log
    • Code References
    • Contexts
    • Context Settings
    • Custom Roles
    • Data Export Destinations
    • Environments
    • Experiments
    • Feature Flags
      • POSTCopy feature flag
      • POSTCreate a feature flag
      • DELDelete feature flag
      • GETGet expiring context targets for feature flag
      • GETGet expiring user targets for feature flag
      • GETGet feature flag
      • GETGet feature flag status
      • GETGet flag status across environments
      • POSTGet migration safety issues
      • GETList feature flag statuses
      • GETList feature flags
      • PATCHUpdate expiring context targets on feature flag
      • PATCHUpdate expiring user targets on feature flag
      • PATCHUpdate feature flag
    • Feature Flags Beta
    • Flag Import Configurations Beta
    • Flag Links Beta
    • Flag Triggers
    • Follow Flags
    • Holdouts Beta
    • Insights Charts Beta
    • Insights Deployments Beta
    • Insights Flag Events Beta
    • Insights Pull Requests Beta
    • Insights Repositories Beta
    • Insights Scores Beta
    • Integration Audit Log Subscriptions
    • Integration Delivery Configurations Beta
    • Integrations Beta
    • Layers
    • Metrics
    • Metrics Beta
    • OAuth2 Clients
    • Persistent Store Integrations Beta
    • Projects
    • Relay Proxy Configurations
    • Release Pipelines Beta
    • Releases Beta
    • Scheduled Changes
    • Segments
    • Tags
    • Teams
    • Teams Beta
    • Users
    • Users Beta
    • User Settings
    • Views Beta
    • Webhooks
    • Workflows
    • Workflow Templates
    • Other
Sign inTry it free
LogoLogo
REST API overviewFeature Flags

Update expiring context targets on feature flag

PATCH
/api/v2/flags/:projectKey/:featureFlagKey/expiring-targets/:environmentKey
PATCH
/api/v2/flags/:projectKey/:featureFlagKey/expiring-targets/:environmentKey
$curl -X PATCH https://app.launchdarkly.com/api/v2/flags/projectKey/featureFlagKey/expiring-targets/environmentKey \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "instructions": [
> {
> "kind": "addExpireUserTargetDate",
> "userKey": "sandy",
> "value": 1686412800000,
> "variationId": "ce12d345-a1b2-4fb5-a123-ab123d4d5f5d"
> }
> ]
>}'
1{
2 "items": [
3 {
4 "_id": "12ab3c45de678910abc12345",
5 "_version": 1,
6 "expirationDate": 1672358400000,
7 "contextKind": "user",
8 "contextKey": "context-key-123abc",
9 "_resourceId": {
10 "environmentKey": "environment-key-123abc",
11 "key": "segment-key-123abc",
12 "kind": "segment",
13 "projectKey": "project-key-123abc",
14 "flagKey": "string"
15 },
16 "targetType": "included",
17 "variationId": "cc4332e2-bd4d-4fe0-b509-dfd2caf8dd73"
18 }
19 ],
20 "_links": {},
21 "totalInstructions": 1,
22 "successfulInstructions": 1,
23 "failedInstructions": 1,
24 "errors": [
25 {
26 "instructionIndex": 1,
27 "message": "example error message"
28 }
29 ]
30}
Schedule a context for removal from individual targeting on a feature flag. The flag must already individually target the context. You can add, update, or remove a scheduled removal date. You can only schedule a context for removal on a single variation per flag. Updating an expiring target 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). ### Instructions Semantic patch requests support the following `kind` instructions for updating expiring targets. <details> <summary>Click to expand instructions for <strong>updating expiring targets</strong></summary> #### addExpiringTarget Adds a date and time that LaunchDarkly will remove the context from the flag's individual targeting. ##### Parameters * `value`: The time, in Unix milliseconds, when LaunchDarkly should remove the context from individual targeting for this flag * `variationId`: ID of a variation on the flag * `contextKey`: The context key for the context to remove from individual targeting * `contextKind`: The kind of context represented by the `contextKey` Here's an example: ```json { "instructions": [{ "kind": "addExpiringTarget", "value": 1754006460000, "variationId": "4254742c-71ae-411f-a992-43b18a51afe0", "contextKey": "user-key-123abc", "contextKind": "user" }] } ``` #### updateExpiringTarget Updates the date and time that LaunchDarkly will remove the context from the flag's individual targeting ##### Parameters * `value`: The time, in Unix milliseconds, when LaunchDarkly should remove the context from individual targeting for this flag * `variationId`: ID of a variation on the flag * `contextKey`: The context key for the context to remove from individual targeting * `contextKind`: The kind of context represented by the `contextKey` * `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", "value": 1754006460000, "variationId": "4254742c-71ae-411f-a992-43b18a51afe0", "contextKey": "user-key-123abc", "contextKind": "user" }] } ``` #### removeExpiringTarget Removes the scheduled removal of the context from the flag's individual targeting. The context will remain part of the flag's individual targeting until you explicitly remove it, or until you schedule another removal. ##### Parameters * `variationId`: ID of a variation on the flag * `contextKey`: The context key for the context to remove from individual targeting * `contextKind`: The kind of context represented by the `contextKey` Here's an example: ```json { "instructions": [{ "kind": "removeExpiringTarget", "variationId": "4254742c-71ae-411f-a992-43b18a51afe0", "contextKey": "user-key-123abc", "contextKind": "user" }] } ``` </details>
Was this page helpful?
Previous

Update expiring user targets on feature flag

Next
Built with

Schedule a context for removal from individual targeting on a feature flag. The flag must already individually target the context.

You can add, update, or remove a scheduled removal date. You can only schedule a context for removal on a single variation per flag.

Updating an expiring target 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.

Instructions

Semantic patch requests support the following kind instructions for updating expiring targets.

Click to expand instructions for updating expiring targets

addExpiringTarget

Adds a date and time that LaunchDarkly will remove the context from the flag’s individual targeting.

Parameters
  • value: The time, in Unix milliseconds, when LaunchDarkly should remove the context from individual targeting for this flag
  • variationId: ID of a variation on the flag
  • contextKey: The context key for the context to remove from individual targeting
  • contextKind: The kind of context represented by the contextKey

Here’s an example:

1{
2 "instructions": [{
3 "kind": "addExpiringTarget",
4 "value": 1754006460000,
5 "variationId": "4254742c-71ae-411f-a992-43b18a51afe0",
6 "contextKey": "user-key-123abc",
7 "contextKind": "user"
8 }]
9}

updateExpiringTarget

Updates the date and time that LaunchDarkly will remove the context from the flag’s individual targeting

Parameters
  • value: The time, in Unix milliseconds, when LaunchDarkly should remove the context from individual targeting for this flag
  • variationId: ID of a variation on the flag
  • contextKey: The context key for the context to remove from individual targeting
  • contextKind: The kind of context represented by the contextKey
  • 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:

1{
2 "instructions": [{
3 "kind": "updateExpiringTarget",
4 "value": 1754006460000,
5 "variationId": "4254742c-71ae-411f-a992-43b18a51afe0",
6 "contextKey": "user-key-123abc",
7 "contextKind": "user"
8 }]
9}

removeExpiringTarget

Removes the scheduled removal of the context from the flag’s individual targeting. The context will remain part of the flag’s individual targeting until you explicitly remove it, or until you schedule another removal.

Parameters
  • variationId: ID of a variation on the flag
  • contextKey: The context key for the context to remove from individual targeting
  • contextKind: The kind of context represented by the contextKey

Here’s an example:

1{
2 "instructions": [{
3 "kind": "removeExpiringTarget",
4 "variationId": "4254742c-71ae-411f-a992-43b18a51afe0",
5 "contextKey": "user-key-123abc",
6 "contextKind": "user"
7 }]
8}

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
environmentKeystringRequiredformat: "string"
The environment key
featureFlagKeystringRequiredformat: "string"
The feature flag key

Request

This endpoint expects an object.
instructionslist of maps from strings to anyRequired
The instructions to perform when updating
commentstringOptional
Optional comment describing the change

Response

Expiring target response
itemslist of objects
A list of the results from each instruction
_linksmap from strings to objects
The location and content type of related resources
totalInstructionsinteger
successfulInstructionsinteger
failedInstructionsinteger
errorslist of objects

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error