Testing the Airtable API with a personal access token

Airtable often ends up as a small team's back office: a content calendar, an inventory, a list of beta customers. The integrations that read and write it are usually a script someone wrote once. A short test collection keeps them honest, especially after someone renames a field in the UI.

Step 1: Token and environment

At airtable.com/create/tokens, create a token with data.records:read, data.records:write and, for the schema check below, schema.bases:read. Give it access to the test base only.

VariableValue
atBasehttps://api.airtable.com/v0
atTokenpat…, marked as secret
baseIdapp… (from the base's URL)
tableIdtbl…

Authorization: Bearer token with {{atToken}}.

Step 2: Check the schema

HTTP
GET {{atBase}}/meta/bases/{{baseId}}/tables
JavaScript
const table = pm.response.json().tables.find((t) => t.id === pm.environment.get('tableId'));
const fields = table.fields.map((f) => f.name);
pm.test('fields the integration needs exist', () => {
  ['Name', 'Email', 'Status'].forEach((name) => pm.expect(fields).to.include(name));
});

This is the test that catches "someone renamed Email to E-mail" before your sync silently writes nothing.

Step 3: List and filter

HTTP
GET {{atBase}}/{{baseId}}/{{tableId}}?pageSize=100&filterByFormula={Status}='Active'&fields[]=Name&fields[]=Email
JavaScript
const body = pm.response.json();
pm.test('records returned', () => pm.expect(body.records).to.be.an('array'));
body.records.forEach((r) => pm.expect(r.fields.Email, r.id).to.match(/@/));
if (body.offset) pm.environment.set('offset', body.offset);

Empty fields are left out of fields entirely, not returned as null. Code that reads record.fields.Phone must handle undefined. See null vs missing fields.

Step 4: Create and update in batches

HTTP
POST {{atBase}}/{{baseId}}/{{tableId}}
Content-Type: application/json

{
  "records": [
    {"fields": {"Name": "API test A", "Email": "[email protected]", "Status": "Active"}},
    {"fields": {"Name": "API test B", "Email": "[email protected]", "Status": "Active"}}
  ],
  "typecast": true
}
JavaScript
const created = pm.response.json().records;
pm.test('two records created', () => pm.expect(created).to.have.lengthOf(2));
pm.environment.set('recordIds', created.map((r) => r.id).join(','));

More than 10 records in one request answers 422. typecast: true lets Airtable convert values, such as adding a new option to a single-select field. Leave it off when you want strict checks.

To upsert by a field, PATCH with "performUpsert": {"fieldsToMergeOn": ["Email"]} updates matching records and creates the rest.

Step 5: Rate limit and errors

Five requests per second per base. Over it, Airtable answers 429, and you have to wait 30 seconds before the next request succeeds. In a run, --delay 250 keeps you safely under.

Statuserror.type
401AUTHENTICATION_REQUIRED
403INVALID_PERMISSIONS_OR_MODEL_NOT_FOUND: no access, or the base doesn't exist
404NOT_FOUND
422INVALID_REQUEST_UNKNOWN, UNKNOWN_FIELD_NAME, INVALID_VALUE_FOR_COLUMN
429rate limited

Delete the test records in a cleanup step: DELETE {{atBase}}/{{baseId}}/{{tableId}}?records[]=rec…&records[]=rec…, up to 10 at a time.