PocketBase icon

PocketBase

Consume PocketBase API

Overview

This node integrates with the PocketBase API, allowing users to perform CRUD operations on PocketBase collections (referred to as Resources). Specifically, for the "Create" operation on the "Default" resource, it creates a new element (record) in the specified PocketBase collection.

Common scenarios include:

  • Adding new records to a PocketBase collection from data processed or generated within an n8n workflow.
  • Automating data entry into PocketBase when triggered by external events.
  • Populating PocketBase collections with dynamic values provided at runtime.

Example: Automatically create a new user profile in a PocketBase collection whenever a form is submitted on a website.

Properties

Name Meaning
Parameters Collection of optional query parameters for list/search operations (not used in Create operation).
- Page (number) Page number for pagination (default 1).
- Elements per Page (number) Number of elements per page (default 30).
- Filter (string) Filter expression for querying (default empty).
- Sort (string) Sorting criteria (default empty).
- Expand (string) Related records to expand (default empty).
Body Parameters Fixed collection of key-value pairs representing fields and their values to set in the new record.
- Name (string) ID of the field to set in the new record.
- Value (string) Value to assign to the field.

For the "Create" operation, only the Body Parameters are relevant, where each parameter corresponds to a field in the PocketBase collection and its value.

Output

The node outputs an array of JSON objects, each representing the newly created record returned by the PocketBase API. The structure matches the PocketBase collection's schema, including all fields of the created element.

If the PocketBase API returns any binary data associated with the record (not typical for creation), it would be included accordingly, but this node primarily handles JSON data.

Dependencies

  • Requires a valid PocketBase API endpoint URL.
  • Requires authentication credentials: username and password for a configured user collection.
  • Uses the official PocketBase JavaScript client library.
  • Requires the "pocketBaseApi" credential configured in n8n containing the API URL, user collection name, username, and password.

Troubleshooting

  • Authentication failed!
    This error occurs if the provided credentials are invalid or the PocketBase server is unreachable. Verify the API URL, username, password, and user collection name in the credentials configuration.

  • Something went wrong: followed by a JSON response
    Indicates an error returned by the PocketBase API during the create operation. Check the field names and values in the Body Parameters to ensure they conform to the collection schema and validation rules.

  • Empty or missing Body Parameters
    If no fields are provided, the create operation may fail or create an incomplete record. Always specify required fields in the Body Parameters.

  • Network issues
    Ensure that the n8n instance can reach the PocketBase server URL and that there are no firewall or connectivity problems.

Links and References

Discussion