Skip to main content

Actions

The ballerinax/hubspot.crm.commerce.taxes package exposes the following clients:

ClientPurpose
ClientManage HubSpot commerce tax objects: CRUD, search, and batch operations.

Client

Manage HubSpot commerce tax objects: CRUD, search, and batch operations.

Configuration

FieldTypeDefaultDescription
authhttp:BearerTokenConfig|OAuth2RefreshTokenGrantConfig|ApiKeysConfigRequiredAuthentication configuration: OAuth 2.0 refresh token, bearer token, or API keys.
httpVersionHttpVersionHTTP_2_0HTTP protocol version.
timeoutdecimal30Request timeout in seconds.
retryConfigRetryConfig()Retry configuration for failed requests.
secureSocketClientSecureSocket()SSL/TLS configuration.
proxyProxyConfig()Proxy server configuration.
compressionhttp:CompressionCOMPRESSION_AUTOHTTP compression setting.
validationbooleantrueEnable/disable payload validation.
laxDataBindingbooleantrueAllow lax data binding for response payloads.

Initializing the client

import ballerinax/hubspot.crm.commerce.taxes;
import ballerina/oauth2;

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

taxes:Client taxesClient = check new ({
auth: {
clientId: clientId,
clientSecret: clientSecret,
refreshToken: refreshToken,
credentialBearer: oauth2:POST_BODY_BEARER
}
});

Operations

Single record operations

List taxes

Signature: get /

Retrieves a paginated list of tax objects, with optional filtering by properties, associations, and archived status.

Parameters:

NameTypeRequiredDescription
propertiesstring[]?NoProperties to include in the response.
associationsstring[]?NoObject types to retrieve associated IDs for.
'limitint:Signed32NoMaximum number of results per page (default 10).
afterstring?NoPaging cursor token for the next page of results.
archivedbooleanNoWhether to return only archived results (default false).
propertiesWithHistorystring[]?NoProperties to return with their history of previous values.

Returns: CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error

Sample code:

CollectionResponseSimplePublicObjectWithAssociationsForwardPaging response =
check taxesClient->/.get(
properties = ["hs_label", "hs_value", "hs_type"],
'limit = 10
);

Sample response:

