Create a cross-project Holdout
1 min
POST
https://api.optimizely.com/flags/v1//holdouts
acceptstringGenerated from available response content types
bodyobject<p>Request body schema for creating or updating a holdout.</p>
<p>Holdouts are experiments that reserve a portion of your traffic to measure the impact of your feature flags and experiments. They help establish a control group by excluding a percentage of users from seeing any experiments, allowing you to measure the overall impact of your experimentation program.</p>
<p><strong>NOTE:</strong> This schema is shared between two endpoints with different validation rules:</p>
<ul>
<li><strong>POST /projects/{project_id}/holdouts</strong>: <code>project_id</code>, <code>project_ids</code>, and <code>rule_ids</code> from the body are ignored (project comes from URL)</li>
<li><strong>POST /holdouts</strong>: <code>project_id</code> is required in the body, plus either <code>project_ids</code> (global) or <code>rule_ids</code> (local)</li>
</ul>
<p>These constraints are enforced at runtime by the API, not by OpenAPI schema validation.</p>
201<p>Successful retrieval, creation or update of a Holdout.</p>
<p>The response includes RESTful JSON (<a href="https://restfuljson.org/" target="_blank">https://restfuljson.org/</a>) styled links. If a
link is not present in the response, it indicates a user is not authorized to access
the related resource.</p>
400<p>Bad Request - Invalid input data or validation failure.</p>
<p>Common causes:</p>
<ul>
<li>Missing <code>project_id</code> (required for cross-project creates)</li>
<li>Global scope: <code>project_id</code> not in <code>project_ids</code></li>
<li>Local scope: <code>project_id</code> doesn't own any of the specified <code>rule_ids</code></li>
<li>Global holdout missing <code>project_ids</code></li>
<li>Local holdout missing <code>rule_ids</code></li>
<li>Global holdout with <code>rule_ids</code> (not allowed)</li>
<li>Invalid scope value</li>
<li>Duplicate holdout key</li>
<li>Rule not found</li>
<li><code>audience_conditions</code> set on a holdout whose targeted rules span more than one project</li>
</ul>
401Invalid credentials
403Do not have permission to perform the operation
curl --request POST \
--url https://api.optimizely.com/flags/v1//holdouts \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"key": "annual_growth_holdout",
"metrics": [
{
"aggregator": "",
"event_properties": {
"filter": {
"conditions": [
{
"name": "",
"operator": "",
"type": "",
"value": ""
}
]
}
},
"winning_direction": ""
}
],
"name": "Annual Growth Control Group",
"scope": "global"
}'