Skip to main content

Actions

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

ClientPurpose
ClientManage association definitions and configurations between HubSpot CRM object types.

Client

Manage association definitions and configurations between HubSpot CRM object types.

Configuration

FieldTypeDefaultDescription
authhttp:BearerTokenConfig|OAuth2RefreshTokenGrantConfig|ApiKeysConfigRequiredOAuth 2.0 refresh token config, bearer token, or API key config.
httpVersionhttp:HttpVersionHTTP_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.
compressionhttp:CompressionCOMPRESSION_AUTOCompression configuration.
circuitBreakerhttp:CircuitBreakerConfig()Circuit breaker configuration.
cachehttp:CacheConfig{}HTTP cache configuration.
validationbooleantrueEnable/disable payload validation.
laxDataBindingbooleantrueEnable/disable lax data binding.

Initializing the client

import ballerina/oauth2;
import ballerinax/hubspot.crm.associations.schema as hsschema;

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

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

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

Operations

Association definitions (labels)

Read association definitions between two object types

Signature: get [string fromObjectType]/[string toObjectType]/labels

Retrieves all association definitions (labels) between two specified CRM object types.

Parameters:

NameTypeRequiredDescription
fromObjectTypestringYesThe source object type (e.g., "contacts", "companies").
toObjectTypestringYesThe target object type (e.g., "deals", "companies").
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: CollectionResponseAssociationSpecWithLabelNoPaging|error

Sample code:

hsschema:CollectionResponseAssociationSpecWithLabelNoPaging associations =
check hubspot->/["contacts"]/["deals"]/labels;

Sample response:

{
"results": [
{
"typeId": 3,
"label": null,
"category": "HUBSPOT_DEFINED"
},
{
"typeId": 4,
"label": null,
"category": "HUBSPOT_DEFINED"
}
]
}
Create a user-defined association definition

Signature: post [string fromObjectType]/[string toObjectType]/labels

Creates a new user-defined association definition with a label and optional inverse label between two CRM object types.

Parameters:

NameTypeRequiredDescription
fromObjectTypestringYesThe source object type.
toObjectTypestringYesThe target object type.
payloadPublicAssociationDefinitionCreateRequestYesThe association definition to create, including name, optional label, and optional inverseLabel.
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: CollectionResponseAssociationSpecWithLabelNoPaging|error

Sample code:

hsschema:PublicAssociationDefinitionCreateRequest payload = {
name: "Headquarters_Franchise",
label: "Franchise company",
inverseLabel: "Headquarters company"
};

hsschema:CollectionResponseAssociationSpecWithLabelNoPaging result =
check hubspot->/["companies"]/["companies"]/labels.post(payload);

Sample response:

{
"results": [
{
"typeId": 35,
"label": "Franchise company",
"category": "USER_DEFINED"
},
{
"typeId": 36,
"label": "Headquarters company",
"category": "USER_DEFINED"
}
]
}
Update a user-defined association definition

Signature: put [string fromObjectType]/[string toObjectType]/labels

Updates the label and inverse label of an existing user-defined association definition.

Parameters:

NameTypeRequiredDescription
fromObjectTypestringYesThe source object type.
toObjectTypestringYesThe target object type.
payloadPublicAssociationDefinitionUpdateRequestYesThe update payload including associationTypeId, label, and optional inverseLabel.
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: error?

Sample code:

hsschema:PublicAssociationDefinitionUpdateRequest payload = {
associationTypeId: 35,
label: "Franchise company updated",
inverseLabel: "Headquarters company updated"
};

check hubspot->/["companies"]/["companies"]/labels.put(payload);
Delete an association definition

Signature: delete [string fromObjectType]/[string toObjectType]/labels/[int:Signed32 associationTypeId]

Deletes a user-defined association definition by its type ID.

Parameters:

NameTypeRequiredDescription
fromObjectTypestringYesThe source object type.
toObjectTypestringYesThe target object type.
associationTypeIdint:Signed32YesThe ID of the association type to delete.
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: error?

Sample code:

check hubspot->/["companies"]/["companies"]/labels/[35].delete();

Association configurations

Retrieve all association configurations

Signature: get definitions/configurations/all

Retrieves all association definition configurations across all object types.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: CollectionResponsePublicAssociationDefinitionUserConfigurationNoPaging|error

Sample code:

hsschema:CollectionResponsePublicAssociationDefinitionUserConfigurationNoPaging configs =
check hubspot->/definitions/configurations/all;

Sample response:

{
"results": [
{
"typeId": 3,
"category": "HUBSPOT_DEFINED",
"label": null,
"userEnforcedMaxToObjectIds": 1
},
{
"typeId": 449,
"category": "HUBSPOT_DEFINED",
"label": null,
"userEnforcedMaxToObjectIds": 5
}
]
}
Retrieve configurations between two object types

