Skip to main content

airtable.airtable.createrecords

Home > @runlightyear/airtable > Airtable > createRecords

Airtable.createRecords() method

Creates multiple records.

Signature:
createRecords(props: CreateRecordsProps): Promise<CreateRecordsResponse>;

Parameters

ParameterTypeDescription
propsCreateRecordsProps
Returns:

Promise<CreateRecordsResponse>

Example 1

Create a single record

import { defineAction } from "@runlightyear/lightyear";
import { Airtable } from "@runlightyear/airtable";

defineAction({
name: "createSingleRecord",
title: "Create Single Record",
apps: ["airtable"],
variables: ["baseId", "tableIdOrName", "name"],
run: async ({ auths, variables }) => {
const airtable = new Airtable({
auth: auths.airtable,
});

const response = await airtable.createRecords({
baseId: variables.baseId!,
tableIdOrName: variables.tableIdOrName!,
fields: {
Name: variables.name!,
},
});

console.log("Record: ", response.data);
},
});

Example 2

Create multiple records

import { defineAction } from "@runlightyear/lightyear";
import { Airtable } from "@runlightyear/airtable";

defineAction({
name: "createMultipleRecords",
title: "Create Multiple Records",
apps: ["airtable"],
variables: ["baseId", "tableIdOrName"],
run: async ({ auths, variables }) => {
const airtable = new Airtable({
auth: auths.airtable,
});

const response = await airtable.createRecords({
baseId: variables.baseId!,
tableIdOrName: variables.tableIdOrName!,
records: [
{
fields: {
Name: "Union Square",
},
},
{
fields: {
Name: "Ferry Building",
},
},
],
});

console.log("Response: ", response.data);
},
});