Functions

archive-contact

fn (id: Str): Any
fn (id: Str, opts: Map): Any

Archive a contact (recycle bin, restorable for 90 days).

Example

::hubspot::contacts/archive-contact("12345")

create-contact

fn (properties: Map): Map
fn (properties: Map, opts: Map): Map

Create a contact from a properties Map (email, firstname, lastname, phone, company, plus any custom properties).

Example

contact ::hubspot::contacts/create-contact({
  email: "ada@example.com",
  firstname: "Ada"
})
contact.id

find-by-email

fn (email: Str): Any
fn (email: Str, opts: Map): Any

Search for a contact by exact email. Returns the contact or null.

Example

contact ::hubspot::contacts/find-by-email("ada@example.com")
if(is-some(contact), contact.id, null)

get-contact

fn (id: Str): Map
fn (id: Str, opts: Map): Map
fn (id: Str, properties: Vec): Map
fn (id: Str, properties: Vec, opts: Map): Map

Fetch a contact by id; the 2-arity form selects properties to return.

Example

contact ::hubspot::contacts/get-contact("12345", ["email", "firstname"])
contact.properties.email

search-contacts

fn (options: Map): Map
fn (options: Map, opts: Map): Map

Search contacts — see ::hubspot::objects/build-search-body for the options.

Example

out ::hubspot::contacts/search-contacts({
  filters: [{propertyName: "lifecyclestage", operator: "EQ", value: "lead"}],
  properties: ["email", "firstname"],
  limit: 50
})
map(out.results, %.id)

update-contact

fn (id: Str, properties: Map): Map
fn (id: Str, properties: Map, opts: Map): Map

Update a contact's properties.

Example

::hubspot::contacts/update-contact("12345", {lifecyclestage: "customer"})

upsert-by-email

fn (records: Vec): Map
fn (records: Vec, opts: Map): Map

Create or update contacts keyed by email in one batch call (max 100): records is a Vec of properties Maps that each include email. Returns {status, results}; each result's new says whether it was created. Unlike search-then-write, this is not affected by search indexing delay.

Example

::hubspot::contacts/upsert-by-email([
  {email: "ada@example.com", firstname: "Ada", lifecyclestage: "lead"}
])