TypeScript
import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
domain: "{YOUR_DOMAIN}",
token: "<token>",
});
await client.experimentation.segments.create({
name: "name",
rules: [
{},
],
});
}
main();import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
domain: "{YOUR_DOMAIN}",
token: "<token>",
});
await client.experimentation.segments.create({
name: "name",
rules: [
{},
],
});
}
main();
package example
import (
context "context"
management "github.com/auth0/go-auth0/v3/management"
client "github.com/auth0/go-auth0/v3/management/client"
option "github.com/auth0/go-auth0/v3/management/option"
)
func do() {
mgmt, err := client.New(
"{YOUR_DOMAIN}",
option.WithToken(
"<token>",
),
)
if err != nil {
return
}
request := &management.CreateSegmentRequestContent{
Name: "name",
Rules: []*management.SegmentRule{
&management.SegmentRule{},
},
}
mgmt.Experimentation.Segments.Create(
context.TODO(),
request,
)
}
# Ensure you're logged in: auth0 login
auth0 api post "experimentation/segments" --data '{
"name": "name",
"rules": [
{}
]
}'using Auth0.ManagementApi;
using System.Threading.Tasks;
using Auth0.ManagementApi.Experimentation;
using System.Collections.Generic;
public partial class Examples
{
public async Task Example() {
var client = new ManagementApiClient(
token: "<token>",
clientOptions: new ClientOptions { BaseUrl = "https://{YOUR_DOMAIN}/api/v2" }
);
await client.Experimentation.Segments.CreateAsync(
new CreateSegmentRequestContent {
Name = "name",
Rules = new List<SegmentRule>(){
new SegmentRule(),
}
}
);
}
}
package com.example.usage;
import com.auth0.client.mgmt.ManagementApi;
import com.auth0.client.mgmt.experimentation.types.CreateSegmentRequestContent;
import com.auth0.client.mgmt.types.SegmentRule;
import java.util.Arrays;
public class Example {
public static void main(String[] args) {
ManagementApi client = ManagementApi
.builder()
.domain("{YOUR_DOMAIN}")
.token("<token>")
.build();
client.experimentation().segments().create(
CreateSegmentRequestContent
.builder()
.name("name")
.rules(
Arrays.asList(
SegmentRule
.builder()
.build()
)
)
.build()
);
}
}<?php
namespace Example;
use Auth0\SDK\API\Management\Wrapper\ManagementClient;
use Auth0\SDK\API\Management\Wrapper\ManagementClientOptions;
use Auth0\SDK\API\Management\Experimentation\Segments\Requests\CreateSegmentRequestContent;
use Auth0\SDK\API\Management\Types\SegmentRule;
$client = new ManagementClient(new ManagementClientOptions(
domain: '{YOUR_DOMAIN}',
token: '<token>',
));
$client->experimentation->segments->create(
new CreateSegmentRequestContent([
'name' => 'name',
'rules' => [
new SegmentRule([]),
],
]),
);
from auth0.management import ManagementClient, SegmentRule
client = ManagementClient(
domain="{YOUR_DOMAIN}",
token="<token>",
)
client.experimentation.segments.create(
name="name",
rules=[
SegmentRule()
],
)
require "auth0"
client = Auth0::Management.new(token: "<token>", base_url: "https://{YOUR_DOMAIN}/api/v2")
client.experimentation.segments.create(
name: "name",
rules: [{}]
)
curl --request POST \
--url https://{tenantDomain}/api/v2/experimentation/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"rules": [
{
"match": {
"client_id": [
"<string>"
],
"connection": [
"<string>"
],
"connection_type": [
"<string>"
],
"organization_id": [
"<string>"
],
"domain": [
"<string>"
],
"device_type": [
"<string>"
],
"browser": [
"<string>"
],
"platform": [
"<string>"
],
"user_agent": [
"<string>"
],
"country": [
"<string>"
],
"region": [
"<string>"
]
},
"not_match": {
"client_id": [
"<string>"
],
"connection": [
"<string>"
],
"connection_type": [
"<string>"
],
"organization_id": [
"<string>"
],
"domain": [
"<string>"
],
"device_type": [
"<string>"
],
"browser": [
"<string>"
],
"platform": [
"<string>"
],
"user_agent": [
"<string>"
],
"country": [
"<string>"
],
"region": [
"<string>"
]
}
}
],
"description": "<string>"
}
'{
"id": "<string>",
"name": "<string>",
"type": "self",
"status": "active",
"rules": [
{
"match": {
"client_id": [
"<string>"
],
"connection": [
"<string>"
],
"connection_type": [
"<string>"
],
"organization_id": [
"<string>"
],
"domain": [
"<string>"
],
"device_type": [
"<string>"
],
"browser": [
"<string>"
],
"platform": [
"<string>"
],
"user_agent": [
"<string>"
],
"country": [
"<string>"
],
"region": [
"<string>"
]
},
"not_match": {
"client_id": [
"<string>"
],
"connection": [
"<string>"
],
"connection_type": [
"<string>"
],
"organization_id": [
"<string>"
],
"domain": [
"<string>"
],
"device_type": [
"<string>"
],
"browser": [
"<string>"
],
"platform": [
"<string>"
],
"user_agent": [
"<string>"
],
"country": [
"<string>"
],
"region": [
"<string>"
]
}
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"description": "<string>"
}Create a segment for the Experiment Center.
Create a new segment with rule-based membership criteria for use in experiments.
POST
https://{tenantDomain}/api/v2
/
experimentation
/
segments
TypeScript
import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
domain: "{YOUR_DOMAIN}",
token: "<token>",
});
await client.experimentation.segments.create({
name: "name",
rules: [
{},
],
});
}
main();import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
domain: "{YOUR_DOMAIN}",
token: "<token>",
});
await client.experimentation.segments.create({
name: "name",
rules: [
{},
],
});
}
main();
package example
import (
context "context"
management "github.com/auth0/go-auth0/v3/management"
client "github.com/auth0/go-auth0/v3/management/client"
option "github.com/auth0/go-auth0/v3/management/option"
)
func do() {
mgmt, err := client.New(
"{YOUR_DOMAIN}",
option.WithToken(
"<token>",
),
)
if err != nil {
return
}
request := &management.CreateSegmentRequestContent{
Name: "name",
Rules: []*management.SegmentRule{
&management.SegmentRule{},
},
}
mgmt.Experimentation.Segments.Create(
context.TODO(),
request,
)
}
# Ensure you're logged in: auth0 login
auth0 api post "experimentation/segments" --data '{
"name": "name",
"rules": [
{}
]
}'using Auth0.ManagementApi;
using System.Threading.Tasks;
using Auth0.ManagementApi.Experimentation;
using System.Collections.Generic;
public partial class Examples
{
public async Task Example() {
var client = new ManagementApiClient(
token: "<token>",
clientOptions: new ClientOptions { BaseUrl = "https://{YOUR_DOMAIN}/api/v2" }
);
await client.Experimentation.Segments.CreateAsync(
new CreateSegmentRequestContent {
Name = "name",
Rules = new List<SegmentRule>(){
new SegmentRule(),
}
}
);
}
}
package com.example.usage;
import com.auth0.client.mgmt.ManagementApi;
import com.auth0.client.mgmt.experimentation.types.CreateSegmentRequestContent;
import com.auth0.client.mgmt.types.SegmentRule;
import java.util.Arrays;
public class Example {
public static void main(String[] args) {
ManagementApi client = ManagementApi
.builder()
.domain("{YOUR_DOMAIN}")
.token("<token>")
.build();
client.experimentation().segments().create(
CreateSegmentRequestContent
.builder()
.name("name")
.rules(
Arrays.asList(
SegmentRule
.builder()
.build()
)
)
.build()
);
}
}<?php
namespace Example;
use Auth0\SDK\API\Management\Wrapper\ManagementClient;
use Auth0\SDK\API\Management\Wrapper\ManagementClientOptions;
use Auth0\SDK\API\Management\Experimentation\Segments\Requests\CreateSegmentRequestContent;
use Auth0\SDK\API\Management\Types\SegmentRule;
$client = new ManagementClient(new ManagementClientOptions(
domain: '{YOUR_DOMAIN}',
token: '<token>',
));
$client->experimentation->segments->create(
new CreateSegmentRequestContent([
'name' => 'name',
'rules' => [
new SegmentRule([]),
],
]),
);
from auth0.management import ManagementClient, SegmentRule
client = ManagementClient(
domain="{YOUR_DOMAIN}",
token="<token>",
)
client.experimentation.segments.create(
name="name",
rules=[
SegmentRule()
],
)
require "auth0"
client = Auth0::Management.new(token: "<token>", base_url: "https://{YOUR_DOMAIN}/api/v2")
client.experimentation.segments.create(
name: "name",
rules: [{}]
)
curl --request POST \
--url https://{tenantDomain}/api/v2/experimentation/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"rules": [
{
"match": {
"client_id": [
"<string>"
],
"connection": [
"<string>"
],
"connection_type": [
"<string>"
],
"organization_id": [
"<string>"
],
"domain": [
"<string>"
],
"device_type": [
"<string>"
],
"browser": [
"<string>"
],
"platform": [
"<string>"
],
"user_agent": [
"<string>"
],
"country": [
"<string>"
],
"region": [
"<string>"
]
},
"not_match": {
"client_id": [
"<string>"
],
"connection": [
"<string>"
],
"connection_type": [
"<string>"
],
"organization_id": [
"<string>"
],
"domain": [
"<string>"
],
"device_type": [
"<string>"
],
"browser": [
"<string>"
],
"platform": [
"<string>"
],
"user_agent": [
"<string>"
],
"country": [
"<string>"
],
"region": [
"<string>"
]
}
}
],
"description": "<string>"
}
'{
"id": "<string>",
"name": "<string>",
"type": "self",
"status": "active",
"rules": [
{
"match": {
"client_id": [
"<string>"
],
"connection": [
"<string>"
],
"connection_type": [
"<string>"
],
"organization_id": [
"<string>"
],
"domain": [
"<string>"
],
"device_type": [
"<string>"
],
"browser": [
"<string>"
],
"platform": [
"<string>"
],
"user_agent": [
"<string>"
],
"country": [
"<string>"
],
"region": [
"<string>"
]
},
"not_match": {
"client_id": [
"<string>"
],
"connection": [
"<string>"
],
"connection_type": [
"<string>"
],
"organization_id": [
"<string>"
],
"domain": [
"<string>"
],
"device_type": [
"<string>"
],
"browser": [
"<string>"
],
"platform": [
"<string>"
],
"user_agent": [
"<string>"
],
"country": [
"<string>"
],
"region": [
"<string>"
]
}
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"description": "<string>"
}Authorizations
bearerAuthoAuth2ClientCredentials
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/jsonapplication/x-www-form-urlencoded
Create a segment for experiment targeting
A human-readable name for the segment
Required string length:
3 - 255Pattern:
^(?!.*\x00)\S(.*\S)?$An ordered list of rules. A segment matches if any rule matches. Each rule is limited to 4KB and the whole segment to 10KB (serialized).
Minimum array length:
1Show child attributes
Show child attributes
A description of the segment
Required string length:
3 - 1024Pattern:
^(?!.*\x00)\S(.*\S)?$Response
Segment successfully created.
Pattern:
^seg_[A-HJ-NP-Za-km-z1-9]+$Available options:
self, auth0 Available options:
active, archived Show child attributes
Show child attributes