Manage table groups

Manage your team's custom table groups. A table group consists a list of named tables, each containing dimensions and metrics from a data source query.

We currently support listing, exporting and importing table groups.

List table groups

GET https://api.supermetrics.com/enterprise/v2/table/groups
Response
PropertyTypeDescription
meta > request_idstring API request ID
datatable_group[] Table group objects
HTTP 200 OK
{
    "meta": {
        "request_id": "WnjTGeKqOXTnkZQMbZCfVMdmswv2wAzx"
    },
    "data": [
        {
            "@type": "table_group",
            "group_id": "tg_1",
            "name": "My table group"
        },
        {
            "@type": "table_group",
            "group_id": "tg_2",
            "name": "Another table group"
        }
    ]
}
Errors

TABLE_GROUP_SEARCH_FAILED

Permissions

table_groups_read


Export table group

GET https://api.supermetrics.com/enterprise/v2/table/group/:group_id/export
  • group_id string
    Supermetrics table group ID
  • version int
    Required. Data model version for the returned data. See supported models.
Errors

TABLE_GROUP_NOT_FOUND, TABLE_GROUP_SEARCH_FAILED

Permissions

table_groups_read


Import table group

POST https://api.supermetrics.com/enterprise/v2/table/group/import
  • version int
    Required. Data model version for the received data. See supported models.
  • ...
    Additional properties depending on version parameter
Response
PropertyTypeDescription
meta > request_idstring API request ID
datatable_group Table group object
HTTP 201 Created
{
    "@type": "table_group",
    "group_id": "tg_1",
    "name": "My table group",
    "links": {
        "enclosure": {
            "href": "https://.../table/group/tg_1/export?version=1"
        }
    }
}
Errors

IMPORT_FIELD_ITEM_TYPE_INVALID, IMPORT_PROPERTY_TYPE_INVALID, IMPORT_TABLE_FIELD_TYPE_INVALID, IMPORT_TABLE_ITEM_TYPE_INVALID, IMPORT_VERSION_INVALID, SCHEMA_DATA_SOURCE_FIELD_NOT_FOUND, SCHEMA_DATA_SOURCE_ID_INVALID, SCHEMA_NAME_DUPLICATE, SCHEMA_NAME_REQUIRED, SCHEMA_TABLE_FIELDS_REQUIRED, SCHEMA_TABLE_NAME_REQUIRED, SCHEMA_TABLE_ORDER_OUT_OF_RANGE, SCHEMA_TABLE_PARTITION_INVALID, SCHEMA_TABLE_REPORT_TYPE_NOT_FOUND, SCHEMA_TABLE_TARGET_NAME_DUPLICATES, SCHEMA_TABLES_REQUIRED, SCHEMA_UNEXPECTED_FAILURE, TABLE_GROUP_CREATE_FAILED, TABLE_GROUP_NOT_FOUND, TABLE_GROUP_SEARCH_FAILED

Permissions

table_groups_write


Model version 1

This data model contains basic group information, tables, and fields for each table. Some additional information about each field is also given.

The export response can be sent to the import endpoint without any alteration to copy it. Read-only properties, such as field type, will simply be ignored.

Model
versionintAlways 1
groupobjectTable group object
tablesobject[]Required. List of table objects
fieldsobject[]Optional. List of field objects
Table group
group_idstringSupermetrics table group ID. Read-only.
group_namestringRequired. Table group name
ds_idstringRequired. Data source ID. See data sources.
table_prefixstringPrefix to table names. Enforced into upper snake case. Maximum length is 15 characters. Appended with an underscore. Defaults to a datasource specific value.
Table
table_namestringRequired. Table name. Enforced into upper snake case.
table_partitionstringTable partition. Either date or none. Defaults to date.
report_typestringConditional. Data source report type. Required for some data sources. Defaults to null.
fieldsstring[]Required. List of field IDs for the table
Field
field_idstringRequired. Field ID that appears in one of the table objects
field_namestringData source field name. Read-only.
display_namestringField display name. Read-only.
target_namestringField name in target table. Defaults to field ID in lower snake case.
data_typestringField data type. Read-only. See field data types for more.

