Skip to main content

Actions

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

ClientPurpose
ClientManage HubSpot CRM pipelines and pipeline stages via the Pipelines REST API.

Client

Manage HubSpot CRM pipelines and pipeline stages via the Pipelines REST API.

Configuration

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

Initializing the client

import ballerina/oauth2;
import ballerinax/hubspot.crm.pipelines as hspipelines;

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

final hspipelines:OAuth2RefreshTokenGrantConfig auth = {
clientId,
clientSecret,
refreshToken,
credentialBearer: oauth2:POST_BODY_BEARER
};

final hspipelines:Client hubSpotPipelines = check new ({auth});

Operations

Pipeline operations

List all pipelines

Signature: get /[string objectType]

Returns all pipelines for the specified object type.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type (e.g., "deals", "tickets", "orders").
headersmap<string|string[]>NoOptional HTTP headers.

Returns: CollectionResponsePipelineNoPaging|error

Sample code:

hspipelines:CollectionResponsePipelineNoPaging pipelines = check hubSpotPipelines->/orders;

Sample response:

{
"results": [
{
"id": "67890",
"label": "Orders Pipeline",
"displayOrder": 0,
"archived": false,
"stages": [
{
"id": "11111",
"label": "Order Received",
"displayOrder": 0,
"archived": false,
"metadata": {"probability": "0.1"},
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z"
}
],
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z"
}
]
}
Create a pipeline

Signature: post /[string objectType]

Creates a new pipeline for the specified object type with the given stages.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type (e.g., "deals", "tickets", "orders").
payloadPipelineInputYesPipeline definition including label, display order, and stages.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: Pipeline|error

Sample code:

hspipelines:Pipeline pipeline = check hubSpotPipelines->/orders.post({
label: "Orders Pipeline",
displayOrder: 0,
stages: [
{label: "Order Received", displayOrder: 0, metadata: {"probability": "0.1"}},
{label: "Processing", displayOrder: 1, metadata: {"probability": "0.3"}},
{label: "Ready for Shipment", displayOrder: 2, metadata: {"probability": "0.5"}},
{label: "Shipped", displayOrder: 3, metadata: {"probability": "0.8"}},
{label: "Delivered", displayOrder: 4, metadata: {"probability": "1.0"}}
]
});

Sample response:

{
"id": "67890",
"label": "Orders Pipeline",
"displayOrder": 0,
"archived": false,
"stages": [
{"id": "11111", "label": "Order Received", "displayOrder": 0, "archived": false, "metadata": {"probability": "0.1"}, "createdAt": "2025-01-15T10:00:00.000Z", "updatedAt": "2025-01-15T10:00:00.000Z"},
{"id": "22222", "label": "Processing", "displayOrder": 1, "archived": false, "metadata": {"probability": "0.3"}, "createdAt": "2025-01-15T10:00:00.000Z", "updatedAt": "2025-01-15T10:00:00.000Z"},
{"id": "33333", "label": "Ready for Shipment", "displayOrder": 2, "archived": false, "metadata": {"probability": "0.5"}, "createdAt": "2025-01-15T10:00:00.000Z", "updatedAt": "2025-01-15T10:00:00.000Z"},
{"id": "44444", "label": "Shipped", "displayOrder": 3, "archived": false, "metadata": {"probability": "0.8"}, "createdAt": "2025-01-15T10:00:00.000Z", "updatedAt": "2025-01-15T10:00:00.000Z"},
{"id": "55555", "label": "Delivered", "displayOrder": 4, "archived": false, "metadata": {"probability": "1.0"}, "createdAt": "2025-01-15T10:00:00.000Z", "updatedAt": "2025-01-15T10:00:00.000Z"}
],
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z"
}
Get a pipeline

Signature: get /[string objectType]/[string pipelineId]

Retrieves a single pipeline by its ID for the specified object type.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline to retrieve.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: Pipeline|error

Sample code:

hspipelines:Pipeline pipeline = check hubSpotPipelines->/orders/["67890"];

Sample response:

{
"id": "67890",
"label": "Orders Pipeline",
"displayOrder": 0,
"archived": false,
"stages": [
{"id": "11111", "label": "Order Received", "displayOrder": 0, "archived": false, "metadata": {"probability": "0.1"}, "createdAt": "2025-01-15T10:00:00.000Z", "updatedAt": "2025-01-15T10:00:00.000Z"}
],
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z"
}
Replace a pipeline

