The generic CRM objects surface. object-type is "contacts",
"companies", "deals", "tickets", an activity type ("notes",
"tasks", "calls", "meetings", "emails"), or a custom object's
fully qualified name or type id. Every function here works uniformly
across them; the typed modules (::hubspot::contacts, ...) delegate
here. Paths use HubSpot's date-based versions
(/crm/objects/2026-09/...; see ::hubspot::api/api-version).
Functions
archive-object
fn (object-type: Str, id: Str): Any
fn (object-type: Str, id: Str, opts: Map): Any
DELETE /crm/objects/{version}/{type}/{id} - Archive a record (it moves to the recycle bin and can be restored for 90 days).
Example
::hubspot::objects/archive-object("tickets", "12345")
associate
fn (from-type: Str, from-id: Str, to-type: Str, to-id: Str): Any
fn (from-type: Str, from-id: Str, to-type: Str, to-id: Str, opts: Map): Any
PUT /crm/objects/{version}/{fromType}/{fromId}/associations/default/{toType}/{toId} - Associate two records with the default (unlabeled) association type, e.g. contact and company, or deal and contact.
Example
::hubspot::objects/associate("deals", "67890", "contacts", "12345")
associate-with-label
fn (from-type: Str, from-id: Str, to-type: Str, to-id: Str, type-id: Int): Map
fn (from-type: Str, from-id: Str, to-type: Str, to-id: Str, type-id: Int, category: Str): Map
fn (from-type: Str, from-id: Str, to-type: Str, to-id: Str, type-id: Int, category: Str, opts: Map): Map
PUT /crm/objects/{version}/{type}/{id}/associations/{toType}/{toId} - Associate two records with a specific association type: a HUBSPOT_DEFINED id (e.g. 1 for a contact's primary company) or a USER_DEFINED label id from your portal's association labels.
Example
// 1 is a contact's primary company
::hubspot::objects/associate-with-label("contacts", "12345", "companies", "9876", 1)
// A label defined in your portal
::hubspot::objects/associate-with-label("contacts", "12345", "companies", "9876", 42, "USER_DEFINED")
association-input
fn (to-id: Str, type-id: Int): Map
fn (to-id: Str, type-id: Int, category: Str): Map
One create-time association: links the new record to record to-id with
association type type-id (HUBSPOT_DEFINED category by default; pass
"USER_DEFINED" for custom labels). See
::hubspot::engagements/association-type-id for the activity ids.
Example
::hubspot::objects/association-input("9876", 1)
// {to: {id: "9876"}, types: [{associationCategory: "HUBSPOT_DEFINED", associationTypeId: 1}]}
::hubspot::objects/association-input("9876", 42, "USER_DEFINED").types[0].associationCategory // "USER_DEFINED"
batch-archive
fn (object-type: Str, ids: Vec): Any
fn (object-type: Str, ids: Vec, opts: Map): Any
POST /crm/objects/{version}/{type}/batch/archive - Archive up to 100 records by id. Returns null (204) on success.
Example
::hubspot::objects/batch-archive("contacts", ["12345", "67890"])
batch-create
fn (object-type: Str, inputs: Vec): Map
fn (object-type: Str, inputs: Vec, opts: Map): Map
POST /crm/objects/{version}/{type}/batch/create - Create up to 100
records. inputs is a Vec of properties Maps, or of {properties, associations} Maps. Returns {status, results, errors?}.
Example
out ::hubspot::objects/batch-create("contacts", [
{email: "ada@example.com", firstname: "Ada"},
{properties: {email: "grace@example.com"}, associations: [::hubspot::objects/association-input("9876", 1)]}
])
map(out.results, %.id)
batch-create-input
fn (input: Map): Map
Normalize one batch-create input: a Map with a properties key passes
through (so it can carry associations); a plain properties Map is
wrapped as {properties}. Exposed for testing.
Example
::hubspot::objects/batch-create-input({email: "ada@example.com"}) // {properties: {email: "ada@example.com"}}
::hubspot::objects/batch-create-input({properties: {email: "ada@example.com"}}) // {properties: {email: "ada@example.com"}}
batch-read
fn (object-type: Str, ids: Vec): Map
fn (object-type: Str, ids: Vec, options: Map): Map
fn (object-type: Str, ids: Vec, options: Map, opts: Map): Map
POST /crm/objects/{version}/{type}/batch/read - Read up to 100 records
by id (or by a unique idProperty) in one call. Returns {status, results, errors?}; missing ids show up in errors, not as a failure.
Example
out ::hubspot::objects/batch-read("contacts", ["ada@example.com", "grace@example.com"], {
idProperty: "email",
properties: ["firstname", "lifecyclestage"]
})
out.results
batch-update
fn (object-type: Str, inputs: Vec): Map
fn (object-type: Str, inputs: Vec, opts: Map): Map
POST /crm/objects/{version}/{type}/batch/update - Update up to 100
records. inputs is a Vec of {id, properties} (add idProperty to
address a record by a unique property).
Example
out ::hubspot::objects/batch-update("contacts", [
{id: "12345", properties: {lifecyclestage: "customer"}},
{id: "grace@example.com", idProperty: "email", properties: {firstname: "Grace"}}
])
out.status
batch-upsert
fn (object-type: Str, id-property: Str, records: Vec): Map
fn (object-type: Str, id-property: Str, records: Vec, opts: Map): Map
POST /crm/objects/{version}/{type}/batch/upsert - Create-or-update up
to 100 records keyed by a unique property: "email" for contacts, or
any custom property created with hasUniqueValue: true (a company's
domain is not unique). records is a Vec of {id, properties}
where id is the unique property's value. Returns {status, results}; each result's
new is true when it was created.
Example
::hubspot::objects/batch-upsert("contacts", "email", [
{id: "ada@example.com", properties: {firstname: "Ada", lifecyclestage: "lead"}},
{id: "grace@example.com", properties: {firstname: "Grace"}}
])
build-batch-read-body
fn (ids: Vec, options: Map): Map
The batch-read payload. options: properties, propertiesWithHistory
(both default to []), and idProperty when the ids are values of a
unique property. Exposed for testing.
Example
::hubspot::objects/build-batch-read-body(["1", 2], {properties: ["email"]})
// {inputs: [{id: "1"}, {id: "2"}], properties: ["email"], propertiesWithHistory: []}
build-batch-upsert-body
fn (id-property: Str, records: Vec): Map
The batch-upsert payload: each {id, properties} record gains
idProperty. Exposed for testing.
Example
::hubspot::objects/build-batch-upsert-body("email", [{id: "ada@example.com", properties: {firstname: "Ada"}}])
// {inputs: [{id: "ada@example.com", idProperty: "email", properties: {firstname: "Ada"}}]}
build-create-body
fn (properties: Map, associations: Vec?): Map
The create payload {properties, associations?}. Each association is
{to: {id}, types: [{associationCategory, associationTypeId}]}; build
them with ::hubspot::objects/association-input. Exposed for testing.
Example
::hubspot::objects/build-create-body({email: "ada@example.com"}, null) // {properties: {email: "ada@example.com"}}
::hubspot::objects/build-create-body({email: "ada@example.com"}, [::hubspot::objects/association-input("9876", 1)]).associations
// [{to: {id: "9876"}, types: [{associationCategory: "HUBSPOT_DEFINED", associationTypeId: 1}]}]
build-search-body
fn (options: Map): Map
Build a CRM search body. options: query (free-text), filters
(Vec of {propertyName, operator, value} — combined with AND),
filterGroups (Vec of {filters} groups combined with OR; overrides
filters), sorts (Vec of {propertyName, direction}), properties,
limit (max 200), after. Unset options are omitted. Exposed for
testing; search-objects uses it.
Example
::hubspot::objects/build-search-body({filters: [{propertyName: "email", operator: "EQ", value: "ada@example.com"}], limit: 1})
// {filterGroups: [{filters: [{propertyName: "email", operator: "EQ", value: "ada@example.com"}]}], limit: 1}
::hubspot::objects/build-search-body({query: "ada"}) // {query: "ada"}
create-object
fn (object-type: Str, properties: Map): Map
fn (object-type: Str, properties: Map, opts: Map): Map
fn (object-type: Str, properties: Map, associations: Vec): Map
fn (object-type: Str, properties: Map, associations: Vec, opts: Map): Map
POST /crm/objects/{version}/{type} - Create a record from a properties
Map. The 3-arity form also creates associations in the same call (Vec of
association-input values).
Example
ticket ::hubspot::objects/create-object("tickets", {subject: "Login broken", hs_pipeline: "0", hs_pipeline_stage: "1"})
ticket.id
// Associated in the same call: 1 is a contact's primary company
::hubspot::objects/create-object("contacts", {email: "ada@example.com"}, [::hubspot::objects/association-input("9876", 1)])
get-object
fn (object-type: Str, id: Str): Map
fn (object-type: Str, id: Str, opts: Map): Map
fn (object-type: Str, id: Str, properties: Vec): Map
fn (object-type: Str, id: Str, properties: Vec, options: Map): Map
fn (object-type: Str, id: Str, properties: Vec, options: Map, opts: Map): Map
GET /crm/objects/{version}/{type}/{id} - One record. The 3-arity form
selects which properties to return (Vec of names). The 4-arity form
adds options: idProperty (look up by a unique property such as
"email" instead of the record id), associations (Vec of object
types whose associated ids to include), propertiesWithHistory, and
archived.
Example
::objects ::hubspot::objects
contact ::objects/get-object("contacts", "ada@example.com", ["firstname", "lastname"], {idProperty: "email", associations: ["companies"]})
list-all-objects
fn (object-type: Str, params: Map): Vec
fn (object-type: Str, params: Map, max-pages: Int): Vec
fn (object-type: Str, params: Map, max-pages: Int, opts: Map): Vec
Every record of a type across pages (100 per page), up to max-pages
pages (default 10, so 1,000 records). params is as for list-objects,
minus after/limit.
Example
tickets ::hubspot::objects/list-all-objects("tickets", {properties: ["subject"]}, 20)
length(tickets)
list-associations
fn (object-type: Str, id: Str, to-type: Str): Map
fn (object-type: Str, id: Str, to-type: Str, params: Map): Map
fn (object-type: Str, id: Str, to-type: Str, params: Map, opts: Map): Map
GET /crm/objects/{version}/{type}/{id}/associations/{toType} - The
records associated with one record: {results: [{toObjectId, associationTypes: [{category, typeId, label}]}], paging?}. params:
limit (max 500), after.
Example
out ::hubspot::objects/list-associations("deals", "67890", "contacts", {limit: 100})
map(out.results, %.toObjectId)
list-objects
fn (object-type: Str): Map
fn (object-type: Str, params: Map): Map
fn (object-type: Str, params: Map, opts: Map): Map
GET /crm/objects/{version}/{type} - One page of records. params:
limit (max 100), after (paging cursor), properties (Vec),
associations (Vec), archived. Returns {results, paging?}; pass
::hubspot::api/next-after(page) as after for the next page, or use
list-all-objects.
Example
page ::hubspot::objects/list-objects("tickets", {limit: 100, properties: ["subject"]})
map(page.results, %.id)
// The next page
::hubspot::objects/list-objects("tickets", {limit: 100, after: ::hubspot::api/next-after(page)})
remove-association
fn (from-type: Str, from-id: Str, to-type: Str, to-id: Str): Any
fn (from-type: Str, from-id: Str, to-type: Str, to-id: Str, opts: Map): Any
DELETE /crm/objects/{version}/{type}/{id}/associations/{toType}/{toId} - Remove every association between two records.
Example
::hubspot::objects/remove-association("deals", "67890", "contacts", "12345")
search-all-objects
fn (object-type: Str, options: Map): Vec
fn (object-type: Str, options: Map, max-pages: Int): Vec
fn (object-type: Str, options: Map, max-pages: Int, opts: Map): Vec
Run a search across pages (limit 200 per page) up to max-pages
(default 5). HubSpot caps any search at 10,000 total results.
Example
deals ::hubspot::objects/search-all-objects("deals", {
filters: [{propertyName: "dealstage", operator: "EQ", value: "closedwon"}],
properties: ["amount"]
}, 10)
length(deals)
search-objects
fn (object-type: Str, options: Map): Map
fn (object-type: Str, options: Map, opts: Map): Map
POST /crm/objects/{version}/{type}/search - Search records. See
build-search-body for the options. Operators: EQ, NEQ, LT,
LTE, GT, GTE, BETWEEN (value + highValue), IN/NOT_IN
(values), HAS_PROPERTY, NOT_HAS_PROPERTY, CONTAINS_TOKEN,
NOT_CONTAINS_TOKEN. Search is eventually consistent: a record
created a moment ago may not match yet.
Example
open-deals ::hubspot::objects/search-objects("deals", {
filters: [{propertyName: "dealstage", operator: "NEQ", value: "closedlost"}],
sorts: [{propertyName: "amount", direction: "DESCENDING"}],
limit: 20
})
update-object
fn (object-type: Str, id: Str, properties: Map): Map
fn (object-type: Str, id: Str, properties: Map, opts: Map): Map
fn (object-type: Str, id: Str, properties: Map, id-property: Str): Map
fn (object-type: Str, id: Str, properties: Map, id-property: Str, opts: Map): Map
PATCH /crm/objects/{version}/{type}/{id} - Update the given properties
of a record. The 4-arity form addresses the record by a unique property
(id-property, e.g. "email") instead of its id. Set a property to
"" to clear it.
Example
::hubspot::objects/update-object("tickets", "12345", {hs_ticket_priority: "HIGH"})
// Addressed by a unique property
::hubspot::objects/update-object("contacts", "ada@example.com", {lifecyclestage: "customer"}, "email")