Signature: get definitions/configurations/[string fromObjectType]/[string toObjectType]

Retrieves association configurations between two specified CRM object types.

Parameters:

NameTypeRequiredDescription
fromObjectTypestringYesThe source object type.
toObjectTypestringYesThe target object type.
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: CollectionResponsePublicAssociationDefinitionUserConfigurationNoPaging|error

Sample code:

hsschema:CollectionResponsePublicAssociationDefinitionUserConfigurationNoPaging configs =
check hubspot->/definitions/configurations/["contacts"]/["contacts"];

Sample response:

{
"results": [
{
"typeId": 449,
"category": "HUBSPOT_DEFINED",
"label": null,
"userEnforcedMaxToObjectIds": 2
}
]
}
Batch create association configurations

Signature: post definitions/configurations/[string fromObjectType]/[string toObjectType]/batch/create

Creates multiple association configurations in a single batch request, setting cardinality constraints.

Parameters:

NameTypeRequiredDescription
fromObjectTypestringYesThe source object type.
toObjectTypestringYesThe target object type.
payloadBatchInputPublicAssociationDefinitionConfigurationCreateRequestYesBatch of configuration create requests, each with typeId, category, and maxToObjectIds.
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: BatchResponsePublicAssociationDefinitionUserConfiguration|BatchResponsePublicAssociationDefinitionUserConfigurationWithErrors|error

Sample code:

hsschema:BatchInputPublicAssociationDefinitionConfigurationCreateRequest payload = {
inputs: [
{
typeId: 449,
category: "HUBSPOT_DEFINED",
maxToObjectIds: 5
}
]
};

hsschema:BatchResponsePublicAssociationDefinitionUserConfiguration|
hsschema:BatchResponsePublicAssociationDefinitionUserConfigurationWithErrors result =
check hubspot->/definitions/configurations/["contacts"]/["contacts"]/batch/create(payload);

Sample response:

{
"completedAt": "2025-01-15T10:30:00.000Z",
"startedAt": "2025-01-15T10:29:59.000Z",
"results": [
{
"typeId": 449,
"category": "HUBSPOT_DEFINED",
"userEnforcedMaxToObjectIds": 5
}
],
"status": "COMPLETE"
}
Batch update association configurations

Signature: post definitions/configurations/[string fromObjectType]/[string toObjectType]/batch/update

Updates multiple association configurations in a single batch request.

Parameters:

NameTypeRequiredDescription
fromObjectTypestringYesThe source object type.
toObjectTypestringYesThe target object type.
payloadBatchInputPublicAssociationDefinitionConfigurationUpdateRequestYesBatch of configuration update requests, each with typeId, category, and maxToObjectIds.
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: BatchResponsePublicAssociationDefinitionConfigurationUpdateResult|BatchResponsePublicAssociationDefinitionConfigurationUpdateResultWithErrors|error

Sample code:

hsschema:BatchInputPublicAssociationDefinitionConfigurationUpdateRequest payload = {
inputs: [
{
typeId: 449,
category: "HUBSPOT_DEFINED",
maxToObjectIds: 10
}
]
};

hsschema:BatchResponsePublicAssociationDefinitionConfigurationUpdateResult|
hsschema:BatchResponsePublicAssociationDefinitionConfigurationUpdateResultWithErrors result =
check hubspot->/definitions/configurations/["contacts"]/["contacts"]/batch/update(payload);

Sample response:

{
"completedAt": "2025-01-15T11:00:00.000Z",
"startedAt": "2025-01-15T10:59:59.000Z",
"results": [
{
"typeId": 449,
"category": "HUBSPOT_DEFINED",
"userEnforcedMaxToObjectIds": 10
}
],
"status": "COMPLETE"
}
Batch delete association configurations

Signature: post definitions/configurations/[string fromObjectType]/[string toObjectType]/batch/purge

Deletes multiple association configurations in a single batch request.

Parameters:

NameTypeRequiredDescription
fromObjectTypestringYesThe source object type.
toObjectTypestringYesThe target object type.
payloadBatchInputPublicAssociationSpecYesBatch of association specs to delete, each with typeId and category.
headersmap<string|string[]>NoOptional custom HTTP headers.

Returns: error?

Sample code:

hsschema:BatchInputPublicAssociationSpec payload = {
inputs: [
{
typeId: 449,
category: "HUBSPOT_DEFINED"
}
]
};

check hubspot->/definitions/configurations/["contacts"]/["contacts"]/batch/purge(payload);