Xata icon

Xata

Consume Xata API

Overview

The Xata node for n8n allows you to interact with the Xata database service. Specifically, when using the Default resource and the Create operation, this node creates a new record in a specified table within your Xata workspace, assigning it a specific ID and optionally controlling which columns are sent.

Common scenarios:

  • Automating the creation of records in a Xata table from other workflows.
  • Integrating data from external sources into Xata.
  • Ensuring records have custom IDs rather than auto-generated ones.

Practical example:
You might use this node to create a new user profile in your "users" table every time a signup event occurs in another system, specifying the user's unique ID and relevant fields.


Properties

Name Type Meaning
Workspace Slug String The slug (unique identifier) of your Xata workspace.
Database Location Options The region where your Xata database is hosted (e.g., us-east-1, us-west-2, eu-west-1).
Database Name String The name of the Xata database you want to access.
Branch Name String The branch of the database to use (similar to Git branches).
Table Name String The name of the table where the record will be created.
ID String The unique identifier for the new record to be created.
Send All Columns Boolean Whether to send all available columns to Xata. If false, specify columns below.
Columns String[] (Shown if "Send All Columns" is false) List of column names to include in the new record.
Additional Options Collection Extra options for the request:
- Ignore Columns: Columns to exclude (if sending all).

Output

  • The output is an array of JSON objects, each representing the result of a record creation attempt.
  • Each object typically contains the full record as returned by Xata after creation, including all fields that were set and any metadata provided by Xata.
  • If an error occurs and "Continue On Fail" is enabled, the output object will contain an error field with the error message.

Example output:

[
  {
    "id": "user_123",
    "name": "Alice",
    "email": "alice@example.com",
    // ...other fields...
    "xata": { /* Xata metadata */ }
  }
]

or, on error:

[
  {
    "error": "Record with ID already exists"
  }
]

Dependencies

  • External Service: Requires access to the Xata API.
  • API Key: You must provide valid Xata API credentials via n8n's credential system (xataApi).
  • n8n Configuration: No special environment variables required beyond standard credential setup.

Troubleshooting

Common issues:

  • Missing or invalid credentials:
    Error: "No credentials provided for Xata Api"
    Resolution: Ensure you have configured the Xata API credentials in n8n.

  • Duplicate ID:
    Error: "Record with ID already exists"
    Resolution: Make sure the ID you provide does not already exist in the target table.

  • Invalid table, database, or branch:
    Error: "Not Found" or similar messages.
    Resolution: Double-check the workspace slug, database name, branch, and table name.

  • Column mismatch:
    Error: "Unknown column" or missing data.
    Resolution: Ensure the columns you specify actually exist in the table schema.

  • Network/API errors:
    Error: Various HTTP status codes (e.g., 401 Unauthorized, 404 Not Found, 500 Server Error).
    Resolution: Check your network connection, credentials, and Xata service status.


Links and References


Discussion