Skip to main content
POST
Create an attribute definition

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

projectId
string
required

Project ID

Body

application/json
scope
enum<string>
required

Which object the attribute belongs to: user, company, companyMembership, or eventDefinition (an event attribute — pre-defines an event property; attach it to events via the event-definitions surface. Tracking also auto-registers event properties at ingestion, so pre-defining is only needed to pin the type or attach before the first track).

Available options:
user,
company,
companyMembership,
eventDefinition
dataType
enum<string>
required

The attribute value type. random_ab / random_number (user and company scope only) are assigned by Usertour per entity, stable for life, and cannot be written.

Available options:
number,
string,
boolean,
list,
datetime,
random_ab,
random_number
codeName
string
required

Stable identifier, unique per project + scope. Immutable. Must start with a letter, then letters/digits/underscores, 2–100 chars.

Required string length: 2 - 100
Pattern: ^[a-zA-Z][a-zA-Z0-9_]*$
displayName
string
required

Human-readable name.

Minimum string length: 1
randomMax
integer

Required for random_number: values are assigned in 1..randomMax. Ignored for other types. Locked after creation.

Required range: 2 <= x <= 10000
description
string

Optional description.

Response

Attribute definition created — or, when a deleted attribute holds this scope and codeName, that one restored

id
string
required
object
enum<string>
required
Available options:
attributeDefinition
predefined
boolean
required

Built-in attribute shipped by Usertour: it cannot be edited or deleted.

createdAt
string<date-time>
required
dataType
enum<string>
required

Value type. random_ab / random_number are SYSTEM-GENERATED bucketing types: each user (or company) is assigned a stable value — A/B, or an integer in [1, randomMax] — for A/B tests and canary rollouts. Their values cannot be written; their type and range are locked after creation.

Available options:
number,
string,
boolean,
list,
datetime,
random_ab,
random_number
randomMax
integer | null
required

Upper bound of a random_number attribute (values are 1..randomMax); null otherwise.

Required range: -9007199254740991 <= x <= 9007199254740991
description
string
required
displayName
string
required
codeName
string
required
scope
enum<string>
required

Which object the attribute belongs to. eventDefinition = an event attribute (attach it to events via the event-definitions surface).

Available options:
user,
company,
companyMembership,
eventDefinition