Skip to content

Save a new segment

POST
/api/v1/workspaces/{workspace}/segments
curl --request POST \
--url https://reputecast.example.com/api/v1/workspaces/acme-newsletter/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "definition": { "groups": [ { "conditions": [ { "amount": 1, "field": "example", "op": "example", "to": "example", "unit": "days", "value": "example" } ], "match": "all" } ] }, "description": "example", "mode": "builder", "name": "example", "refresh": "dynamic", "sql": "example" }'

Permission: segments:edit

workspace
required

Workspace slug

string
/^[a-z0-9][a-z0-9-]{1,62}$/

Workspace slug

Media typeapplication/json
object
definition
object
groups
required
Array<object>
object
conditions
required
Array<object>
object
amount
integer format: int64
<= 3650
field
required
string
<= 80 characters
op
required
string
<= 20 characters
to
string
<= 20 characters
unit
string
Allowed values: days weeks
value
string
<= 500 characters
match
required

All = every condition, any = at least one

string
Allowed values: all any
description
string
<= 500 characters
mode
required
string
Allowed values: builder sql
name
string
<= 120 characters
refresh
string
Allowed values: dynamic static
sql
string
<= 20000 characters

Created

Media typeapplication/json
object
count
integer format: int64
countMs
integer format: int32
countedAt
string format: date-time
definition
object
groups
required
Array<object>
object
conditions
required
Array<object>
object
amount
integer format: int64
<= 3650
field
required
string
<= 80 characters
op
required
string
<= 20 characters
to
string
<= 20 characters
unit
string
Allowed values: days weeks
value
string
<= 500 characters
match
required

All = every condition, any = at least one

string
Allowed values: all any
description
required
string
generatedSql
required
string
id
required
string
mode
required
string
Allowed values: builder sql
name
required
string
refresh
required
string
Allowed values: dynamic static
sql
required
string
tiers
required
object
active
required
integer format: int64
atRisk
required
integer format: int64
cooling
required
integer format: int64
sunset
required
integer format: int64
updatedAt
required
string format: date-time
updatedBy
required
string

Example

{
"definition": {
"groups": [
{
"conditions": [
{
"unit": "days"
}
],
"match": "all"
}
]
},
"mode": "builder",
"refresh": "dynamic"
}

Error

Media typeapplication/problem+json
object
code

Stable error code, e.g. permission_denied

string
detail

A human-readable explanation specific to this occurrence of the problem.

string
errors

Optional list of individual error details

Array<object>
object
location

Where the error occurred, e.g. ‘body.items[3].tags’ or ‘path.thing-id’

string
message

Error message text

string
value

The value at the given location

helpers

Members who hold the missing permission

Array<string>
instance

A URI reference that identifies the specific occurrence of the problem.

string format: uri
meta
object
key
additional properties
permission

The missing permission key

string
status

HTTP status code

integer format: int64
title

A short, human-readable summary of the problem type. This value should not change between occurrences of the error.

string
type

A URI reference to human-readable documentation for the error.

string format: uri
default: about:blank

Example

{
"detail": "Property foo is required but is missing.",
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "about:blank"
}