Signature: put /[string objectType]/[string pipelineId]

Replaces a pipeline entirely with the provided definition. Use this to overwrite all fields and stages.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline to replace.
payloadPipelineInputYesComplete pipeline definition to replace the existing one.
queriesPutCrmV3PipelinesObjectTypePipelineIdReplaceQueriesNoOptional query parameters for validation before deletion.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: Pipeline|error

Sample code:

hspipelines:Pipeline updated = check hubSpotPipelines->/orders/["67890"].put({
label: "Updated Orders Pipeline",
displayOrder: 0,
stages: [
{label: "New Order", displayOrder: 0, metadata: {"probability": "0.2"}},
{label: "Fulfilled", displayOrder: 1, metadata: {"probability": "1.0"}}
]
});

Sample response:

{
"id": "67890",
"label": "Updated Orders Pipeline",
"displayOrder": 0,
"archived": false,
"stages": [
{"id": "66666", "label": "New Order", "displayOrder": 0, "archived": false, "metadata": {"probability": "0.2"}, "createdAt": "2025-01-15T12:00:00.000Z", "updatedAt": "2025-01-15T12:00:00.000Z"},
{"id": "77777", "label": "Fulfilled", "displayOrder": 1, "archived": false, "metadata": {"probability": "1.0"}, "createdAt": "2025-01-15T12:00:00.000Z", "updatedAt": "2025-01-15T12:00:00.000Z"}
],
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T12:00:00.000Z"
}
Update a pipeline

Signature: patch /[string objectType]/[string pipelineId]

Partially updates a pipeline's properties (label, display order, archived status).

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline to update.
payloadPipelinePatchInputYesFields to update (label, displayOrder, archived).
queriesPatchCrmV3PipelinesObjectTypePipelineIdUpdateQueriesNoOptional query parameters for validation before deletion.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: Pipeline|error

Sample code:

hspipelines:Pipeline patched = check hubSpotPipelines->/orders/["67890"].patch({
label: "Renamed Orders Pipeline"
});

Sample response:

{
"id": "67890",
"label": "Renamed Orders Pipeline",
"displayOrder": 0,
"archived": false,
"stages": [],
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T14:00:00.000Z"
}
Delete a pipeline

Signature: delete /[string objectType]/[string pipelineId]

Archives (deletes) a pipeline by its ID.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline to delete.
queriesDeleteCrmV3PipelinesObjectTypePipelineIdArchiveQueriesNoOptional query parameters for validation before deletion.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: error?

Sample code:

check hubSpotPipelines->/orders/["67890"].delete();
Get pipeline audit log

Signature: get /[string objectType]/[string pipelineId]/audit

Returns the audit history for a pipeline, showing changes made over time.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline to audit.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: CollectionResponsePublicAuditInfoNoPaging|error

Sample code:

hspipelines:CollectionResponsePublicAuditInfoNoPaging auditLog =
check hubSpotPipelines->/orders/["67890"]/audit;

Sample response:

{
"results": [
{
"identifier": "67890",
"action": "PIPELINE_CREATE",
"timestamp": "2025-01-15T10:00:00.000Z",
"portalId": 12345678,
"fromUserId": 98765
},
{
"identifier": "67890",
"action": "PIPELINE_UPDATE",
"timestamp": "2025-01-15T14:00:00.000Z",
"portalId": 12345678,
"fromUserId": 98765,
"message": "Label changed"
}
]
}

Pipeline stage operations

List all stages in a pipeline

Signature: get /[string objectType]/[string pipelineId]/stages

Returns all stages for a specific pipeline.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: CollectionResponsePipelineStageNoPaging|error

Sample code:

hspipelines:CollectionResponsePipelineStageNoPaging stages =
check hubSpotPipelines->/tickets/["67890"]/stages;

Sample response:

{
"results": [
{
"id": "11111",
"label": "New Ticket",
"displayOrder": 0,
"archived": false,
"metadata": {"ticketStatus": "OPEN"},
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z"
},
{
"id": "22222",
"label": "Resolved",
"displayOrder": 1,
"archived": false,
"metadata": {"ticketStatus": "CLOSED"},
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z"
}
]
}
Create a pipeline stage

Signature: post /[string objectType]/[string pipelineId]/stages

Creates a new stage within a pipeline.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline to add the stage to.
payloadPipelineStageInputYesStage definition including label, display order, and optional metadata.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: PipelineStage|error