{
"results": [
{
"id": "123456789",
"properties": {
"hs_label": "Sales Tax 8.5%",
"hs_value": "8.5000",
"hs_type": "PERCENT",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
],
"paging": {
"next": {
"after": "NTI1Cg%3D%3D",
"link": "?after=NTI1Cg%3D%3D"
}
}
}
Create a tax

Signature: post /

Creates a new tax object with the specified properties and optional associations.

Parameters:

NameTypeRequiredDescription
payloadSimplePublicObjectInputForCreateYesTax record data including properties (e.g., hs_label, hs_value, hs_type) and optional associations.

Returns: SimplePublicObject|error

Sample code:

SimplePublicObject response = check taxesClient->/.post({
properties: {
"hs_label": "A percentage-based tax of 8.5%",
"hs_value": "8.5000",
"hs_type": "PERCENT"
},
associations: []
});

Sample response:

{
"id": "123456789",
"properties": {
"hs_label": "A percentage-based tax of 8.5%",
"hs_value": "8.5000",
"hs_type": "PERCENT",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
Read a tax by ID

Signature: get /[taxId]

Retrieves a single tax object by its ID, with optional properties and associations.

Parameters:

NameTypeRequiredDescription
taxIdstringYesThe ID of the tax object to retrieve.
propertiesstring[]?NoProperties to include in the response.
associationsstring[]?NoObject types to retrieve associated IDs for.
archivedbooleanNoWhether to return archived results (default false).
idPropertystring?NoThe name of a property whose values are unique for this object type.
propertiesWithHistorystring[]?NoProperties to return with their history of previous values.

Returns: SimplePublicObjectWithAssociations|error

Sample code:

SimplePublicObjectWithAssociations response =
check taxesClient->/[taxId].get(
properties = ["hs_label", "hs_value", "hs_type"]
);

Sample response:

{
"id": "123456789",
"properties": {
"hs_label": "A percentage-based tax of 8.5%",
"hs_value": "8.5000",
"hs_type": "PERCENT",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-15T10:30:00.000Z"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
Update a tax

Signature: patch /[taxId]

Updates the properties of an existing tax object identified by its ID.

Parameters:

NameTypeRequiredDescription
taxIdstringYesThe ID of the tax object to update.
payloadSimplePublicObjectInputYesUpdated properties for the tax record.
idPropertystring?NoThe name of a property whose values are unique for this object type.

Returns: SimplePublicObject|error

Sample code:

SimplePublicObject response = check taxesClient->/[taxId].patch({
properties: {
"hs_label": "Updated tax at 7.5%",
"hs_value": "7.5000"
}
});

Sample response:

{
"id": "123456789",
"properties": {
"hs_label": "Updated tax at 7.5%",
"hs_value": "7.5000",
"hs_type": "PERCENT",
"hs_createdate": "2025-01-15T10:30:00.000Z",
"hs_lastmodifieddate": "2025-01-16T08:00:00.000Z"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-16T08:00:00.000Z",
"archived": false
}
Archive a tax

Signature: delete /[taxId]

Archives (soft-deletes) a tax object by its ID.

Parameters:

NameTypeRequiredDescription
taxIdstringYesThe ID of the tax object to archive.

Returns: error?

Sample code:

check taxesClient->/[taxId].delete();
Search taxes

Signature: post /search

Searches for tax objects using filters, query text, sorting, and pagination.

Parameters:

NameTypeRequiredDescription
payloadPublicObjectSearchRequestYesSearch request with optional query string, filter groups, sorts, properties, limit, and paging cursor.

Returns: CollectionResponseWithTotalSimplePublicObjectForwardPaging|error

Sample code:

CollectionResponseWithTotalSimplePublicObjectForwardPaging response =
check taxesClient->/search.post({
query: "tax",
properties: ["hs_label", "hs_value", "hs_type"],
sorts: ["hs_value"],
'limit: 10
});

Sample response:

{
"total": 2,
"results": [
{
"id": "123456789",
"properties": {
"hs_label": "Sales Tax 5%",
"hs_value": "5.0000",
"hs_type": "PERCENT"
},
"createdAt": "2025-01-10T09:00:00.000Z",
"updatedAt": "2025-01-10T09:00:00.000Z",
"archived": false
},
{
"id": "987654321",
"properties": {
"hs_label": "Sales Tax 8.5%",
"hs_value": "8.5000",
"hs_type": "PERCENT"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
]
}

Batch operations

Batch create taxes

Signature: post /batch/create

Creates multiple tax objects in a single request.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectInputForCreateYesBatch input containing an array of tax records to create.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors response =
check taxesClient->/batch/create.post({
inputs: [
{
properties: {
"hs_label": "State Tax 6%",
"hs_value": "6.0000",
"hs_type": "PERCENT"
},
associations: []
},
{
properties: {
"hs_label": "Fixed Fee $2.50",
"hs_value": "2.5000",
"hs_type": "FIXED"
},
associations: []
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "111111111",
"properties": {
"hs_label": "State Tax 6%",
"hs_value": "6.0000",
"hs_type": "PERCENT",
"hs_createdate": "2025-01-20T12:00:00.000Z",
"hs_lastmodifieddate": "2025-01-20T12:00:00.000Z"
},
"createdAt": "2025-01-20T12:00:00.000Z",
"updatedAt": "2025-01-20T12:00:00.000Z",
"archived": false
},
{
"id": "222222222",
"properties": {
"hs_label": "Fixed Fee $2.50",
"hs_value": "2.5000",
"hs_type": "FIXED",
"hs_createdate": "2025-01-20T12:00:00.000Z",
"hs_lastmodifieddate": "2025-01-20T12:00:00.000Z"
},
"createdAt": "2025-01-20T12:00:00.000Z",
"updatedAt": "2025-01-20T12:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-20T12:00:00.000Z",
"completedAt": "2025-01-20T12:00:01.000Z"
}
Batch read taxes

Signature: post /batch/read

Reads a batch of tax objects by their IDs or unique property values.

Parameters:

NameTypeRequiredDescription
payloadBatchReadInputSimplePublicObjectIdYesBatch read input with IDs, properties to return, and optional ID property name.
archivedbooleanNoWhether to return archived results (default false).

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors response =
check taxesClient->/batch/read.post({
inputs: [{id: "123456789"}, {id: "987654321"}],
properties: ["hs_label", "hs_value", "hs_type"],
propertiesWithHistory: []
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "123456789",
"properties": {
"hs_label": "Sales Tax 8.5%",
"hs_value": "8.5000",
"hs_type": "PERCENT"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "987654321",
"properties": {
"hs_label": "Sales Tax 5%",
"hs_value": "5.0000",
"hs_type": "PERCENT"
},
"createdAt": "2025-01-10T09:00:00.000Z",
"updatedAt": "2025-01-10T09:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-20T12:00:00.000Z",
"completedAt": "2025-01-20T12:00:01.000Z"
}
Batch update taxes

Signature: post /batch/update

Updates multiple tax objects in a single request by their IDs or unique property values.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectBatchInputYesBatch input containing an array of tax records with IDs and updated properties.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors response =
check taxesClient->/batch/update.post({
inputs: [
{
id: "123456789",
properties: {
"hs_value": "9.0000"
}
},
{
id: "987654321",
properties: {
"hs_value": "5.5000"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "123456789",
"properties": {
"hs_label": "Sales Tax 8.5%",
"hs_value": "9.0000",
"hs_type": "PERCENT",
"hs_lastmodifieddate": "2025-01-21T14:00:00.000Z"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-21T14:00:00.000Z",
"archived": false
},
{
"id": "987654321",
"properties": {
"hs_label": "Sales Tax 5%",
"hs_value": "5.5000",
"hs_type": "PERCENT",
"hs_lastmodifieddate": "2025-01-21T14:00:00.000Z"
},
"createdAt": "2025-01-10T09:00:00.000Z",
"updatedAt": "2025-01-21T14:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-21T14:00:00.000Z",
"completedAt": "2025-01-21T14:00:01.000Z"
}
Batch upsert taxes

Signature: post /batch/upsert

Creates or updates a batch of tax objects by unique property values. If a record with the given ID property exists it is updated; otherwise a new record is created.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectBatchInputUpsertYesBatch upsert input containing an array of tax records with IDs and properties.

Returns: BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error

Sample code:

BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors response =
check taxesClient->/batch/upsert.post({
inputs: [
{
id: "123456789",
properties: {
"hs_label": "Upserted Tax 10%",
"hs_value": "10.0000",
"hs_type": "PERCENT"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "123456789",
"properties": {
"hs_label": "Upserted Tax 10%",
"hs_value": "10.0000",
"hs_type": "PERCENT",
"hs_lastmodifieddate": "2025-01-22T09:00:00.000Z"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-22T09:00:00.000Z",
"archived": false,
"new": false
}
],
"startedAt": "2025-01-22T09:00:00.000Z",
"completedAt": "2025-01-22T09:00:01.000Z"
}
Batch archive taxes

Signature: post /batch/archive

Archives multiple tax objects in a single request by their IDs.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectIdYesBatch input containing an array of tax object IDs to archive.

Returns: error?

Sample code:

check taxesClient->/batch/archive.post({
inputs: [{id: "123456789"}, {id: "987654321"}]
});