Skip to content
View as Markdown

Enroll a contact

Starts a Workflow run for the given contact or group. The first step executes immediately. The response includes runId and the pb_line_id pinned to the run, plus groupId when enrolled by group.

POST/enroll-flowBearer token

Because the first step runs before the response is written, the returned status is the state after that step. A run that begins with a wait comes back SLEEPING, and one that begins by asking a question comes back WAITING_REPLY — ACTIVE is the exception, not the rule. Statuses are uppercase: ACTIVE, SLEEPING, WAITING_REPLY, COMPLETED, CANCELLED, FAILED.

Request body

flowIdstring (UUID)Required
The Workflow id, as returned by GET /get-flows. An opaque UUID string — do not parse it. Must be 1 to 64 characters.
phoneNumberstring
The contact's phone number. Accepts many formats — normalized to E.164. Exactly one of phoneNumber or groupId is required.
groupIdstring
The groupId returned by POST /send-group-message (pbg_…). Exactly one of phoneNumber or groupId is required. A group run sends into the group from the line it lives on.
pb_line_idstring (UUID)
Optional. Line to send from (lineId from GET /get-lines). When omitted, a line is selected automatically and pinned for the entire run.
variablesobject
Optional string values for this run. first_name, last_name, email, and company override the matching core tokens. Every other key is available as {{custom.<key>}}. first_name and last_name create the Project Blue contact only when no CRM is connected. CRM accounts never get a Project Blue contact from enrollment. Keys are letters, digits, and underscores; case insensitive; max 50 keys; max 500 characters per value. Example: {"first_name":"Jane","order_id":"123"}.
Personalization
Workflow messages can include {{first_name}}, {{last_name}}, {{email}}, {{company}}, {{phone}}, {{reply}} (the contact's last reply during a wait step), and {{custom.<key>}}. An optional fallback is written as {{first_name|there}}. Unknown tokens with no fallback render as an empty string.

At send time each token is filled in this order:

  1. variables sent on the enroll request
  2. the connected CRM contact (HighLevel, HubSpot, or Close), looked up live by the contact's phone number
  3. the Project Blue contact record, only for accounts with no connected CRM

{{custom.<key>}} reads from variables first, then from the CRM using the CRM's own field identifier. HighLevel uses the custom field key without the contact. prefix (the part GHL shows in {{contact.<key>}}). HubSpot uses the contact property internal name. Close uses the custom field name, case insensitive, on the contact or its lead. Accounts with no CRM get custom values from variables only.

Status codes

400
Provide phoneNumber or groupId, not both; phoneNumber or groupId is required; This group lives on a different line; pb_line_id is required for this group; invalid phone number, invalid pb_line_id, or no available lines
403
Contact has opted out
404
Group not found for this account; flow not found or not published, or line not found
409
This group's line is no longer on this account; an active run already exists for this contact in this flow
API reference