Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this page
Looking for more inspiration?Visit the

Type matching


Supported data types

supported-data-types page anchor

Twilio Cohorts filter criteria accept the following primitive types:

TypeDescriptionExample
stringText value"hello", "US"
integerWhole number (64-bit signed)0, 25, -1
floatFloating-point number (64-bit double)3.14, -0.5
booleanBoolean valuetrue, false
timestampDate-time valuetimestamp("2026-01-01T00:00:00Z")
durationTime durationduration("24h"), duration("30m")

Operands must match type

operands-must-match-type page anchor

When you combine two values in filter criteria, both sides generally need to be the same type.

Comparison operators

comparison-operators page anchor
OperatorAllowed operand types
==, !=Any type, provided that both operands are the same type — except for integer and float, which are numerically coerced when compared.
<, <=, >, >=integer, float, string, timestamp, or duration. Both operands must be the same type — except for integer and float, which are numerically coerced when compared.
profile.trait.Account.age > 18

age and 18 are both numbers, so this comparison is valid. Comparing a string-typed trait to an integer literal, or a timestamp to a string, is invalid and causes an evaluation failure.

OperatorAllowed operand types
+integer + integer, float + float, string + string (concatenation), or timestamp + duration.
-integer - integer, float - float, timestamp - duration, or timestamp - timestamp.
*, /integer * integer, float * float, integer / integer, or float / float.
%integer % integer only.

Mixed types, such as a string plus an integer, are invalid.

The left-hand value's type must be compatible with the type of the elements in the list on the right.

profile.trait.Contact.country in ["US", "FR", "DE"]

Comparing a string-typed trait to a list of integers is invalid.

Conditional (ternary)

conditional-ternary page anchor

Both branches of a ?: expression must evaluate to compatible types.

profile.trait.Metrics.score > 0 ? profile.trait.Metrics.score : 0

Here, both branches resolve to a number. Returning a number from one branch and a string from the other is invalid.


Type mismatches are rejected, not silently excluded

type-mismatches-are-rejected-not-silently-excluded page anchor

A type mismatch behaves differently from a missing trait. A missing trait evaluates to false and quietly excludes the profile. A type mismatch fails validation when you create or update a cohort or create a snapshot from inline criteria. In those cases, the request is rejected with an HTTP 400 Bad Request error.


Reconciling mismatched types

reconciling-mismatched-types page anchor

If you need to combine or compare values of different types, convert one of them explicitly by using a type-conversion function such as string(), int(), or double().

string(profile.trait.Account.age) == "18"

  • Review the available functions, including type conversion.
  • Learn about null handling for missing traits.