Class: HubSpotSDK::Resources::Crm::Objects::Leads::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/crm/objects/leads/batch.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Batch

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Batch.

Parameters:



142
143
144
# File 'lib/hubspot_sdk/resources/crm/objects/leads/batch.rb', line 142

def initialize(client:)
  @client = client
end

Instance Method Details

#create(inputs:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::BatchResponseSimplePublicObject

Create multiple lead records in a single request by providing a batch of lead data. This endpoint allows for efficient creation of leads by processing them together, which can be useful for syncing data from other systems or importing large datasets.



22
23
24
25
26
27
28
29
30
31
# File 'lib/hubspot_sdk/resources/crm/objects/leads/batch.rb', line 22

def create(params)
  parsed, options = HubSpotSDK::Crm::Objects::Leads::BatchCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "crm/objects/2026-03/leads/batch/create",
    body: parsed,
    model: HubSpotSDK::Crm::BatchResponseSimplePublicObject,
    options: options
  )
end

#delete(inputs:, request_options: {}) ⇒ nil

Archive multiple leads by their IDs in a single request, moving them to the recycling bin.

Parameters:

Returns:

  • (nil)

See Also:



68
69
70
71
72
73
74
75
76
77
# File 'lib/hubspot_sdk/resources/crm/objects/leads/batch.rb', line 68

def delete(params)
  parsed, options = HubSpotSDK::Crm::Objects::Leads::BatchDeleteParams.dump_request(params)
  @client.request(
    method: :post,
    path: "crm/objects/2026-03/leads/batch/archive",
    body: parsed,
    model: NilClass,
    options: options
  )
end

#get(inputs:, properties:, properties_with_history:, archived: nil, id_property: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::BatchResponseSimplePublicObject

Some parameter documentations has been truncated, see Models::Crm::Objects::Leads::BatchGetParams for more details.

Retrieve records by record ID or include the ‘idProperty` parameter to retrieve records by a custom unique value property.

Parameters:

  • inputs (Array<HubSpotSDK::Models::Crm::SimplePublicObjectID>)

    Body param

  • properties (Array<String>)

    Body param: Key-value pairs for setting properties for the new object.

  • properties_with_history (Array<String>)

    Body param: Key-value pairs for setting properties for the new object and their

  • archived (Boolean)

    Query param: Whether to return only results that have been archived.

  • id_property (String)

    Body param: When using a custom unique value property to retrieve records, the n

  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/hubspot_sdk/resources/crm/objects/leads/batch.rb', line 102

def get(params)
  query_params = [:archived]
  parsed, options = HubSpotSDK::Crm::Objects::Leads::BatchGetParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :post,
    path: "crm/objects/2026-03/leads/batch/read",
    query: query,
    body: parsed.except(*query_params),
    model: HubSpotSDK::Crm::BatchResponseSimplePublicObject,
    options: options
  )
end

#update(inputs:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::BatchResponseSimplePublicObject

Update multiple lead records using their internal IDs or unique property values. This endpoint allows batch processing of updates, where each lead’s properties can be modified based on the provided input. Ensure that the properties being updated exist on the lead objects to avoid errors.



46
47
48
49
50
51
52
53
54
55
# File 'lib/hubspot_sdk/resources/crm/objects/leads/batch.rb', line 46

def update(params)
  parsed, options = HubSpotSDK::Crm::Objects::Leads::BatchUpdateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "crm/objects/2026-03/leads/batch/update",
    body: parsed,
    model: HubSpotSDK::Crm::BatchResponseSimplePublicObject,
    options: options
  )
end

#upsert(inputs:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::BatchResponseSimplePublicUpsertObject

Create or update records identified by a unique property value as specified by the ‘idProperty` query param. `idProperty` query param refers to a property whose values are unique for the object.



128
129
130
131
132
133
134
135
136
137
# File 'lib/hubspot_sdk/resources/crm/objects/leads/batch.rb', line 128

def upsert(params)
  parsed, options = HubSpotSDK::Crm::Objects::Leads::BatchUpsertParams.dump_request(params)
  @client.request(
    method: :post,
    path: "crm/objects/2026-03/leads/batch/upsert",
    body: parsed,
    model: HubSpotSDK::Crm::BatchResponseSimplePublicUpsertObject,
    options: options
  )
end