# List all tables and field slugs in Google Sheets

> An Apps Script that writes every table of your app, with each field's name, slug and type, to a Google Sheet you can keep beside your API code.

Source: https://tadabase.com/docs/developers/save-tables-and-fields-into-spreadsheet  
Status: Verified Nov 17, 2026. Checked against the current product

API calls name tables by ID and fields by slug, such as `field_36`. This Google Apps Script writes all of them to a sheet: one row per field, with its table's name and ID, the field's name, slug and type.

> **Only need one or two slugs?:** Open **Settings** > **API Keys** and click **API Playground**. When you run a request on a table there, the response shows each field slug with the field's name beside it, without any code. See [Tables and fields API](https://tadabase.com/docs/developers/tables-and-fields-api) for the calls this script uses.

## Before you start

You need an API key for the app with **Allow Reads** turned on, and its App ID, API key and API secret. See [Get your API keys](https://tadabase.com/docs/developers/getting-api-keys).

## Set it up

1. **Open Apps Script** Create a Google Sheet, then choose **Extensions** > **Apps Script**.
2. **Paste the script** Delete the sample code, paste the script below and save the project.
3. **Store your keys** Open **Project Settings** (the gear icon) and, under **Script Properties**, add `TADABASE_APP_ID`, `TADABASE_API_KEY` and `TADABASE_API_SECRET`.
4. **Run it** Reload the sheet and choose **Tadabase** > **List tables and fields**, or select `listTablesAndFields` in the editor and click **Run**. Google asks you to authorize the script the first time.

```javascript
// Writes every table and field of a Tadabase app to the "Tables and fields" tab.
// Set these Script Properties first (Project Settings > Script Properties):
// TADABASE_APP_ID, TADABASE_API_KEY, TADABASE_API_SECRET

var SHEET_NAME = 'Tables and fields';

function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('Tadabase')
    .addItem('List tables and fields', 'listTablesAndFields')
    .addToUi();
}

// GETs a path under /api/v1 and stops with a readable message if the call fails.
function callApi_(path) {
  var props = PropertiesService.getScriptProperties();
  for (var attempt = 0; attempt <= 5; attempt++) {
    var response = UrlFetchApp.fetch('https://api.tadabase.io/api/v1' + path, {
      method: 'get',
      headers: {
        'X-Tadabase-App-Id': props.getProperty('TADABASE_APP_ID'),
        'X-Tadabase-App-Key': props.getProperty('TADABASE_API_KEY'),
        'X-Tadabase-App-Secret': props.getProperty('TADABASE_API_SECRET')
      },
      muteHttpExceptions: true
    });
    var code = response.getResponseCode();
    if (code === 429) { // rate limited: wait as long as the API asks, then retry
      var headers = response.getHeaders();
      Utilities.sleep(Math.min(Number(headers['Retry-After'] || headers['retry-after']) || 60, 60) * 1000);
      continue;
    }
    var body = JSON.parse(response.getContentText());
    if (code !== 200 || body.type !== 'success') {
      throw new Error('Tadabase API error ' + code + ': ' + (body.msg || response.getContentText()));
    }
    return body;
  }
  throw new Error('The API is still rate limiting. Try again later.');
}

function listTablesAndFields() {
  var rows = [['Table', 'Table ID', 'Field', 'Field slug', 'Type']];
  var tables = callApi_('/data-tables').data_tables;
  tables.forEach(function (table) {
    var fields = callApi_('/data-tables/' + table.id + '/fields').fields;
    fields.forEach(function (field) {
      rows.push([table.name, table.id, field.name, field.slug, field.type]);
    });
  });

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getSheetByName(SHEET_NAME) || spreadsheet.insertSheet(SHEET_NAME);
  sheet.clearContents();
  sheet.getRange(1, 1, rows.length, rows[0].length).setValues(rows);
}

```

## What the sheet shows

| Column | Comes from |
| --- | --- |
| Table, Table ID | `GET /api/v1/data-tables`, which returns `data_tables`: each table's `id` and `name`. |
| Field, Field slug, Type | `GET /api/v1/data-tables/{tableId}/fields`, which returns `fields`: each field's `name`, `slug` and `type`. |

- Only tables that are visible in the Data Builder are listed.
- The type is the field type's internal name. Most match the builder, but a connection field shows as `Join` and a date range field as `Calendar`. See [Field types reference](https://tadabase.com/docs/developers/field-types-reference).
- Run the script again after you add or rename fields: it replaces the tab's contents each time.
- For descriptions, default values and the options of choice fields, call `GET /api/v1/data-tables/{tableId}/full-fields-info` instead of `/fields`.

## Common problems

| What you see | What to do |
| --- | --- |
| No **Tadabase** menu | Reload the sheet and wait a few seconds, or run `listTablesAndFields` from the editor. |
| `Tadabase API error 412` | The key is not allowed to read. Turn on **Allow Reads** for it. |
| Another `Tadabase API error` | Check the three Script Properties and that the key's status is active. |
