Segments

Create segment

POST
/api/v2/segments/{projectKey}/{environmentKey}

Create a new segment.

Authorization

ApiKey read, write
Authorization<token>

In: header

Scope: read, write

Path Parameters

projectKey*string

The project key

Formatstring
environmentKey*string

The environment key

Formatstring

Request Body

application/json

name*string

A human-friendly name for the segment

key*string

A unique key used to reference the segment

description?string

A description of the segment's purpose

tags?array<string>

Tags for the segment

unbounded?boolean

Whether to create a standard segment (false) or a big segment (true). Standard segments include rule-based and smaller list-based segments. Big segments include larger list-based segments and synced segments. Only use a big segment if you need to add more than 15,000 individual targets.

unboundedContextKind?string

For big segments, the targeted context kind.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/v2/segments/string/string" \  -H "Content-Type: application/json" \  -d '{    "name": "Example segment",    "key": "segment-key-123abc"  }'
{  "name": "Example segment",  "description": "Bundle our sample customers together",  "tags": [    "testing"  ],  "creationDate": "1654104600000",  "lastModifiedDate": "1654104600000",  "key": "segment-key-123abc",  "included": [    "user-key-123abc"  ],  "excluded": [    "user-key-123abc"  ],  "includedContexts": [    {      "values": [        "string"      ],      "contextKind": "string"    }  ],  "excludedContexts": [    {      "values": [        "string"      ],      "contextKind": "string"    }  ],  "_links": {    "property1": {      "href": "string",      "type": "string"    },    "property2": {      "href": "string",      "type": "string"    }  },  "rules": [    {      "_id": "1234a56b7c89d012345e678f",      "clauses": [        {          "_id": "12ab3c45de678910fab12345",          "attribute": "email",          "negate": false,          "op": "endsWith",          "values": [            ".edu"          ]        }      ]    }  ],  "version": 1,  "deleted": false,  "_access": {    "denied": [      {        "action": "string",        "reason": {          "resources": [            "proj/*:env/*;qa_*:/flag/*"          ],          "notResources": [            "string"          ],          "actions": [            "*"          ],          "notActions": [            "string"          ],          "effect": "allow",          "role_name": "string"        }      }    ],    "allowed": [      {        "action": "string",        "reason": {          "resources": [            "proj/*:env/*;qa_*:/flag/*"          ],          "notResources": [            "string"          ],          "actions": [            "*"          ],          "notActions": [            "string"          ],          "effect": "allow",          "role_name": "string"        }      }    ]  },  "_flags": [    {      "name": "Example flag",      "key": "flag-key-123abc",      "_links": {        "property1": {          "href": "string",          "type": "string"        },        "property2": {          "href": "string",          "type": "string"        }      },      "_site": {        "href": "string",        "type": "string"      }    }  ],  "unbounded": false,  "unboundedContextKind": "string",  "generation": 0,  "_unboundedMetadata": {    "envId": "string",    "segmentId": "string",    "version": 0,    "includedCount": 0,    "excludedCount": 0,    "lastModified": 0,    "deleted": true  },  "_external": "amplitude",  "_externalLink": "https://analytics.amplitude.com/org/1234/cohort/123abc",  "_importInProgress": false}

List segments GET

Get a list of all segments in the given project. Segments can be rule-based, list-based, or synced. Big segments include larger list-based segments and synced segments. Some fields in the response only apply to big segments. ### Filtering segments The `filter` parameter supports the following operators: `equals`, `anyOf`, and `exists`. You can also combine filters in the following ways: - Use a comma (`,`) as an AND operator - Use a vertical bar (`|`) as an OR operator - Use parentheses (`()`) to group filters #### Supported fields and operators You can only filter certain fields in segments when using the `filter` parameter. Additionally, you can only filter some fields with certain operators. When you search for segments, the `filter` parameter supports the following fields and operators: |<div style="width:120px">Field</div> |Description |Supported operators | |---|---|---| | `excludedKeys` | The segment keys of segments to exclude from the results. | `anyOf` | | `external` | Whether the segment is a synced segment. | `exists` | | `includedKeys` | The segment keys of segments to include in the results. | `anyOf` | | `query` | A "fuzzy" search across segment key, name, and description. Supply a string or list of strings to the operator. | `equals` | | `tags` | The segment tags. | `anyOf` | | `unbounded` | Whether the segment is a standard segment (`false`) or a big segment (`true`). Standard segments include rule-based segments and smaller list-based segments. Big segments include larger list-based segments and synced segments. | `equals` | Here are a few examples: * The filter `?filter=tags anyOf ["enterprise", "beta"],query equals "toggle"` matches segments with "toggle" in their key, name, or description that also have "enterprise" or "beta" as a tag. * The filter `?filter=excludedKeys anyOf ["segmentKey1", "segmentKey2"]` excludes the segments with those keys from the results. * The filter `?filter=unbounded equals true` matches larger list-based segments and synced segments. The documented values for `filter` query parameters are prior to URL encoding. For example, the `[` in `?filter=tags anyOf ["enterprise", "beta"]` must be encoded to `%5B`.

Get segment GET

Get a single segment by key.<br/><br/>Segments can be rule-based, list-based, or synced. Big segments include larger list-based segments and synced segments. Some fields in the response only apply to big segments.