Skip to main content

Actions

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

ClientPurpose
ClientAccess the HubSpot Owners API to list and retrieve owner information.

Client

Access the HubSpot Owners API to list and retrieve owner information.

Configuration

FieldTypeDefaultDescription
authhttp:BearerTokenConfig|OAuth2RefreshTokenGrantConfig|ApiKeysConfigRequiredAuthentication configuration: OAuth 2.0 refresh token, bearer token, or API keys.
httpVersionhttp:HttpVersionhttp:HTTP_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:Compressionhttp:COMPRESSION_AUTOHTTP compression configuration.
validationbooleantrueEnable/disable payload validation.

Initializing the client

import ballerina/oauth2;
import ballerinax/hubspot.crm.owners as hsowners;

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

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

hsowners:Client hubspot = check new ({auth});

Operations

Owner retrieval

Get a page of owners

Signature: get /

Retrieves a paginated list of owners for the account. Supports filtering by email address and pagination.

Parameters:

NameTypeRequiredDescription
emailstring?NoFilter results by owner email address.
afterstring?NoPagination cursor token for the next page of results.
'limitint:Signed32NoMaximum number of results to return per page (default 100).
archivedbooleanNoWhether to return only archived owners (default false).

Returns: CollectionResponsePublicOwnerForwardPaging|error

Sample code:

hsowners:CollectionResponsePublicOwnerForwardPaging response = check hubspot->/();
foreach hsowners:PublicOwner owner in response.results {
// Access owner details: owner.email, owner.id, owner.firstName, etc.
}

Sample response:

{
"results": [
{
"id": "12345",
"email": "[email protected]",
"type": "PERSON",
"firstName": "John",
"lastName": "Smith",
"userId": 9876543,
"userIdIncludingInactive": 9876543,
"archived": false,
"teams": [
{
"id": "101",
"name": "Sales Team",
"primary": true
}
],
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-06-20T14:22:00.000Z"
}
],
"paging": {
"next": {
"after": "NTI1Cg%3D%3D",
"link": "?after=NTI1Cg%3D%3D"
}
}
}
Read an owner by given id or userId

Signature: get /[int:Signed32 ownerId]

Retrieves a single owner by their numeric owner ID or userId.

Parameters:

NameTypeRequiredDescription
ownerIdint:Signed32YesThe numeric ID of the owner (path parameter).
idProperty"id"|"userId"NoWhich property to use for lookup: "id" (default) or "userId".
archivedbooleanNoWhether to return only archived owners (default false).

Returns: PublicOwner|error

Sample code:

hsowners:PublicOwner owner = check hubspot->/[12345]();

Sample response:

{
"id": "12345",
"email": "[email protected]",
"type": "PERSON",
"firstName": "John",
"lastName": "Smith",
"userId": 9876543,
"userIdIncludingInactive": 9876543,
"archived": false,
"teams": [
{
"id": "101",
"name": "Sales Team",
"primary": true
}
],
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-06-20T14:22:00.000Z"
}