Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

2.1 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { airtableAuth } from '../auth';
import { airtableCommon } from '../common';
import { AirtableTableConfig } from '../common/models';
import { createBaseActionOutputSchema } from '../output-schemas';

export const airtableCreateBaseAction = createAction({
  auth: airtableAuth,
  name: 'airtable_create_base',
  classification: 'WRITE',
  displayName: 'Create Base',
  description: 'Create a new base with a specified table structure.',
  audience: 'human',
  outputSchema: createBaseActionOutputSchema,
  aiMetadata: {
    description:
      'Creates a new Airtable base inside a workspace, seeded with one or more tables defined by a JSON structure (the first field of each table becomes its primary field). Use to provision a brand-new base. Requires a workspace ID and base name; not idempotent — each call creates a separate base.',
    idempotent: false,
  },
  props: {
    workspaceId: airtableCommon.workspaceId,
    name: Property.ShortText({
      displayName: 'Base Name',
      required: true,
    }),
    tables: Property.Json({
      displayName: 'Tables',
      description:
        'Tables to create. The first field of each table is its primary field.',
      required: true,
      defaultValue: [
        {
          name: 'My First Table',
          fields: [
            {
              name: 'Name',
              type: 'singleLineText',
            },
            {
              name: 'Status',
              type: 'singleSelect',
              options: {
                choices: [
                  { name: 'Todo' },
                  { name: 'In Progress' },
                  { name: 'Done' },
                ],
              },
            },
          ],
        },
      ],
    }),
  },
  async run(context) {
    const { auth: personalToken, propsValue } = context;
    const { workspaceId, name, tables } = propsValue;

    return await airtableCommon.createBase({
      personalToken: personalToken.secret_text,
      workspaceId: workspaceId as string,
      name: name as string,
      tables: tables as unknown as AirtableTableConfig[],
    });
  },
});