Back to APIs

Create, update or delete single or multiple records in your bases.

Using our official Airtable integration

Create any tasks possible with the Airtable API.

Use io.runTask() and the official SDK or fetch.

Airtable integration docs

Example code using Airtable

Below are some working code examples of how you can use Airtable with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

1
import { TriggerClient } from "@trigger.dev/sdk";
2
import { Stripe } from "@trigger.dev/stripe";
3
import { Airtable } from "@trigger.dev/airtable";
4
5
const stripe = new Stripe({
6
id: "stripe",
7
apiKey: process.env.STRIPE_API_KEY!,
8
});
9
10
const airtable = new Airtable({
11
id: "airtable",
12
token: process.env.AIRTABLE_TOKEN!,
13
});
14
15
//this is the type definition for the table
16
type SubscribedUsers = {
17
id: string;
18
interval: string;
19
currency: string;
20
unitAmount?: number;
21
};
22
23
// This job populates an Airtable table when a new customer subscription is created in Stripe
24
client.defineJob({
25
id: "stripe-new-subscription-update-airtable",
26
name: "On new Stripe subscription update Airtable",
27
version: "1.0.0",
28
integrations: {
29
stripe,
30
airtable,
31
},
32
trigger: stripe.onCustomerSubscription(),
33
run: async (payload, io, ctx) => {
34
// Adding the type to table<YourTableType>("<your table name>")
35
// gives you nice type inference and errors.
36
// You can leave it out as well table("<your table name>")
37
const table = io.airtable
38
.base("<your base id>")
39
.table<SubscribedUsers>("<your table name>");
40
41
//create a new record
42
const newRecords = await table.createRecords("create records", [
43
{
44
// Check the Stripe documents for object info: https://stripe.com/docs/api/subscriptions/object
45
fields: {
46
id: payload.id,
47
interval: payload.items.data[0].price.recurring?.interval,
48
currency: payload.items.data[0].price.currency,
49
// The unit amount in pence to be charged, represented as a whole integer if possible.
50
unitAmount: payload.items.data[0].price.unit_amount ?? undefined,
51
},
52
},
53
]);
54
55
await io.logger.info("A new subscription was created.");
56
},
57
});