Skip to main content

Actions

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

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

Client

Manage HubSpot call 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.calls;

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

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

Operations

Call CRUD

Retrieve calls

Signature: get /

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

Parameters:

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

Returns: CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error

Sample code:

calls:CollectionResponseSimplePublicObjectWithAssociationsForwardPaging response =
check callsClient->/.get();

Sample response:

{
"results": [
{
"id": "48093927432",
"properties": {
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z",
"hs_object_id": "48093927432",
"hs_call_title": "Discovery Call"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
],
"paging": {
"next": {
"after": "48093927432",
"link": "https://api.hubapi.com/crm/v3/objects/calls?after=48093927432"
}
}
}
Create a call

Signature: post /

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

Parameters:

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

Returns: SimplePublicObject|error

Sample code:

calls:SimplePublicObject response = check callsClient->/.post({
properties: {
"hs_timestamp": "2025-01-15T10:30:00.000Z",
"hs_call_title": "Discovery Call",
"hs_call_body": "Discussed product requirements and timeline.",
"hs_call_duration": "360000",
"hs_call_from_number": "+1234567890",
"hs_call_to_number": "+0987654321",
"hs_call_status": "COMPLETED"
},
associations: [
{
types: [
{
associationCategory: "HUBSPOT_DEFINED",
associationTypeId: 194
}
],
to: {
id: "12345"
}
}
]
});

Sample response:

{
"id": "48093927432",
"properties": {
"hs_timestamp": "2025-01-15T10:30:00.000Z",
"hs_call_title": "Discovery Call",
"hs_call_body": "Discussed product requirements and timeline.",
"hs_call_duration": "360000",
"hs_call_from_number": "+1234567890",
"hs_call_to_number": "+0987654321",
"hs_call_status": "COMPLETED",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z",
"hs_object_id": "48093927432"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
Retrieve a call

Signature: get /[string callId]

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

Parameters:

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

Returns: SimplePublicObjectWithAssociations|error

Sample code:

calls:SimplePublicObjectWithAssociations response =
check callsClient->/["48093927432"].get();

Sample response:

{
"id": "48093927432",
"properties": {
"hs_timestamp": "2025-01-15T10:30:00.000Z",
"hs_call_title": "Discovery Call",
"hs_call_body": "Discussed product requirements and timeline.",
"hs_call_duration": "360000",
"hs_call_status": "COMPLETED",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z",
"hs_object_id": "48093927432"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
Update a call

Signature: patch /[string callId]

Updates the properties of an existing call engagement record.

Parameters:

NameTypeRequiredDescription
callIdstringYesThe ID of the call to update.
payloadSimplePublicObjectInputYesProperties to update.
headersmap<string|string[]>NoOptional HTTP headers.
queriesPatchCrmV3ObjectsCallsCallIdUpdateQueriesNoQuery parameters including idProperty.

Returns: SimplePublicObject|error

Sample code:

calls:SimplePublicObject response = check callsClient->/["48093927432"].patch({
properties: {
"hs_call_title": "Updated Discovery Call",
"hs_call_status": "COMPLETED"
}
});

Sample response:

{
"id": "48093927432",
"properties": {
"hs_call_title": "Updated Discovery Call",
"hs_call_status": "COMPLETED",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T11:00:00.000Z",
"hs_object_id": "48093927432"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z",
"archived": false
}
Archive a call

Signature: delete /[string callId]

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

Parameters:

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

Returns: error?

Sample code:

check callsClient->/["48093927432"].delete();

Batch operations

Create a batch of calls

Signature: post /batch/create

Creates multiple call engagement records in a single request.

Parameters:

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

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

calls:BatchResponseSimplePublicObject|calls:BatchResponseSimplePublicObjectWithErrors response =
check callsClient->/batch/create.post({
inputs: [
{
properties: {
"hs_timestamp": "2025-01-15T10:30:00.000Z",
"hs_call_title": "Call 1",
"hs_call_status": "COMPLETED"
},
associations: []
},
{
properties: {
"hs_timestamp": "2025-01-15T11:00:00.000Z",
"hs_call_title": "Call 2",
"hs_call_status": "COMPLETED"
},
associations: []
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "48093927432",
"properties": {
"hs_call_title": "Call 1",
"hs_call_status": "COMPLETED",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_object_id": "48093927432"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "48093927433",
"properties": {
"hs_call_title": "Call 2",
"hs_call_status": "COMPLETED",
"hs_createdate": "2025-01-15T11:00:00.000Z",
"hs_object_id": "48093927433"
},
"createdAt": "2025-01-15T11:00:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-15T10:30:00.000Z",
"completedAt": "2025-01-15T10:30:01.000Z"
}
Retrieve a batch of calls

Signature: post /batch/read

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

Parameters:

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

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

calls:BatchResponseSimplePublicObject|calls:BatchResponseSimplePublicObjectWithErrors response =
check callsClient->/batch/read.post({
inputs: [
{ id: "48093927432" },
{ id: "48093927433" }
],
properties: ["hs_call_title", "hs_call_status", "hs_call_duration"]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "48093927432",
"properties": {
"hs_call_title": "Call 1",
"hs_call_status": "COMPLETED",
"hs_call_duration": "360000"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "48093927433",
"properties": {
"hs_call_title": "Call 2",
"hs_call_status": "COMPLETED",
"hs_call_duration": "180000"
},
"createdAt": "2025-01-15T11:00:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-15T10:30:00.000Z",
"completedAt": "2025-01-15T10:30:01.000Z"
}
Update a batch of calls

Signature: post /batch/update

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

Parameters:

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

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

calls:BatchResponseSimplePublicObject|calls:BatchResponseSimplePublicObjectWithErrors response =
check callsClient->/batch/update.post({
inputs: [
{
id: "48093927432",
properties: {
"hs_call_title": "Updated Call 1",
"hs_call_status": "COMPLETED"
}
},
{
id: "48093927433",
properties: {
"hs_call_title": "Updated Call 2",
"hs_call_status": "COMPLETED"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "48093927432",
"properties": {
"hs_call_title": "Updated Call 1",
"hs_call_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": "48093927433",
"properties": {
"hs_call_title": "Updated Call 2",
"hs_call_status": "COMPLETED",
"hs_lastmodifieddate": "2025-01-15T11:00:00.000Z"
},
"createdAt": "2025-01-15T11: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 calls

Signature: post /batch/archive

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

Parameters:

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

Returns: error?

Sample code:

check callsClient->/batch/archive.post({
inputs: [
{ id: "48093927432" },
{ id: "48093927433" }
]
});
Create or update a batch of calls by unique property

Signature: post /batch/upsert

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

Parameters:

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

Returns: BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error

Sample code:

calls:BatchResponseSimplePublicUpsertObject|calls:BatchResponseSimplePublicUpsertObjectWithErrors response =
check callsClient->/batch/upsert.post({
inputs: [
{
idProperty: "hs_object_id",
id: "48093927432",
properties: {
"hs_call_title": "Upserted Call",
"hs_call_status": "COMPLETED"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "48093927432",
"properties": {
"hs_call_title": "Upserted Call",
"hs_call_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 calls

Signature: post /search

Searches for call 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:

calls:CollectionResponseWithTotalSimplePublicObjectForwardPaging response =
check callsClient->/search.post({
filterGroups: [
{
filters: [
{
propertyName: "hs_call_status",
operator: "EQ",
value: "COMPLETED"
}
]
}
],
properties: ["hs_call_title", "hs_call_status", "hs_call_duration"],
sorts: ["hs_createdate"],
limit: 10
});

Sample response:

{
"total": 2,
"results": [
{
"id": "48093927432",
"properties": {
"hs_call_title": "Discovery Call",
"hs_call_status": "COMPLETED",
"hs_call_duration": "360000"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "48093927433",
"properties": {
"hs_call_title": "Follow-up Call",
"hs_call_status": "COMPLETED",
"hs_call_duration": "180000"
},
"createdAt": "2025-01-15T11:00:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z",
"archived": false
}
],
"paging": {
"next": {
"after": "48093927433"
}
}
}