Airtable objects can be used to work bases and tables in an Airtable account. Integration works via the Airtable API so plan to reference their documentation for details on parameters and return value objects. Drafts will take care of the OAuth authentication, and conversion to and from JSON for passing parameters and receiving return values.

// set values from your account
let baseId = "YOUR-BASE-ID"
let tableName = "YOUR-TABLE-ID-OR-NAME"

// create Airtable value
let at = new Airtable()
// sample values...need to match the target table
let record = {
"fields": {
"F1": "Text for Field 1",
"F2": "Text for Field 2",
"Complete": true // checkbox field
},
"typecast": true
}

let result = at.createRecords(baseId, tableName, record)
if (result) { // success! result contains record info
console.log("Airtable record created")
}
else { // something went wrong, log error
console.log(at.lastError)
context.fail()
}

Bases

  • Convenience wrapper arounc the get base schema endpoint used to retreive the table schema of all tables in the base.

    Parameters

    • baseId: string

    Returns object

    Object containing the parsed JSON returned by the API.

  • Convenience wrapper arounc the list bases endpoint used to retreive a list of available bases in the account.

    Returns object

    Object containing the parsed JSON returned by the API.

Other

  • Create new instance.

    Parameters

    • Optionalidentifier: string

    Returns Airtable

lastError: string

If a convenience function fails, this property will contain the last error as a string message, otherwise it will be undefined.

  • Execute a request against the Airtable API. For successful requests, the HTTPResponse object will contain an object or array or objects decoded from the JSON returned by Airtable as appropriate to the request made. Refer to Airtable API documentation for details about the expected parameters and responses. Drafts will handle wrapping the request in the appropriate OAuth authentication flow and translating passed and received data object to and from JSON.

    Parameters

    • settings: {
          data?: {
              [x: string]: string;
          };
          headers?: {
              [x: string]: string;
          };
          method: string;
          parameters?: {
              [x: string]: string;
          };
          url: string;
      }
      • Optionaldata?: {
            [x: string]: string;
        }

        An object containing data to be encoded into the HTTP body of the request.

        • [x: string]: string
      • Optionalheaders?: {
            [x: string]: string;
        }

        An object contain key-values to be added as custom headers in the request. There is no need to provide authorization headers, Drafts will add those.

        • [x: string]: string
      • method: string

        The HTTP method, like "GET", "POST", etc.

      • Optionalparameters?: {
            [x: string]: string;
        }

        An object containing key-values to be added to the request as URL parameters. Drafts will take care of encoding these.

        • [x: string]: string
      • url: string

        The URL of the API endpoint in the Airtable API. This should include the entire URL, including api version, usually something like https://api.airtable.com/v0/...

    Returns HTTPResponse

  • Creates a new Airtable object.

    Parameters

    • Optionalidentifier: string

      used to identify a Airtable account. Typically this can be omitted if you only work with one Airtable account in Drafts.

    Returns Airtable

Records

  • Convenience wrapper arounc the list records endpoint used to retreive records in a table.

    Parameters

    • baseId: string

      Valid id of an existing base in the Airtable account.

    • tableIdOrName: string

      Valid id, or name, of a table that exists in the Airtable account.

    • records: object

      An object containing a single record field values, or an array of up to 10 record field values to create. See API docs for details on configuring records.

    Returns object

    Object containing the parsed JSON returned by the API.

  • Convenience wrapper arounc the list records endpoint used to retreive records in a table.

    Parameters

    • baseId: string

      Valid id of an existing base in the Airtable account.

    • tableIdOrName: string

      Valid id, or name, of a table that exists in the Airtable account.

    • Optionaloptions: object

    Returns object

    Object containing the parsed JSON returned by the API.

  • Convenience wrapper arounc the list records endpoint used to update values of an existing record in a table.

    Parameters

    • baseId: string

      Valid id of an existing base in the Airtable account.

    • tableIdOrName: string

      Valid id, or name, of a table that exists in the Airtable account.

    • recordId: string

      Valid id of an existing record in the table.

    • fields: object

      An object containing field values. See API docs for details.

    Returns object

    Object containing the parsed JSON returned by the API.

""