# Send records to Google Sheets with Apps Script

> Copy every record of a table into a Google Sheet with a Google Apps Script that reads the Tadabase REST API.

Source: https://tadabase.com/docs/data/exporting-records-to-google-sheets  
Status: Verified Nov 17, 2026. Checked against the current product

Tadabase has no built-in Google Sheets connection. To copy a table into a sheet, you can run the Google Apps Script below: it reads the table's records through the Tadabase REST API and writes them to the sheet, one row per record. You can also send records to a sheet with Zapier or Make.

> **Warning:** The script is an example. Tadabase support cannot help you change it or fix problems with it.

## Before you start

- An API key for the app. Go to **Settings** > **API Keys** and create a key with **Allow Reads** turned on. Note its **App ID**, **API Key** and **API Secret**. Your plan must include API access. See [Get your API keys](https://tadabase.com/docs/developers/getting-api-keys).
- The table's ID. Open the table in the Data Builder: the ID is the part of the page's address right after `dataTables/`.

## Add the script to your sheet

1. **Open Apps Script** In a new Google Sheet, choose **Extensions** > **Apps Script**.
2. **Paste the script** Delete the sample code in the editor and paste the script below.
3. **Fill in your values** Replace the four values at the top with your App ID, API key, API secret and table ID.
4. **Save** Save the project, then reload the sheet. A **Tadabase** menu appears after a few seconds.
5. **Run it** Choose **Tadabase** > **Get all records**. The first time, Google asks you to authorize the script; allow it, then run the menu item again.

```javascript
// Replace these four values with your own.
var APP_ID = 'YOUR_APP_ID';
var API_KEY = 'YOUR_API_KEY';
var API_SECRET = 'YOUR_API_SECRET';
var TABLE_ID = 'YOUR_TABLE_ID';

var BASE_URL = 'https://api.tadabase.io/api/v1/data-tables/' + TABLE_ID;
var PAGE_SIZE = 100; // the API returns at most 200 records per page

// Adds the Tadabase menu to the sheet.
function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('Tadabase')
    .addItem('Get all records', 'getAllRecords')
    .addToUi();
}

// Calls the API and stops with a readable message if the call fails.
function callApi(path) {
  var response = UrlFetchApp.fetch(BASE_URL + path, {
    method: 'get',
    headers: {
      'X-Tadabase-App-Id': APP_ID,
      'X-Tadabase-App-Key': API_KEY,
      'X-Tadabase-App-Secret': API_SECRET
    },
    muteHttpExceptions: true
  });
  var body = JSON.parse(response.getContentText());
  if (response.getResponseCode() !== 200 || body.type !== 'success') {
    throw new Error('Tadabase API error ' + response.getResponseCode() + ': ' + (body.msg || response.getContentText()));
  }
  return body;
}

// Turns a value with several parts (a name, an address, a list) into text.
function toText(value) {
  if (value === null || value === undefined) return '';
  if (Array.isArray(value)) return value.map(toText).filter(String).join(', ');
  if (typeof value === 'object') {
    if (value.url) return value.url;
    return Object.keys(value).map(function (key) { return toText(value[key]); }).filter(String).join(' ');
  }
  return value;
}

function cellValue(record, field) {
  // A connection field also comes back as <slug>_val: the connected records' display values.
  var connected = record[field.slug + '_val'];
  if (Array.isArray(connected)) {
    return connected.map(function (item) { return item.val; }).join(', ');
  }
  return toText(record[field.slug]);
}

function getAllRecords() {
  var fields = callApi('/fields').fields;
  var rows = [['Record ID'].concat(fields.map(function (field) { return field.name; }))];

  var page = 1;
  var totalPages = 1;
  do {
    var result = callApi('/records?limit=' + PAGE_SIZE + '&page=' + page);
    result.items.forEach(function (record) {
      rows.push([record.id].concat(fields.map(function (field) { return cellValue(record, field); })));
    });
    totalPages = result.total_pages;
    page++;
  } while (page <= totalPages);

  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.clearContents();
  sheet.getRange(1, 1, rows.length, rows[0].length).setValues(rows);
}

```

Each run clears the active sheet and writes the table again: a header row with the field names, then one row per record. Fields with several parts, such as Name and Address, are joined into one cell, and connection fields show the connected records' display values.

## How the script uses the API

| Call | What it returns |
| --- | --- |
| `GET /api/v1/data-tables/{tableId}/fields` | The table's fields, each with its `name`, `slug` and `type`. |
| `GET /api/v1/data-tables/{tableId}/records?limit=100&page=1` | One page of records in `items`, plus `total_items`, `total_pages` and `current_page`. `limit` is capped at 200. |

Every call sends the `X-Tadabase-App-Id`, `X-Tadabase-App-Key` and `X-Tadabase-App-Secret` headers. A large table takes one call per page, and API calls are rate limited; see [Rate limiting](https://tadabase.com/docs/developers/rate-limiting). For filters, sorting and the other calls, see [REST API overview](https://tadabase.com/docs/developers/rest-api-overview).

## Common problems

| What you see | What to do |
| --- | --- |
| No **Tadabase** menu | Reload the sheet and wait a few seconds. Check that the project was saved. |
| Another Tadabase API error | Read the message after the code. Check the App ID, API key, API secret and table ID, and that the key's **Status** is active. |
| Tadabase API error 412 | The key is not allowed to read records. Turn on **Allow Reads** for it. |
| The sheet stops partway on a very large table | Google limits how long a script can run. Export the table to CSV instead and import the file into the sheet: see [Export records to CSV](https://tadabase.com/docs/data/standard-exports). |
