Actions
The ballerinax/hubspot.crm.owners package exposes the following clients:
| Client | Purpose |
|---|---|
Client | Access the HubSpot Owners API to list and retrieve owner information. |
Client
Access the HubSpot Owners API to list and retrieve owner information.
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
auth | http:BearerTokenConfig|OAuth2RefreshTokenGrantConfig|ApiKeysConfig | Required | Authentication configuration: OAuth 2.0 refresh token, bearer token, or API keys. |
httpVersion | http:HttpVersion | http:HTTP_2_0 | HTTP protocol version. |
timeout | decimal | 30 | Request timeout in seconds. |
retryConfig | http:RetryConfig? | () | Retry configuration for failed requests. |
secureSocket | http:ClientSecureSocket? | () | SSL/TLS configuration. |
proxy | http:ProxyConfig? | () | Proxy server configuration. |
circuitBreaker | http:CircuitBreakerConfig? | () | Circuit breaker configuration for fault tolerance. |
compression | http:Compression | http:COMPRESSION_AUTO | HTTP compression configuration. |
validation | boolean | true | Enable/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:
| Name | Type | Required | Description |
|---|---|---|---|
email | string? | No | Filter results by owner email address. |
after | string? | No | Pagination cursor token for the next page of results. |
'limit | int:Signed32 | No | Maximum number of results to return per page (default 100). |
archived | boolean | No | Whether 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:
| Name | Type | Required | Description |
|---|---|---|---|
ownerId | int:Signed32 | Yes | The numeric ID of the owner (path parameter). |
idProperty | "id"|"userId" | No | Which property to use for lookup: "id" (default) or "userId". |
archived | boolean | No | Whether 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"
}