Xata icon

Xata

Consume Xata API

Overview

The Xata node for n8n allows you to interact with the Xata database service. Specifically, the Create or Update operation (also known as "upsert") enables you to create a new record in a specified table or update an existing one if a record with the given ID already exists. This is useful for workflows where you want to ensure data consistency without having to check manually whether a record exists before updating or creating it.

Common scenarios:

  • Synchronizing user profiles from another system into Xata, ensuring each profile is either created or updated.
  • Logging events or transactions where each event has a unique identifier.
  • Automating data imports where duplicate records should be updated rather than inserted.

Practical example:
Suppose you have a list of customer orders and want to make sure each order (by its unique ID) is present in your Xata database—if it’s new, it gets created; if it already exists, it gets updated with the latest information.


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 within the database to target.
Table Name string The specific table in the database where the record will be created or updated.
ID string The unique identifier of the record to create or update.
Send All Columns boolean Whether to send all columns from the input data to Xata. If false, specify columns below.
Columns string[] (Optional) List of column names to include when sending data, used if Send All Columns is false.
Additional Options collection (Optional) Extra settings:
- Ignore Columns: Columns to exclude when sending all.
- Bulk Size: Not applicable for upsert.

Output

  • The output is a JSON object representing the created or updated record as returned by the Xata API.
  • For each input item processed, the corresponding result from Xata is included in the output array.
  • If an error occurs and "Continue On Fail" is enabled, the output for that item will contain an error field with the error message.

Example output:

[
  {
    "id": "123",
    "columnA": "valueA",
    "columnB": "valueB"
    // ...other fields as returned by Xata
  }
]

If an error occurs:

[
  {
    "error": "Record not found"
  }
]

Dependencies

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

Troubleshooting

Common Issues:

  • Missing Credentials: If no Xata API key is provided, the node will throw an error: "No credentials provided for Xata Api".
  • Invalid IDs: If the provided ID does not match the expected format or is missing, the operation may fail.
  • Schema Mismatch: Sending columns that do not exist in the table schema can cause errors.
  • Network/API Errors: Connectivity issues or invalid endpoint configuration (wrong workspace slug, database, branch, or table) will result in request failures.

Error Messages & Resolutions:

  • "No credentials provided for Xata Api": Ensure you have set up the xataApi credential in n8n.
  • "Operation undefined": Make sure the operation property is set correctly.
  • Error objects in output: Check the error field for details; often due to invalid input data or connectivity issues.

Links and References


Discussion