Skip to main content

Actions

The ballerinax/hubspot.crm.engagements.tasks package exposes the following clients:

ClientPurpose
ClientManage HubSpot task engagement records: CRUD, batch operations, and search.

Client

Manage HubSpot task engagement records: CRUD, batch operations, and search.

Configuration

FieldTypeDefaultDescription
authhttp:BearerTokenConfig|OAuth2RefreshTokenGrantConfig|ApiKeysConfigRequiredAuthentication configuration: OAuth 2.0 refresh token, bearer token, or API keys.
httpVersionhttp:HttpVersionHTTP_2_0HTTP protocol version.
timeoutdecimal30Request timeout in seconds.
retryConfighttp:RetryConfig()Retry configuration for failed requests.
secureSockethttp:ClientSecureSocket()SSL/TLS configuration.
proxyhttp:ProxyConfig()Proxy server configuration.
circuitBreakerhttp:CircuitBreakerConfig()Circuit breaker configuration for fault tolerance.
compressionhttp:CompressionCOMPRESSION_AUTOHTTP compression configuration.
validationbooleantrueEnable or disable payload validation.

Initializing the client

import ballerinax/hubspot.crm.engagements.tasks;

configurable string clientId = ?;
configurable string clientSecret = ?;
configurable string refreshToken = ?;

tasks:Client tasksClient = check new ({
auth: {
clientId: clientId,
clientSecret: clientSecret,
refreshToken: refreshToken,
refreshUrl: "https://api.hubapi.com/oauth/v1/token"
}
});

Operations

Task CRUD

List of the tasks

Signature: get /

Retrieves a page of task engagement records with optional filtering by properties, associations, and pagination.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoOptional HTTP headers.
queriesGetCrmV3ObjectsTasksGetPageQueriesNoQuery parameters including limit, after, properties, associations, and archived.

Returns: CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error

Sample code:

tasks:CollectionResponseSimplePublicObjectWithAssociationsForwardPaging response =
check tasksClient->/.get();

Sample response:

