CreateSegment - CloudWatch Evidently

CreateSegment

Use this operation to define a segment of your audience. A segment is a portion of your audience that share one or more characteristics. Examples could be Chrome browser users, users in Europe, or Firefox browser users in Europe who also fit other criteria that your application collects, such as age.

Using a segment in an experiment limits that experiment to evaluate only the users who match the segment criteria. Using one or more segments in a launch allows you to define different traffic splits for the different audience segments.

For more information about segment pattern syntax, see Segment rule pattern syntax.

The pattern that you define for a segment is matched against the value of evaluationContext, which is passed into Evidently in the EvaluateFeature operation, when Evidently assigns a feature variation to a user.

Request Syntax

POST /segments HTTP/1.1 Content-type: application/json { "description": "string", "name": "string", "pattern": "string", "tags": { "string" : "string" } }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

description

An optional description for this segment.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 160.

Pattern: .*

Required: No

name

A name for the segment.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: ^[-a-zA-Z0-9._]*$

Required: Yes

pattern

The pattern to use for the segment. For more information about pattern syntax, see Segment rule pattern syntax.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Required: Yes

tags

Assigns one or more tags (key-value pairs) to the segment.

Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values.

Tags don't have any semantic meaning to AWS and are interpreted strictly as strings of characters.

You can associate as many as 50 tags with a segment.

For more information, see Tagging AWS resources.

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Key Pattern: ^(?!aws:)[a-zA-Z+-=._:/]+$

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Required: No

Response Syntax

HTTP/1.1 200 Content-type: application/json { "segment": { "arn": "string", "createdTime": number, "description": "string", "experimentCount": number, "lastUpdatedTime": number, "launchCount": number, "name": "string", "pattern": "string", "tags": { "string" : "string" } } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

segment

A structure that contains the complete information about the segment that was just created.

Type: Segment object

Errors

For information about the errors that are common to all actions, see Common Errors.

AccessDeniedException

You do not have sufficient permissions to perform this action.

HTTP Status Code: 403

ConflictException

A resource was in an inconsistent state during an update or a deletion.

HTTP Status Code: 409

ServiceQuotaExceededException

The request would cause a service quota to be exceeded.

HTTP Status Code: 402

ValidationException

The value of a parameter in the request caused an error.

HTTP Status Code: 400

Examples

Example

The following example creates a segment that matches users in Europe using the Firefox browser.

{ "description": "An example segment", "name": "Firefox users in Europe", "pattern": "{ \"Browser\": [\"Firefox\"], \"Location\": [\"Europe\"] }" }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: