Class: HubSpotSDK::Resources::Cms::Hubdb::Tables

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/cms/hubdb/tables.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tables

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 Tables.

Parameters:



532
533
534
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 532

def initialize(client:)
  @client = client
end

Instance Method Details

#clone_draft(table_id_or_name, copy_rows:, is_hubspot_defined:, new_label: nil, new_name: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::HubDBTableV3

Clone an existing HubDB table. The ‘newName` and `newLabel` of the new table can be sent as JSON in the request body. This will create the cloned table as a draft.

Parameters:

  • table_id_or_name (String)
  • copy_rows (Boolean)

    Specifies whether to copy the rows during clone

  • is_hubspot_defined (Boolean)

    Indicates whether the table is defined by HubSpot.

  • new_label (String)

    The new label for the cloned table

  • new_name (String)

    The new name for the cloned table

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

Returns:

See Also:



148
149
150
151
152
153
154
155
156
157
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 148

def clone_draft(table_id_or_name, params)
  parsed, options = HubSpotSDK::Cms::Hubdb::TableCloneDraftParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["cms/hubdb/2026-03/tables/%1$s/draft/clone", table_id_or_name],
    body: parsed,
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

#create(allow_child_tables:, allow_public_api_access:, columns:, dynamic_meta_tags:, enable_child_table_pages:, label:, name:, use_for_pages:, request_options: {}) ⇒ HubSpotSDK::Models::Cms::HubDBTableV3

Some parameter documentations has been truncated, see Models::Cms::Hubdb::TableCreateParams for more details.

Creates a new draft HubDB table given a JSON schema. The table name and label should be unique for each account.

Parameters:

  • allow_child_tables (Boolean)

    Specifies whether child tables can be created

  • allow_public_api_access (Boolean)

    Specifies whether the table can be read by public without authorization

  • columns (Array<HubSpotSDK::Models::Cms::ColumnRequest>)

    List of columns in the table

  • dynamic_meta_tags (Hash{Symbol=>Integer})

    Specifies the key value pairs of the [metadata fields](developers.hubspo

  • enable_child_table_pages (Boolean)

    Specifies creation of multi-level dynamic pages using child tables

  • label (String)

    Label of the table

  • name (String)

    Name of the table

  • use_for_pages (Boolean)

    Specifies whether the table can be used for creation of dynamic pages

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

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 37

def create(params)
  parsed, options = HubSpotSDK::Cms::Hubdb::TableCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "cms/hubdb/2026-03/tables",
    body: parsed,
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

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

Archive (soft delete) an existing HubDB table. This archives both the published and draft versions.

Parameters:

Returns:

  • (nil)

See Also:



118
119
120
121
122
123
124
125
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 118

def delete(table_id_or_name, params = {})
  @client.request(
    method: :delete,
    path: ["cms/hubdb/2026-03/tables/%1$s", table_id_or_name],
    model: NilClass,
    options: params[:request_options]
  )
end

#delete_version(version_id, table_id_or_name:, request_options: {}) ⇒ nil

Delete a specific version of a table

Parameters:

Returns:

  • (nil)

See Also:



170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 170

def delete_version(version_id, params)
  parsed, options = HubSpotSDK::Cms::Hubdb::TableDeleteVersionParams.dump_request(params)
  table_id_or_name =
    parsed.delete(:table_id_or_name) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["cms/hubdb/2026-03/tables/%1$s/versions/%2$s", table_id_or_name, version_id],
    model: NilClass,
    options: options
  )
end

#export(table_id_or_name, format_: nil, request_options: {}) ⇒ StringIO

Exports the published version of a table in a specified format.

Parameters:

Returns:

  • (StringIO)

See Also:



195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 195

def export(table_id_or_name, params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableExportParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["cms/hubdb/2026-03/tables/%1$s/export", table_id_or_name],
    query: query.transform_keys(format_: "format"),
    headers: {"accept" => "application/vnd.ms-excel"},
    model: StringIO,
    options: options
  )
end

#export_draft(table_id_or_name, format_: nil, request_options: {}) ⇒ StringIO

Exports the draft version of a table to CSV / EXCEL format.

Parameters:

Returns:

  • (StringIO)

See Also:



219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 219

def export_draft(table_id_or_name, params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableExportDraftParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["cms/hubdb/2026-03/tables/%1$s/draft/export", table_id_or_name],
    query: query.transform_keys(format_: "format"),
    headers: {"accept" => "application/vnd.ms-excel"},
    model: StringIO,
    options: options
  )
end

#get(table_id_or_name, archived: nil, include_foreign_ids: nil, is_get_localized_schema: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::HubDBTableV3

Returns the details for the published version of the specified table. This will include the definitions for the columns in the table and the number of rows in the table.

Note: This endpoint can be accessed without any authentication if the table is set to be allowed for public access. To do so, you’ll need to include the HubSpot account ID in a ‘portalId` query parameter.