Sample code:

hspipelines:PipelineStage stage = check hubSpotPipelines->/tickets/["67890"]/stages.post({
label: "Waiting on Customer",
displayOrder: 2,
metadata: {"ticketStatus": "OPEN", "priority": "HIGH"}
});

Sample response:

{
"id": "33333",
"label": "Waiting on Customer",
"displayOrder": 2,
"archived": false,
"metadata": {"ticketStatus": "OPEN", "priority": "HIGH"},
"createdAt": "2025-01-15T11:00:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z"
}
Get a pipeline stage

Signature: get /[string objectType]/[string pipelineId]/stages/[string stageId]

Retrieves a single stage by its ID within a pipeline.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline.
stageIdstringYesThe ID of the stage to retrieve.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: PipelineStage|error

Sample code:

hspipelines:PipelineStage stage =
check hubSpotPipelines->/tickets/["67890"]/stages/["33333"];

Sample response:

{
"id": "33333",
"label": "Waiting on Customer",
"displayOrder": 2,
"archived": false,
"metadata": {"ticketStatus": "OPEN", "priority": "HIGH"},
"createdAt": "2025-01-15T11:00:00.000Z",
"updatedAt": "2025-01-15T11:00:00.000Z"
}
Replace a pipeline stage

Signature: put /[string objectType]/[string pipelineId]/stages/[string stageId]

Replaces a pipeline stage entirely with the provided definition.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline.
stageIdstringYesThe ID of the stage to replace.
payloadPipelineStageInputYesComplete stage definition to replace the existing one.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: PipelineStage|error

Sample code:

hspipelines:PipelineStage replaced =
check hubSpotPipelines->/tickets/["67890"]/stages/["33333"].put({
label: "Escalated",
displayOrder: 2,
metadata: {"ticketStatus": "OPEN", "priority": "CRITICAL"}
});

Sample response:

{
"id": "33333",
"label": "Escalated",
"displayOrder": 2,
"archived": false,
"metadata": {"ticketStatus": "OPEN", "priority": "CRITICAL"},
"createdAt": "2025-01-15T11:00:00.000Z",
"updatedAt": "2025-01-15T15:00:00.000Z"
}
Update a pipeline stage

Signature: patch /[string objectType]/[string pipelineId]/stages/[string stageId]

Partially updates a pipeline stage's properties (label, display order, metadata, archived status).

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline.
stageIdstringYesThe ID of the stage to update.
payloadPipelineStagePatchInputYesFields to update (label, displayOrder, metadata, archived).
headersmap<string|string[]>NoOptional HTTP headers.

Returns: PipelineStage|error

Sample code:

hspipelines:PipelineStage patched =
check hubSpotPipelines->/tickets/["67890"]/stages/["33333"].patch({
label: "Awaiting Response"
});

Sample response:

{
"id": "33333",
"label": "Awaiting Response",
"displayOrder": 2,
"archived": false,
"metadata": {"ticketStatus": "OPEN", "priority": "HIGH"},
"createdAt": "2025-01-15T11:00:00.000Z",
"updatedAt": "2025-01-15T16:00:00.000Z"
}
Delete a pipeline stage

Signature: delete /[string objectType]/[string pipelineId]/stages/[string stageId]

Archives (deletes) a stage from a pipeline.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline.
stageIdstringYesThe ID of the stage to delete.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: error?

Sample code:

check hubSpotPipelines->/tickets/["67890"]/stages/["33333"].delete();
Get pipeline stage audit log

Signature: get /[string objectType]/[string pipelineId]/stages/[string stageId]/audit

Returns the audit history for a specific pipeline stage.

Parameters:

NameTypeRequiredDescription
objectTypestringYesThe CRM object type.
pipelineIdstringYesThe ID of the pipeline.
stageIdstringYesThe ID of the stage to audit.
headersmap<string|string[]>NoOptional HTTP headers.

Returns: CollectionResponsePublicAuditInfoNoPaging|error

Sample code:

hspipelines:CollectionResponsePublicAuditInfoNoPaging stageAudit =
check hubSpotPipelines->/tickets/["67890"]/stages/["33333"]/audit;

Sample response:

{
"results": [
{
"identifier": "33333",
"action": "STAGE_CREATE",
"timestamp": "2025-01-15T11:00:00.000Z",
"portalId": 12345678,
"fromUserId": 98765
}
]
}