{
"results": [
{
"id": "78901234567",
"properties": {
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z",
"hs_object_id": "78901234567",
"hs_task_subject": "Follow up with client"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
],
"paging": {
"next": {
"after": "78901234567",
"link": "https://api.hubapi.com/crm/v3/objects/tasks?after=78901234567"
}
}
}
Create a task

Signature: post /

Creates a new task engagement record with the specified properties and optional associations.

Parameters:

NameTypeRequiredDescription
payloadSimplePublicObjectInputForCreateYesTask properties and optional associations.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: SimplePublicObject|error

Sample code:

tasks:SimplePublicObject response = check tasksClient->/.post({
properties: {
"hs_timestamp": "2025-01-15T10:30:00.000Z",
"hs_task_subject": "Follow up with client",
"hs_task_body": "Discuss contract renewal terms and next steps.",
"hs_task_priority": "HIGH",
"hs_task_type": "TODO",
"hs_task_status": "NOT_STARTED"
},
associations: [
{
types: [
{
associationCategory: "HUBSPOT_DEFINED",
associationTypeId: 204
}
],
to: {
id: "12345"
}
}
]
});

Sample response:

{
"id": "78901234567",
"properties": {
"hs_timestamp": "2025-01-15T10:30:00.000Z",
"hs_task_subject": "Follow up with client",
"hs_task_body": "Discuss contract renewal terms and next steps.",
"hs_task_priority": "HIGH",
"hs_task_type": "TODO",
"hs_task_status": "NOT_STARTED",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z",
"hs_object_id": "78901234567"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
Read a task

Signature: get /[string taskId]

Retrieves a single task engagement record by its ID, with optional property and association details.

Parameters:

NameTypeRequiredDescription
taskIdstringYesThe ID of the task to retrieve.
headersmap<string|string[]>NoOptional HTTP headers.
queriesGetCrmV3ObjectsTasksTaskIdGetByIdQueriesNoQuery parameters including properties, associations, and archived.

Returns: SimplePublicObjectWithAssociations|error

Sample code:

tasks:SimplePublicObjectWithAssociations response =
check tasksClient->/["78901234567"].get();

Sample response:

{
"id": "78901234567",
"properties": {
"hs_timestamp": "2025-01-15T10:30:00.000Z",
"hs_task_subject": "Follow up with client",
"hs_task_body": "Discuss contract renewal terms and next steps.",
"hs_task_priority": "HIGH",
"hs_task_type": "TODO",
"hs_task_status": "NOT_STARTED",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z",
"hs_object_id": "78901234567"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
Update a task

Signature: patch /[string taskId]

Updates the properties of an existing task engagement record.

Parameters:

NameTypeRequiredDescription
taskIdstringYesThe ID of the task to update.
payloadSimplePublicObjectInputYesProperties to update.
headersmap<string|string[]>NoOptional HTTP headers.
queriesPatchCrmV3ObjectsTasksTaskIdUpdateQueriesNoQuery parameters including idProperty.

Returns: SimplePublicObject|error

Sample code:

tasks:SimplePublicObject response = check tasksClient->/["78901234567"].patch({
properties: {
"hs_task_status": "COMPLETED",
"hs_task_subject": "Follow up with client: Done"
}
});

Sample response:

{
"id": "78901234567",
"properties": {
"hs_task_subject": "Follow up with client: Done",
"hs_task_status": "COMPLETED",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T11:00:00.000Z",
"hs_object_id": "78901234567"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z",
"archived": false
}
Archive a task

Signature: delete /[string taskId]

Archives (soft-deletes) a task engagement record by its ID.

Parameters:

NameTypeRequiredDescription
taskIdstringYesThe ID of the task to archive.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: error?

Sample code:

check tasksClient->/["78901234567"].delete();

Batch operations

Create a batch of tasks

Signature: post /batch/create

Creates multiple task engagement records in a single request.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectInputForCreateYesBatch of task inputs with properties and optional associations.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

tasks:BatchResponseSimplePublicObject|tasks:BatchResponseSimplePublicObjectWithErrors response =
check tasksClient->/batch/create.post({
inputs: [
{
properties: {
"hs_timestamp": "2025-01-15T10:30:00.000Z",
"hs_task_subject": "Send proposal",
"hs_task_priority": "HIGH",
"hs_task_type": "TODO",
"hs_task_status": "NOT_STARTED"
},
associations: []
},
{
properties: {
"hs_timestamp": "2025-01-16T09:00:00.000Z",
"hs_task_subject": "Schedule demo",
"hs_task_priority": "MEDIUM",
"hs_task_type": "TODO",
"hs_task_status": "NOT_STARTED"
},
associations: []
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "78901234567",
"properties": {
"hs_task_subject": "Send proposal",
"hs_task_priority": "HIGH",
"hs_task_status": "NOT_STARTED",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_object_id": "78901234567"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "78901234568",
"properties": {
"hs_task_subject": "Schedule demo",
"hs_task_priority": "MEDIUM",
"hs_task_status": "NOT_STARTED",
"hs_createdate": "2025-01-16T09:00:00.000Z",
"hs_object_id": "78901234568"
},
"createdAt": "2025-01-16T09:00:00.000Z",
"updatedAt": "2025-01-16T09:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-15T10:30:00.000Z",
"completedAt": "2025-01-15T10:30:01.000Z"
}
Read a batch of tasks by internal ID, or unique property values

Signature: post /batch/read

Retrieves multiple task engagement records by their IDs in a single request.

Parameters:

NameTypeRequiredDescription
payloadBatchReadInputSimplePublicObjectIdYesBatch of task IDs to retrieve, with optional property selection.
headersmap<string|string[]>NoOptional HTTP headers.
queriesPostCrmV3ObjectsTasksBatchReadReadQueriesNoQuery parameters including archived.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

tasks:BatchResponseSimplePublicObject|tasks:BatchResponseSimplePublicObjectWithErrors response =
check tasksClient->/batch/read.post({
inputs: [
{ id: "78901234567" },
{ id: "78901234568" }
],
properties: ["hs_task_subject", "hs_task_status", "hs_task_priority"],
propertiesWithHistory: []
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "78901234567",
"properties": {
"hs_task_subject": "Send proposal",
"hs_task_status": "NOT_STARTED",
"hs_task_priority": "HIGH"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "78901234568",
"properties": {
"hs_task_subject": "Schedule demo",
"hs_task_status": "NOT_STARTED",
"hs_task_priority": "MEDIUM"
},
"createdAt": "2025-01-16T09:00:00.000Z",
"updatedAt": "2025-01-16T09:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-15T10:30:00.000Z",
"completedAt": "2025-01-15T10:30:01.000Z"
}
Update a batch of tasks by internal ID, or unique property values

Signature: post /batch/update

Updates properties on multiple task engagement records in a single request.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectBatchInputYesBatch of task IDs with updated properties.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

tasks:BatchResponseSimplePublicObject|tasks:BatchResponseSimplePublicObjectWithErrors response =
check tasksClient->/batch/update.post({
inputs: [
{
id: "78901234567",
properties: {
"hs_task_status": "COMPLETED",
"hs_task_subject": "Send proposal: Done"
}
},
{
id: "78901234568",
properties: {
"hs_task_status": "IN_PROGRESS",
"hs_task_subject": "Schedule demo: In Progress"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "78901234567",
"properties": {
"hs_task_subject": "Send proposal: Done",
"hs_task_status": "COMPLETED",
"hs_lastmodifieddate": "2025-01-15T11:00:00.000Z"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z",
"archived": false
},
{
"id": "78901234568",
"properties": {
"hs_task_subject": "Schedule demo: In Progress",
"hs_task_status": "IN_PROGRESS",
"hs_lastmodifieddate": "2025-01-15T11:00:00.000Z"
},
"createdAt": "2025-01-16T09:00:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-15T11:00:00.000Z",
"completedAt": "2025-01-15T11:00:01.000Z"
}
Archive a batch of tasks by ID

Signature: post /batch/archive

Archives (soft-deletes) multiple task engagement records in a single request.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectIdYesBatch of task IDs to archive.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: error?

Sample code:

check tasksClient->/batch/archive.post({
inputs: [
{ id: "78901234567" },
{ id: "78901234568" }
]
});
Create or update a batch of tasks by unique property values

Signature: post /batch/upsert

Creates or updates multiple task records in a single request, matching by a unique property value.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectBatchInputUpsertYesBatch of task inputs with an idProperty for matching and properties to set.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error

Sample code:

tasks:BatchResponseSimplePublicUpsertObject|tasks:BatchResponseSimplePublicUpsertObjectWithErrors response =
check tasksClient->/batch/upsert.post({
inputs: [
{
idProperty: "hs_object_id",
id: "78901234567",
properties: {
"hs_task_subject": "Upserted Task",
"hs_task_status": "COMPLETED"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "78901234567",
"properties": {
"hs_task_subject": "Upserted Task",
"hs_task_status": "COMPLETED"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T11:30:00.000Z",
"archived": false,
"new": false
}
],
"startedAt": "2025-01-15T11:30:00.000Z",
"completedAt": "2025-01-15T11:30:01.000Z"
}
Search for tasks

Signature: post /search

Searches for task engagement records using filters, property conditions, and sorting criteria.

Parameters:

NameTypeRequiredDescription
payloadPublicObjectSearchRequestYesSearch request with filter groups, sorting, properties to return, and pagination.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: CollectionResponseWithTotalSimplePublicObjectForwardPaging|error

Sample code:

tasks:CollectionResponseWithTotalSimplePublicObjectForwardPaging response =
check tasksClient->/search.post({
filterGroups: [
{
filters: [
{
propertyName: "hs_task_subject",
operator: "CONTAINS_TOKEN",
value: "follow up"
}
]
}
],
properties: ["hs_task_subject", "hs_task_status", "hs_task_priority"],
sorts: ["hs_createdate"],
limit: 10
});

Sample response:

{
"total": 2,
"results": [
{
"id": "78901234567",
"properties": {
"hs_task_subject": "Follow up with client",
"hs_task_status": "NOT_STARTED",
"hs_task_priority": "HIGH"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "78901234569",
"properties": {
"hs_task_subject": "Follow up on proposal",
"hs_task_status": "IN_PROGRESS",
"hs_task_priority": "MEDIUM"
},
"createdAt": "2025-01-16T09:00:00.000Z",
"updatedAt": "2025-01-16T09:00:00.000Z",
"archived": false
}
],
"paging": {
"next": {
"after": "78901234569"
}
}
}