Examples

Import
POST https://api.supermetrics.com/enterprise/v2/table/group/import
Authorization: Bearer <your api key>
Content-Type: application/json

{
    "version": 1,
    "group": {
        "group_name": "My table group",
        "ds_id": "GA"
    },
    "tables": [
        {
            "table_name": "Table 1",
            "fields": [
                "date",
                "users"
            ]
        }
    ],
    "fields": [
        {
            "field_id": "users",
            "target_name": "site_users"
        }
    ]
}
Export
HTTP 200 OK
{
    "version": 1,
    "group": {
        "group_id": "tg_1",
        "group_name": "My table group",
        "ds_id": "GA",
        "table_prefix": "GA_"
    },
    "tables": [
        {
            "table_name": "TABLE_1",
            "table_partition": "date",
            "report_type": null,
            "fields": [
                "date",
                "users"
            ]
        },
        {
            "table_name": "TABLE_2",
            "table_partition": "date",
            "report_type": null,
            "fields": [
                "browser",
                "users",
                "newvisits"
            ]
        }
    ],
    "fields": [
        {
            "field_id": "date",
            "field_name": "Date",
            "display_name": "Date",
            "target_name": "date",
            "data_type": "string.time.date"
        },
        {
            "field_id": "users",
            "field_name": "Users",
            "display_name": "Users",
            "target_name": "total_users",
            "data_type": "int.number.value"
        },
        {
            "field_id": "browser",
            "field_name": "Browser",
            "display_name": "Browser",
            "target_name": "browser_name",
            "data_type": "string.text.value"
        },
        {
            "field_id": "newvisits",
            "field_name": "newvisits",
            "display_name": "New users",
            "target_name": "newvisits",
            "data_type": "int.number.value"
        }
    ]
}

Object reference

table_group
PropertyTypeDescription
group_idstring Supermetrics table group ID
namestring Table group name
links > enclosureresource_url Resource URL to export the table group

resource_url
PropertyTypeDescription
hrefstring Full URL to the resource

Errors

StatusErrorDescription
400IMPORT_FIELD_ITEM_TYPE_INVALIDList of fields to import should contain only objects.
400IMPORT_PROPERTY_TYPE_INVALIDImport property had an unexpected type.
400IMPORT_TABLE_FIELD_TYPE_INVALIDList of table fields to import should contain only strings.
400IMPORT_TABLE_ITEM_TYPE_INVALIDList of tables to import should contain only objects.
400IMPORT_VERSION_INVALIDImport model version is invalid.
400SCHEMA_DATA_SOURCE_FIELD_NOT_FOUNDUnable to find specified data source field.
400SCHEMA_DATA_SOURCE_ID_INVALIDProvided data source ID is not valid or accessible.
409SCHEMA_NAME_DUPLICATEAnother schema with the same name already exists.
400SCHEMA_NAME_REQUIREDSchema name is required.
400SCHEMA_TABLE_FIELDS_REQUIREDSchema table should have fields.
400SCHEMA_TABLE_NAME_REQUIREDSchema table should have a name.
400SCHEMA_TABLE_ORDER_OUT_OF_RANGEToo many tables provided for the schema.
400SCHEMA_TABLE_PARTITION_INVALIDSchema table partition value is not supported.
400SCHEMA_TABLE_REPORT_TYPE_NOT_FOUNDUnable to find specified report type from the data source.
400SCHEMA_TABLE_TARGET_NAME_DUPLICATESMultiple fields with the same target name was given.
400SCHEMA_TABLES_REQUIREDSchema tables are required.
500SCHEMA_UNEXPECTED_FAILURESomething went wrong while processing the schema. Please try again or contact support.
500TABLE_GROUP_CREATE_FAILEDFailed to create a new table group. Please try again or contact support.
404TABLE_GROUP_NOT_FOUNDRequested table group was not found.
500TABLE_GROUP_SEARCH_FAILEDSomething went wrong while searching for table groups. Please try again or contact support.
Last updated 2023-10-09 UTC.