Parameters:

  • table_id_or_name (String)
  • archived (Boolean)

    Whether to return only results that have been archived.

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

Returns:

See Also:



255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 255

def get(table_id_or_name, params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableGetParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["cms/hubdb/2026-03/tables/%1$s", table_id_or_name],
    query: query.transform_keys(
      include_foreign_ids: "includeForeignIds",
      is_get_localized_schema: "isGetLocalizedSchema"
    ),
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

#get_draft(table_id_or_name, archived: nil, include_foreign_ids: nil, is_get_localized_schema: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::HubDBTableV3

Get the details for the draft version of a specific HubDB table. This will include the definitions for the columns in the table and the number of rows in the table.

Parameters:

  • table_id_or_name (String)
  • archived (Boolean)

    Whether to return only results that have been archived.

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

Returns:

See Also:



289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 289

def get_draft(table_id_or_name, params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableGetDraftParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["cms/hubdb/2026-03/tables/%1$s/draft", table_id_or_name],
    query: query.transform_keys(
      include_foreign_ids: "includeForeignIds",
      is_get_localized_schema: "isGetLocalizedSchema"
    ),
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

#import_draft(table_id_or_name, config: nil, file: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::ImportResult

Import the contents of a CSV file into an existing HubDB table. The data will always be imported into the draft version of the table. Use the ‘/publish` endpoint to push these changes to the published version. This endpoint takes a multi-part POST request. The first part will be a set of JSON-formatted options for the import and you can specify this with the name as `config`. The second part will be the CSV file you want to import and you can specify this with the name as `file`. Refer the [overview section](developers.hubspot.com/docs/api/cms/hubdb#importing-tables) to check the details and format of the JSON-formatted options for the import.

Parameters:

Returns:

See Also:



324
325
326
327
328
329
330
331
332
333
334
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 324

def import_draft(table_id_or_name, params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableImportDraftParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["cms/hubdb/2026-03/tables/%1$s/draft/import", table_id_or_name],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: HubSpotSDK::Cms::ImportResult,
    options: options
  )
end

#list(after: nil, archived: nil, content_type: nil, created_after: nil, created_at: nil, created_before: nil, is_get_localized_schema: nil, limit: nil, sort: nil, updated_after: nil, updated_at: nil, updated_before: nil, request_options: {}) ⇒ HubSpotSDK::Internal::Page<HubSpotSDK::Models::Cms::HubDBTableV3>

Some parameter documentations has been truncated, see Models::Cms::Hubdb::TableListParams for more details.

Returns the details for the published version of each table defined in an account, including column definitions.

Parameters:

  • after (String)

    The paging cursor token of the last successfully read resource will be returned

  • archived (Boolean)

    Whether to return only results that have been archived.

  • content_type (String)
  • created_after (Time)
  • created_at (Time)
  • created_before (Time)
  • is_get_localized_schema (Boolean)
  • limit (Integer)

    The maximum number of results to display per page.

  • sort (Array<String>)
  • updated_after (Time)
  • updated_at (Time)
  • updated_before (Time)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 85

def list(params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableListParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "cms/hubdb/2026-03/tables",
    query: query.transform_keys(
      content_type: "contentType",
      created_after: "createdAfter",
      created_at: "createdAt",
      created_before: "createdBefore",
      is_get_localized_schema: "isGetLocalizedSchema",
      updated_after: "updatedAfter",
      updated_at: "updatedAt",
      updated_before: "updatedBefore"
    ),
    page: HubSpotSDK::Internal::Page,
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

#list_draft(after: nil, archived: nil, content_type: nil, created_after: nil, created_at: nil, created_before: nil, is_get_localized_schema: nil, limit: nil, sort: nil, updated_after: nil, updated_at: nil, updated_before: nil, request_options: {}) ⇒ HubSpotSDK::Internal::Page<HubSpotSDK::Models::Cms::HubDBTableV3>

Some parameter documentations has been truncated, see Models::Cms::Hubdb::TableListDraftParams for more details.

Returns the details for each draft table defined in the specified account, including column definitions.

Parameters:

  • after (String)

    The paging cursor token of the last successfully read resource will be returned

  • archived (Boolean)

    Whether to return only results that have been archived.

  • content_type (String)
  • created_after (Time)
  • created_at (Time)
  • created_before (Time)
  • is_get_localized_schema (Boolean)
  • limit (Integer)

    The maximum number of results to display per page.

  • sort (Array<String>)
  • updated_after (Time)
  • updated_at (Time)
  • updated_before (Time)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 373

def list_draft(params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableListDraftParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "cms/hubdb/2026-03/tables/draft",
    query: query.transform_keys(
      content_type: "contentType",
      created_after: "createdAfter",
      created_at: "createdAt",
      created_before: "createdBefore",
      is_get_localized_schema: "isGetLocalizedSchema",
      updated_after: "updatedAfter",
      updated_at: "updatedAt",
      updated_before: "updatedBefore"
    ),
    page: HubSpotSDK::Internal::Page,
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

#publish_draft(table_id_or_name, include_foreign_ids: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::HubDBTableV3

Publishes the table by copying the data and table schema changes from draft version to the published version, meaning any website pages using data from the table will be updated.

Parameters:

Returns:

See Also:



408
409
410
411
412
413
414
415
416
417
418
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 408

def publish_draft(table_id_or_name, params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TablePublishDraftParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :post,
    path: ["cms/hubdb/2026-03/tables/%1$s/draft/publish", table_id_or_name],
    query: query.transform_keys(include_foreign_ids: "includeForeignIds"),
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

#reset_draft(table_id_or_name, include_foreign_ids: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::HubDBTableV3

Replaces the data in the draft version of the table with values from the published version. Any unpublished changes in the draft will be lost after this call is made.

Parameters:

Returns:

See Also:



433
434
435
436
437
438
439
440
441
442
443
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 433

def reset_draft(table_id_or_name, params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableResetDraftParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :post,
    path: ["cms/hubdb/2026-03/tables/%1$s/draft/reset", table_id_or_name],
    query: query.transform_keys(include_foreign_ids: "includeForeignIds"),
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

#unpublish(table_id_or_name, include_foreign_ids: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::HubDBTableV3

Unpublishes the table, meaning any website pages using data from the table will not render any data.

Parameters:

Returns:

See Also:



457
458
459
460
461
462
463
464
465
466
467
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 457

def unpublish(table_id_or_name, params = {})
  parsed, options = HubSpotSDK::Cms::Hubdb::TableUnpublishParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :post,
    path: ["cms/hubdb/2026-03/tables/%1$s/unpublish", table_id_or_name],
    query: query.transform_keys(include_foreign_ids: "includeForeignIds"),
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end

#update_draft(table_id_or_name, allow_child_tables:, allow_public_api_access:, columns:, dynamic_meta_tags:, enable_child_table_pages:, label:, name:, use_for_pages:, archived: nil, include_foreign_ids: nil, is_get_localized_schema: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::HubDBTableV3

Some parameter documentations has been truncated, see Models::Cms::Hubdb::TableUpdateDraftParams for more details.

Update an existing HubDB table. You can use this endpoint to add or remove columns to the table as well as restore an archived table. Tables updated using the endpoint will only modify the draft verion of the table. Use the ‘/publish` endpoint to push all the changes to the published version. To restore a table, include the query parameter `archived=true` and `“archived”: false` in the json body. Note: You need to include all the columns in the input when you are adding/removing/updating a column. If you do not include an already existing column in the request, it will be deleted.

Parameters:

  • table_id_or_name (String)

    Path param

  • allow_child_tables (Boolean)

    Body param: Specifies whether child tables can be created

  • allow_public_api_access (Boolean)

    Body param: Specifies whether the table can be read by public without authorizat

  • columns (Array<HubSpotSDK::Models::Cms::ColumnRequest>)

    Body param: List of columns in the table

  • dynamic_meta_tags (Hash{Symbol=>Integer})

    Body param: Specifies the key value pairs of the [metadata fields](devel

  • enable_child_table_pages (Boolean)

    Body param: Specifies creation of multi-level dynamic pages using child tables

  • label (String)

    Body param: Label of the table

  • name (String)

    Body param: Name of the table

  • use_for_pages (Boolean)

    Body param: Specifies whether the table can be used for creation of dynamic page

  • archived (Boolean)

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

  • include_foreign_ids (Boolean)

    Query param

  • is_get_localized_schema (Boolean)

    Query param

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

Returns:

See Also:



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/hubspot_sdk/resources/cms/hubdb/tables.rb', line 512

def update_draft(table_id_or_name, params)
  query_params = [:archived, :include_foreign_ids, :is_get_localized_schema]
  parsed, options = HubSpotSDK::Cms::Hubdb::TableUpdateDraftParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :patch,
    path: ["cms/hubdb/2026-03/tables/%1$s/draft", table_id_or_name],
    query: query.transform_keys(
      include_foreign_ids: "includeForeignIds",
      is_get_localized_schema: "isGetLocalizedSchema"
    ),
    body: parsed.except(*query_params),
    model: HubSpotSDK::Cms::HubDBTableV3,
    options: options
  )
end