---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/cohorts/cel/functions#article
headline: Functions
description: Reference for the functions and list operations available in Twilio Cohorts filter criteria.
url: https://www.twilio.com/docs/cohorts/cel/functions
inLanguage: en
dateModified: 2026-09-15T09:58:28.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# Functions

## Presence and time

| Function            | Description                                                                                                                                                                                                                                                                       | Example                                                                      |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| `has(x)`            | Returns `true` if a trait or address is present on the profile. Use this instead of comparing a possibly missing trait directly to a value.                                                                                                                                       | `has(profile.trait.Account.email)`                                           |
| `now()`             | Returns the current timestamp, evaluated when your snapshot is generated.                                                                                                                                                                                                         | `profile.trait.Account.lastPurchaseDate < now()`                             |
| `timestamp(string)` | Parses an RFC 3339 timestamp string (for example, `timestamp("2026-01-01T00:00:00Z")`). Other date formats aren't supported.                                                                                                                                                      | `profile.trait.Account.lastPurchaseDate > timestamp("2026-01-01T00:00:00Z")` |
| `duration(string)`  | Parses a Go-style duration string. You can combine units, as in `duration("1h30m")`. The value must resolve to a whole number of seconds. Sub-second precision (for example, `duration("1.5s")`) isn't supported. In practice, use `h` (hours), `m` (minutes), and `s` (seconds). | `now() - profile.trait.Account.lastPurchaseDate < duration("720h")`          |

## Math

| Function                   | Description                               | Example                                                   |
| -------------------------- | ----------------------------------------- | --------------------------------------------------------- |
| `math.least(a, b, ...)`    | Returns the smallest of the given values. | `math.least(profile.trait.Account.lifetimeValue, 500)`    |
| `math.greatest(a, b, ...)` | Returns the largest of the given values.  | `math.greatest(profile.trait.Account.lifetimeValue, 500)` |

## Type conversion

| Function    | Description                                  | Example                                    |
| ----------- | -------------------------------------------- | ------------------------------------------ |
| `string(x)` | Converts a value to a string.                | `string(profile.trait.Account.age)`        |
| `int(x)`    | Converts a value to an integer.              | `int(profile.trait.Account.lifetimeValue)` |
| `double(x)` | Converts a value to a floating-point number. | `double(profile.trait.Account.age)`        |

> \[!NOTE]
>
> Both sides of a comparison must evaluate to the same data type. If you need to compare fields with differing types, such as a numeric string and an integer, use a type conversion function (`int()`, `string()`, or `double()`) to reconcile them. See [type matching](/docs/cohorts/cel/type-matching) for the full rules.

## String methods

Call these as methods on a string value.

| Method                 | Description                                        | Example                                                |
| ---------------------- | -------------------------------------------------- | ------------------------------------------------------ |
| `.contains(substring)` | Returns `true` if the string contains `substring`. | `profile.trait.Account.email.contains("@example.com")` |
| `.startsWith(prefix)`  | Returns `true` if the string starts with `prefix`. | `profile.trait.Account.email.startsWith("jane")`       |
| `.endsWith(suffix)`    | Returns `true` if the string ends with `suffix`.   | `profile.trait.Account.email.endsWith("@example.com")` |

## List operations

| Operation                       | Description                                                             | Example                                                        |
| ------------------------------- | ----------------------------------------------------------------------- | -------------------------------------------------------------- |
| `size(list)`                    | Returns the number of items in a list.                                  | `size(profile.address.email) > 1`                              |
| `list.exists(x, condition)`     | Returns `true` if at least one item in the list satisfies `condition`.  | `profile.address.email.exists(e, e.endsWith("@example.com"))`  |
| `list.all(x, condition)`        | Returns `true` if every item in the list satisfies `condition`.         | `profile.address.phone.all(p, p.startsWith("+1"))`             |
| `list.exists_one(x, condition)` | Returns `true` if exactly one item in the list satisfies `condition`.   | `profile.address.email.exists_one(e, e == "jane@example.com")` |
| `list.filter(x, condition)`     | Returns a new list that contains only the items satisfying `condition`. | `profile.address.email.filter(e, e.endsWith("@example.com"))`  |

Cohorts currently doesn't support list transformation with `.map()`.

## Next steps

* Learn about [type matching](/docs/cohorts/cel/type-matching).
* Review [example criteria](/docs/cohorts/cel/common-filtering-patterns) for common filtering patterns.
* Learn about [null handling](/docs/cohorts/cel/null-handling).
