Skip to main content

Actions

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

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

Client

Manage HubSpot order objects: CRUD, batch operations, and search.

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.
compressionCompressionCOMPRESSION_AUTOHTTP compression configuration.
validationbooleantrueEnable payload validation.
laxDataBindingbooleantrueAllow lax data binding for responses.

Initializing the client

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

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

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

Operations

Single order CRUD

List

Signature: get /

Retrieves a paginated list of order objects with optional property and association filtering.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesGetCrmV3ObjectsOrdersQueriesNoQuery parameters including properties, associations, archived, limit, and after for pagination.

Returns: CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error

Sample code:

orders:CollectionResponseSimplePublicObjectWithAssociationsForwardPaging response =
check ordersClient->/.get(queries = {
'limit: 10,
properties: ["hs_order_name", "hs_currency_code", "hs_fulfillment_status"]
});

Sample response:

{
"results": [
{
"id": "394961395351",
"properties": {
"hs_order_name": "Camping supplies",
"hs_currency_code": "USD",
"hs_fulfillment_status": "Packing",
"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": "394961395352",
"link": "https://api.hubapi.com/crm/v3/objects/orders?after=394961395352"
}
}
}
Read

Signature: get /[string orderId]

Retrieves a single order object by its ID, with optional property and association selection.

Parameters:

NameTypeRequiredDescription
orderIdstringYesThe ID of the order to retrieve.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesGetCrmV3ObjectsOrdersOrderIdQueriesNoQuery parameters including properties, associations, archived, and idProperty.

Returns: SimplePublicObjectWithAssociations|error

Sample code:

orders:SimplePublicObjectWithAssociations response =
check ordersClient->/[orderId].get(queries = {
properties: ["hs_order_name", "hs_currency_code", "hs_fulfillment_status"]
});

Sample response:

{
"id": "394961395351",
"properties": {
"hs_order_name": "Camping supplies",
"hs_currency_code": "USD",
"hs_fulfillment_status": "Packing",
"hs_source_store": "REI: Portland",
"hs_shipping_address_city": "Portland",
"hs_shipping_address_state": "Maine",
"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
}
Create

Signature: post /

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

Parameters:

NameTypeRequiredDescription
payloadSimplePublicObjectInputForCreateYesThe order properties and associations to create.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: SimplePublicObject|error

Sample code:

orders:SimplePublicObject response = check ordersClient->/.post({
associations: [
{
to: {id: "31440573867"},
types: [
{
associationCategory: "HUBSPOT_DEFINED",
associationTypeId: 512
}
]
}
],
properties: {
"hs_order_name": "Camping supplies",
"hs_currency_code": "USD",
"hs_source_store": "REI: Portland",
"hs_fulfillment_status": "Packing",
"hs_shipping_address_city": "Portland",
"hs_shipping_address_state": "Maine",
"hs_shipping_address_street": "123 Fake Street"
}
});

Sample response:

{
"id": "394961395351",
"properties": {
"hs_order_name": "Camping supplies",
"hs_currency_code": "USD",
"hs_source_store": "REI: Portland",
"hs_fulfillment_status": "Packing",
"hs_shipping_address_city": "Portland",
"hs_shipping_address_state": "Maine",
"hs_shipping_address_street": "123 Fake Street",
"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

Signature: patch /[string orderId]

Updates an existing order object's properties by its ID.

Parameters:

NameTypeRequiredDescription
orderIdstringYesThe ID of the order to update.
payloadSimplePublicObjectInputYesThe properties to update.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesPatchCrmV3ObjectsOrdersOrderIdQueriesNoQuery parameters including idProperty.

Returns: SimplePublicObject|error

Sample code:

orders:SimplePublicObject response = check ordersClient->/[orderId].patch({
properties: {
"hs_fulfillment_status": "Shipped"
}
});

Sample response:

{
"id": "394961395351",
"properties": {
"hs_order_name": "Camping supplies",
"hs_currency_code": "USD",
"hs_fulfillment_status": "Shipped",
"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

Signature: delete /[string orderId]

Archives (soft-deletes) an order object by its ID.

Parameters:

NameTypeRequiredDescription
orderIdstringYesThe ID of the order to archive.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: error?

Sample code:

check ordersClient->/[orderId].delete();

Batch operations

Read a batch of orders by internal ID, or unique property values

Signature: post /batch/read

Reads a batch of order objects by their IDs or a unique property, with optional property selection.

Parameters:

NameTypeRequiredDescription
payloadBatchReadInputSimplePublicObjectIdYesBatch read input containing IDs, properties, and optional idProperty.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesPostCrmV3ObjectsOrdersBatchReadQueriesNoQuery parameters including archived.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

orders:BatchResponseSimplePublicObject|orders:BatchResponseSimplePublicObjectWithErrors response =
check ordersClient->/batch/read.post({
inputs: [
{id: orderId1},
{id: orderId2}
],
properties: ["hs_order_name", "hs_currency_code", "hs_fulfillment_status"],
propertiesWithHistory: []
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "394961395351",
"properties": {
"hs_order_name": "Camping supplies",
"hs_currency_code": "USD",
"hs_fulfillment_status": "Packing"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "394961395352",
"properties": {
"hs_order_name": "Office supplies",
"hs_currency_code": "USD",
"hs_fulfillment_status": "Shipped"
},
"createdAt": "2025-01-15T10:35:00.000Z",
"updatedAt": "2025-01-15T10:35:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-16T08:00:00.000Z",
"completedAt": "2025-01-16T08:00:01.000Z"
}
Create a batch of orders

Signature: post /batch/create

Creates multiple order objects in a single request.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectInputForCreateYesBatch input containing an array of order objects to create.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

orders:BatchResponseSimplePublicObject|orders:BatchResponseSimplePublicObjectWithErrors response =
check ordersClient->/batch/create.post({
inputs: [
{
associations: [
{
types: [
{
associationCategory: "HUBSPOT_DEFINED",
associationTypeId: 512
}
],
to: {id: "31440573867"}
}
],
properties: {
"hs_currency_code": "USD",
"hs_order_name": "Bulk Order 1"
}
},
{
associations: [],
properties: {
"hs_currency_code": "USD",
"hs_order_name": "Bulk Order 2"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "394961395353",
"properties": {
"hs_order_name": "Bulk Order 1",
"hs_currency_code": "USD"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
},
{
"id": "394961395354",
"properties": {
"hs_order_name": "Bulk Order 2",
"hs_currency_code": "USD"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-15T10:30:00.000Z",
"completedAt": "2025-01-15T10:30:01.000Z"
}
Update a batch of orders

Signature: post /batch/update

Updates multiple order objects in a single request.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectBatchInputYesBatch input containing an array of order updates with IDs and properties.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

orders:BatchResponseSimplePublicObject|orders:BatchResponseSimplePublicObjectWithErrors response =
check ordersClient->/batch/update.post({
inputs: [
{
id: orderId1,
properties: {
"hs_fulfillment_status": "Delivered"
}
},
{
id: orderId2,
properties: {
"hs_fulfillment_status": "Shipped"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "394961395351",
"properties": {
"hs_order_name": "Camping supplies",
"hs_fulfillment_status": "Delivered"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-16T08:00:00.000Z",
"archived": false
},
{
"id": "394961395352",
"properties": {
"hs_order_name": "Office supplies",
"hs_fulfillment_status": "Shipped"
},
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-16T08:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-16T08:00:00.000Z",
"completedAt": "2025-01-16T08:00:01.000Z"
}
Create or update a batch of orders by unique property values

Signature: post /batch/upsert

Creates or updates multiple order objects in a single request, matched by a unique property.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectBatchInputUpsertYesBatch input containing an array of order upsert objects with IDs and properties.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error

Sample code:

orders:BatchResponseSimplePublicUpsertObject|orders:BatchResponseSimplePublicUpsertObjectWithErrors response =
check ordersClient->/batch/upsert.post({
inputs: [
{
id: "unique-order-key-1",
idProperty: "hs_order_name",
properties: {
"hs_order_name": "unique-order-key-1",
"hs_currency_code": "USD",
"hs_fulfillment_status": "Packing"
}
}
]
});

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "394961395355",
"properties": {
"hs_order_name": "unique-order-key-1",
"hs_currency_code": "USD",
"hs_fulfillment_status": "Packing"
},
"new": true,
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z",
"archived": false
}
],
"startedAt": "2025-01-15T10:30:00.000Z",
"completedAt": "2025-01-15T10:30:01.000Z"
}
Archive a batch of orders by ID

Signature: post /batch/archive

Archives (soft-deletes) multiple order objects in a single request.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectIdYesBatch input containing an array of order IDs to archive.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: error?

Sample code:

check ordersClient->/batch/archive.post({
inputs: [
{id: orderId1},
{id: orderId2}
]
});
Search

Signature: post /search

Searches for order objects using filters, query text, sorting, and property selection.

Parameters:

NameTypeRequiredDescription
payloadPublicObjectSearchRequestYesSearch request with optional query, filterGroups, sorts, properties, limit, and after.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: CollectionResponseWithTotalSimplePublicObjectForwardPaging|error

Sample code:

orders:CollectionResponseWithTotalSimplePublicObjectForwardPaging response =
check ordersClient->/search.post({
query: "apple",
properties: ["hs_order_name", "hs_currency_code"],
filterGroups: [
{
filters: [
{
propertyName: "hs_order_name",
operator: "EQ",
value: "New Order Example"
}
]
}
]
});

Sample response:

{
"total": 1,
"results": [
{
"id": "394961395351",
"properties": {
"hs_order_name": "New Order Example",
"hs_currency_code": "USD",
"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": {}
}