Skip to content

Segments_update

PUT
/segments/{id}
curl --request PUT \
--url http://localhost:3000/api/segments/example \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "name": "example", "definition": { "kind": "group", "combinator": "and", "not": true, "rules": [ { "kind": "rule", "field": "example", "operator": "eq", "value": "example" } ] } }'

Update a resource

id
required

A primary key, written as a decimal string so JavaScript never rounds it. The format makes the Go servers parse it into an int64: a malformed id is refused as a 400 before a handler runs. The pattern says the same in the contract, so a client (or a fuzzer) can tell a malformed id from a valid one without trying it. Eighteen digits is the most a key reaches, so every id the schema admits fits an int64.

string format: int64
/^[0-9]{1,18}$/

Unique identifier

Media typeapplication/json

Request body for updating a segment

object
name

Segment name

string
definition

Segment definition: the rule group; an empty group matches all contacts

object
kind
required
string
Allowed values: group
combinator
required

How the rules combine

string
Allowed values: and or
not

Negate the whole group

boolean
rules
required

The group’s rules and nested groups

Array<object>
One of: discriminator: kind

One condition of a segment: a field, an operator and a value

object
kind
required
string
Allowed values: rule
field
required

What it tests: a contact attribute (email, phone, subject_id, first_name, last_name, time_zone), “tag”, “custom:” for a custom field of the workspace, or “event:”

string
operator
required

How the field is tested

string
Allowed values: eq neq contains beginsWith null notNull performed notPerformed has doesNotHave
value

The value to test against: a tag name, a day window for events (“” = ever), blank for null and notNull

string

The request has succeeded.

Media typeapplication/json

Segment resource

object
id
required

Unique identifier

string format: int64
/^[0-9]{1,18}$/
name
required

Segment name

string
definition

Segment definition: the rule group; an empty group matches all contacts

object
kind
required
string
Allowed values: group
combinator
required

How the rules combine

string
Allowed values: and or
not

Negate the whole group

boolean
rules
required

The group’s rules and nested groups

Array<object>
One of: discriminator: kind

One condition of a segment: a field, an operator and a value

object
kind
required
string
Allowed values: rule
field
required

What it tests: a contact attribute (email, phone, subject_id, first_name, last_name, time_zone), “tag”, “custom:” for a custom field of the workspace, or “event:”

string
operator
required

How the field is tested

string
Allowed values: eq neq contains beginsWith null notNull performed notPerformed has doesNotHave
value

The value to test against: a tag name, a day window for events (“” = ever), blank for null and notNull

string
createdAt
required

Creation timestamp

string format: date-time
updatedAt
required

Last update timestamp

string format: date-time

Example

{
"definition": {
"kind": "group",
"combinator": "and",
"rules": [
{
"kind": "rule",
"operator": "eq"
}
]
}
}

RFC 7807 bad request response

Media typeapplication/problem+json

RFC 7807 Problem Details

object
code

Why the request was refused, when the client should act on it

string
Allowed values: second_factor_required email_verification_required signup_closed
type

A URI reference that identifies the problem type

string
title

A short, human-readable summary of the problem type

string
status

HTTP status code

integer format: int32
detail

A human-readable explanation specific to this occurrence

string
instance

A URI reference that identifies the specific occurrence

string
errors

Validation errors grouped by field

object
key
additional properties
Array<string>
form

Form-level validation error

string
fields

Field validation errors

object
key
additional properties
string
retryAfter

Seconds to wait before retrying; set on a 429 so a client that only sees the body can show the wait

integer format: int32
debug

Why a 500 happened, sent only by a development server (SPHERICON_ENV=development)

object
error
required

The error that failed the request, or the panic value

string
stack

The goroutine stack of a panic; absent for an error a handler returned

string
requestId

The request id the server log carries for this request

string
method
required

The HTTP method of the failed request

string
path
required

The path of the failed request

string

Example

{
"code": "second_factor_required"
}

RFC 7807 unauthorized response

Media typeapplication/problem+json

RFC 7807 Problem Details

object
code

Why the request was refused, when the client should act on it

string
Allowed values: second_factor_required email_verification_required signup_closed
type

A URI reference that identifies the problem type

string
title

A short, human-readable summary of the problem type

string
status

HTTP status code

integer format: int32
detail

A human-readable explanation specific to this occurrence

string
instance

A URI reference that identifies the specific occurrence

