Skip to main content

Actions

The ballerinax/hubspot.crm.obj.lineitems package exposes the following clients:

ClientPurpose
ClientProvides full CRUD, batch operations, and search for HubSpot CRM Line Item records.

Client

Provides full CRUD, batch operations, and search for HubSpot CRM Line Item records.

Configuration

FieldTypeDefaultDescription
authOAuth2RefreshTokenGrantConfig|http:BearerTokenConfig|ApiKeysConfigRequiredAuthentication configuration: OAuth 2.0 refresh token, bearer token (Private App), or API key headers.
serviceUrlstring"https://api.hubapi.com/crm/v3/objects/line_items"Base URL of the HubSpot CRM Line Items API.
httpVersionHttpVersionHTTP_2_0HTTP protocol version to use.
timeoutdecimal30Request timeout in seconds.
retryConfigRetryConfig()Retry configuration for failed requests.
secureSocketClientSecureSocket()SSL/TLS configuration.
proxyProxyConfig()Proxy server configuration.
validationbooleantrueEnable/disable constraint validation on request/response payloads.

Initializing the client

import ballerinax/hubspot.crm.obj.lineitems as hslineitems;

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

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

Operations

Single record operations

List a page of line items

Retrieves a paginated list of line item records, with optional property filtering and association expansion.

Parameters:

NameTypeRequiredDescription
queriesGetCrmV3ObjectsLineItemsGetPageQueriesNoOptional query parameters including limit, after (pagination cursor), properties, propertiesWithHistory, associations, and archived.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error

Sample code:

hslineitems:CollectionResponseSimplePublicObjectWithAssociationsForwardPaging response =
check hsLineItems->/.get(queries = {
'limit: 10,
properties: ["name", "price", "quantity"]
});

Sample response:

{
"results": [
{
"id": "12345",
"properties": {
"name": "Wired Keyboard",
"price": "2400.00",
"quantity": "5",
"hs_object_id": "12345",
"createdate": "2025-01-15T10:00:00.000Z",
"hs_lastmodifieddate": "2025-01-20T12:30:00.000Z"
},
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-20T12:30:00.000Z",
"archived": false
}
],
"paging": {
"next": {
"after": "NTI1Cg%3D%3D",
"link": "https://api.hubapi.com/crm/v3/objects/line_items?after=NTI1Cg%3D%3D"
}
}
}
Create a line item

Creates a new line item record in HubSpot CRM with the specified properties and optional deal associations.

Parameters:

NameTypeRequiredDescription
payloadSimplePublicObjectInputForCreateYesLine item properties (e.g., name, price, quantity) and optional associations.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: SimplePublicObject|error

Sample code:

hslineitems:SimplePublicObject newItem = check hsLineItems->/.post(
payload = {
properties: {
"name": "Wired Keyboard",
"price": "2400.00",
"quantity": "5"
},
associations: []
}
);

Sample response:

{
"id": "67890",
"properties": {
"name": "Wired Keyboard",
"price": "2400.00",
"quantity": "5",
"hs_object_id": "67890",
"createdate": "2025-03-18T09:00:00.000Z",
"hs_lastmodifieddate": "2025-03-18T09:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T09:00:00.000Z",
"archived": false
}
Read a line item

Retrieves a single line item record by its HubSpot ID, including properties, associations, and optional property history.

Parameters:

NameTypeRequiredDescription
lineItemIdstringYesThe HubSpot ID of the line item to retrieve.
queriesGetCrmV3ObjectsLineItemsLineItemIdGetByIdQueriesNoOptional query parameters including properties, propertiesWithHistory, associations, idProperty, and archived.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: SimplePublicObjectWithAssociations|error

Sample code:

hslineitems:SimplePublicObjectWithAssociations lineItem =
check hsLineItems->/["67890"].get(
queries = {
properties: ["name", "price", "quantity"]
}
);

Sample response:

{
"id": "67890",
"properties": {
"name": "Wired Keyboard",
"price": "2400.00",
"quantity": "5",
"hs_object_id": "67890",
"createdate": "2025-03-18T09:00:00.000Z",
"hs_lastmodifieddate": "2025-03-18T09:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T09:00:00.000Z",
"archived": false,
"associations": {}
}
Update a line item

Performs a partial update on a line item record, modifying only the supplied property fields.

Parameters:

NameTypeRequiredDescription
lineItemIdstringYesThe HubSpot ID of the line item to update.
payloadSimplePublicObjectInputYesProperties to update on the line item.
queriesPatchCrmV3ObjectsLineItemsLineItemIdUpdateQueriesNoOptional query parameters including idProperty for alternate ID lookup.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: SimplePublicObject|error

Sample code:

hslineitems:SimplePublicObject updated = check hsLineItems->/["67890"].patch(
payload = {
properties: {
"price": "2700.00",
"quantity": "3"
}
}
);

Sample response:

{
"id": "67890",
"properties": {
"name": "Wired Keyboard",
"price": "2700.00",
"quantity": "3",
"hs_object_id": "67890",
"createdate": "2025-03-18T09:00:00.000Z",
"hs_lastmodifieddate": "2025-03-18T11:45:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T11:45:00.000Z",
"archived": false
}
Archive a line item

Archives (soft-deletes) a single line item by its HubSpot ID. Archived records can be restored later.

Parameters:

NameTypeRequiredDescription
lineItemIdstringYesThe HubSpot ID of the line item to archive.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: error?

Sample code:

check hsLineItems->/["67890"].delete();

Batch operations

Create a batch of line items

Creates multiple line items in a single API call, each with its own properties and optional associations.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectInputForCreateYesArray of line item inputs to create, each containing properties and optional associations.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

hslineitems:BatchResponseSimplePublicObject batchResult =
check hsLineItems->/batch/create.post(
payload = {
inputs: [
{
properties: {
"name": "Dining Table",
"price": "55000.00",
"quantity": "1"
},
associations: [
{
types: [{
associationCategory: "HUBSPOT_DEFINED",
associationTypeId: 20
}],
to: {id: "31232284502"}
}
]
},
{
properties: {
"name": "Office Chair",
"price": "12000.00",
"quantity": "3"
},
associations: [
{
types: [{
associationCategory: "HUBSPOT_DEFINED",
associationTypeId: 20
}],
to: {id: "31232284502"}
}
]
}
]
}
);

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "11111",
"properties": {
"name": "Dining Table",
"price": "55000.00",
"quantity": "1",
"hs_object_id": "11111",
"createdate": "2025-03-18T09:00:00.000Z",
"hs_lastmodifieddate": "2025-03-18T09:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T09:00:00.000Z",
"archived": false
},
{
"id": "11112",
"properties": {
"name": "Office Chair",
"price": "12000.00",
"quantity": "3",
"hs_object_id": "11112",
"createdate": "2025-03-18T09:00:00.000Z",
"hs_lastmodifieddate": "2025-03-18T09:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T09:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-03-18T09:00:00.000Z",
"completedAt": "2025-03-18T09:00:01.000Z"
}
Read a batch of line items by internal ID, or unique property values

Retrieves a batch of line items by their HubSpot IDs in a single request, with optional property and history filtering.

Parameters:

NameTypeRequiredDescription
payloadBatchReadInputSimplePublicObjectIdYesObject IDs to fetch plus the list of properties and propertiesWithHistory to include in each result.
queriesPostCrmV3ObjectsLineItemsBatchReadReadQueriesNoOptional query params: archived (default false) to include archived records.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

hslineitems:BatchResponseSimplePublicObject batchRead =
check hsLineItems->/batch/read.post(
payload = {
inputs: [{id: "11111"}, {id: "11112"}],
properties: ["name", "price", "quantity"],
propertiesWithHistory: ["price"]
}
);

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "11111",
"properties": {
"name": "Dining Table",
"price": "55000.00",
"quantity": "1"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T09:00:00.000Z",
"archived": false
},
{
"id": "11112",
"properties": {
"name": "Office Chair",
"price": "12000.00",
"quantity": "3"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T09:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-03-18T09:00:00.000Z",
"completedAt": "2025-03-18T09:00:01.000Z"
}
Update a batch of line items

Updates properties on multiple line items in a single request using their HubSpot IDs.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectBatchInputYesArray of update inputs, each specifying a line item id and the properties to modify.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error

Sample code:

hslineitems:BatchResponseSimplePublicObject updateResult =
check hsLineItems->/batch/update.post(
payload = {
inputs: [
{id: "11111", properties: {"quantity": "2"}},
{id: "11112", properties: {"quantity": "2"}}
]
}
);

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "11111",
"properties": {
"name": "Dining Table",
"price": "55000.00",
"quantity": "2",
"hs_lastmodifieddate": "2025-03-18T12:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T12:00:00.000Z",
"archived": false
},
{
"id": "11112",
"properties": {
"name": "Office Chair",
"price": "12000.00",
"quantity": "2",
"hs_lastmodifieddate": "2025-03-18T12:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T12:00:00.000Z",
"archived": false
}
],
"startedAt": "2025-03-18T12:00:00.000Z",
"completedAt": "2025-03-18T12:00:01.000Z"
}
Archive a batch of line items by ID

Archives multiple line items at once by their HubSpot IDs.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectIdYesArray of { id: string } objects identifying the line items to archive.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: error?

Sample code:

check hsLineItems->/batch/archive.post(
payload = {
inputs: [{id: "11111"}, {id: "11112"}]
}
);
Upsert a batch of line items

Creates or updates line items in bulk using a unique identifier property: creates a new record if no match is found, updates the existing record if a match is found.

Parameters:

NameTypeRequiredDescription
payloadBatchInputSimplePublicObjectBatchInputUpsertYesArray of upsert inputs each with an id, optional idProperty, and properties to set.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error

Sample code:

hslineitems:BatchResponseSimplePublicUpsertObject upsertResult =
check hsLineItems->/batch/upsert.post(
payload = {
inputs: [
{
id: "sku-keyboard-001",
idProperty: "hs_sku",
properties: {
"name": "Wired Keyboard",
"price": "2400.00",
"quantity": "10"
}
}
]
}
);

Sample response:

{
"status": "COMPLETE",
"results": [
{
"id": "67890",
"properties": {
"name": "Wired Keyboard",
"price": "2400.00",
"quantity": "10",
"hs_object_id": "67890",
"hs_lastmodifieddate": "2025-03-18T12:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T12:00:00.000Z",
"archived": false,
"new": false
}
],
"startedAt": "2025-03-18T12:00:00.000Z",
"completedAt": "2025-03-18T12:00:01.000Z"
}
Search line items

Searches HubSpot CRM line item records using keyword queries, filter groups, sorting, and pagination.

Parameters:

NameTypeRequiredDescription
payloadPublicObjectSearchRequestYesSearch request with optional query (keyword), filterGroups, sorts, properties, limit, and after cursor.
headersmap<string|string[]>NoAdditional HTTP headers.

Returns: CollectionResponseWithTotalSimplePublicObjectForwardPaging|error

Sample code:

hslineitems:CollectionResponseWithTotalSimplePublicObjectForwardPaging searchResult =
check hsLineItems->/search.post(
payload = {
query: "Chair",
'limit: 5,
sorts: ["price"],
properties: ["name", "price", "quantity"]
}
);

Sample response:

{
"total": 3,
"results": [
{
"id": "11112",
"properties": {
"name": "Office Chair",
"price": "12000.00",
"quantity": "2",
"hs_object_id": "11112",
"createdate": "2025-03-18T09:00:00.000Z",
"hs_lastmodifieddate": "2025-03-18T12:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T12:00:00.000Z",
"archived": false
},
{
"id": "11113",
"properties": {
"name": "Casual Chair",
"price": "8500.00",
"quantity": "2",
"hs_object_id": "11113",
"createdate": "2025-03-18T09:00:00.000Z",
"hs_lastmodifieddate": "2025-03-18T12:00:00.000Z"
},
"createdAt": "2025-03-18T09:00:00.000Z",
"updatedAt": "2025-03-18T12:00:00.000Z",
"archived": false
}
]
}