string
errors

Validation errors grouped by field

object
key
additional properties
Array<string>
form

Form-level validation error

string
fields

Field validation errors

object
key
additional properties
string
retryAfter

Seconds to wait before retrying; set on a 429 so a client that only sees the body can show the wait

integer format: int32
debug

Why a 500 happened, sent only by a development server (SPHERICON_ENV=development)

object
error
required

The error that failed the request, or the panic value

string
stack

The goroutine stack of a panic; absent for an error a handler returned

string
requestId

The request id the server log carries for this request

string
method
required

The HTTP method of the failed request

string
path
required

The path of the failed request

string

Example

{
"code": "second_factor_required"
}

RFC 7807 not found response

Media typeapplication/problem+json

RFC 7807 Problem Details

object
code

Why the request was refused, when the client should act on it

string
Allowed values: second_factor_required email_verification_required signup_closed
type

A URI reference that identifies the problem type

string
title

A short, human-readable summary of the problem type

string
status

HTTP status code

integer format: int32
detail

A human-readable explanation specific to this occurrence

string
instance

A URI reference that identifies the specific occurrence

string
errors

Validation errors grouped by field

object
key
additional properties
Array<string>
form

Form-level validation error

string
fields

Field validation errors

object
key
additional properties
string
retryAfter

Seconds to wait before retrying; set on a 429 so a client that only sees the body can show the wait

integer format: int32
debug

Why a 500 happened, sent only by a development server (SPHERICON_ENV=development)

object
error
required

The error that failed the request, or the panic value

string
stack

The goroutine stack of a panic; absent for an error a handler returned

string
requestId

The request id the server log carries for this request

string
method
required

The HTTP method of the failed request

string
path
required

The path of the failed request

string

Example

{
"code": "second_factor_required"
}

RFC 7807 validation response

Media typeapplication/problem+json

RFC 7807 Problem Details

object
code

Why the request was refused, when the client should act on it

string
Allowed values: second_factor_required email_verification_required signup_closed
type

A URI reference that identifies the problem type

string
title

A short, human-readable summary of the problem type

string
status

HTTP status code

integer format: int32
detail

A human-readable explanation specific to this occurrence

string
instance

A URI reference that identifies the specific occurrence

string
errors

Validation errors grouped by field

object
key
additional properties
Array<string>
form

Form-level validation error

string
fields

Field validation errors

object
key
additional properties
string
retryAfter

Seconds to wait before retrying; set on a 429 so a client that only sees the body can show the wait

integer format: int32
debug

Why a 500 happened, sent only by a development server (SPHERICON_ENV=development)

object
error
required

The error that failed the request, or the panic value

string
stack

The goroutine stack of a panic; absent for an error a handler returned

string
requestId

The request id the server log carries for this request

string
method
required

The HTTP method of the failed request

string
path
required

The path of the failed request

string

Example

{
"code": "second_factor_required"
}

RFC 7807 too many requests response: a rate limit was exceeded (ADR 0025)

Media typeapplication/problem+json

RFC 7807 Problem Details

object
code

Why the request was refused, when the client should act on it

string
Allowed values: second_factor_required email_verification_required signup_closed
type

A URI reference that identifies the problem type

string
title

A short, human-readable summary of the problem type

string
status

HTTP status code

integer format: int32
detail

A human-readable explanation specific to this occurrence

string
instance

A URI reference that identifies the specific occurrence

string
errors

Validation errors grouped by field

object
key
additional properties
Array<string>
form

Form-level validation error

string
fields

Field validation errors

object
key
additional properties
string
retryAfter

Seconds to wait before retrying; set on a 429 so a client that only sees the body can show the wait

integer format: int32
debug

Why a 500 happened, sent only by a development server (SPHERICON_ENV=development)

object
error
required

The error that failed the request, or the panic value

string
stack

The goroutine stack of a panic; absent for an error a handler returned

string
requestId

The request id the server log carries for this request

string
method
required

The HTTP method of the failed request

string
path
required

The path of the failed request

string

Example

{
"code": "second_factor_required"
}
Retry-After
required
integer format: int32

Seconds to wait before retrying

X-RateLimit-Limit
required
integer format: int32

The request budget of the window that was exceeded

X-RateLimit-Remaining
required
integer format: int32

Requests left in the current window

X-RateLimit-Reset
required
integer format: int64

Unix time at which the window resets