PocketBase Custom icon

PocketBase Custom

Work with PocketBase records

Overview

This node integrates with PocketBase, a backend service for managing collections and records. Specifically, the Record - Get operation retrieves a single record from a specified PocketBase collection by its ID. It supports expanding related records to include linked data in the response.

Common scenarios where this node is useful include:

  • Fetching detailed information about a specific entity stored in PocketBase, such as a user profile, product details, or order information.
  • Retrieving related data in one request by expanding relations, reducing the need for multiple API calls.
  • Integrating PocketBase data retrieval into automated workflows, e.g., fetching a record before processing or updating it.

Example use case:

  • You have a "users" collection in PocketBase and want to get the full details of a user by their record ID, including related "address" data expanded inline.

Properties

Name Meaning
Collection The name of the PocketBase collection from which to retrieve the record (e.g., "users").
Record ID The unique identifier of the record to fetch within the specified collection.
Expand Relations Comma-separated list of relation fields to expand in the response (e.g., turma,turma.colegio). This includes linked records inline.

Output

The output JSON contains the retrieved record's data as returned by PocketBase. It includes all fields of the record and, if specified, expanded related records under an expand property.

Example structure:

{
  "id": "recordId",
  "field1": "value1",
  "field2": "value2",
  "expand": {
    "relation1": { /* related record data */ },
    "relation2": { /* related record data */ }
  }
}
  • The output is paired with the input item index for traceability.
  • No binary data is output by this operation.

Dependencies

  • Requires a valid PocketBase instance URL and authentication credentials.
  • Supports authentication via either:
    • Email and password of a PocketBase admin user.
    • An API token.
  • The node uses the official pocketbase JavaScript SDK internally.
  • Credentials must be configured in n8n with the necessary URL and authentication details.

Troubleshooting

  • Authentication errors:
    If authentication fails, verify that the email/password or API token provided are correct and have sufficient permissions. Common error messages include:

    • "Authentication failed - No token received"
    • "PocketBase authentication failed: ..."
    • "PocketBase token authentication failed: ..."
      Ensure the PocketBase server URL is reachable and correct.
  • Record not found or access denied:
    If the record ID does not exist or the authenticated user lacks permission, the node will throw an error. Check the record ID and your PocketBase collection rules.

  • Expand relations warnings:
    When expanding relations, if some expansions fail, a warning is logged indicating which relations could not be expanded. This often relates to API view rules restricting access to related collections.

  • Invalid parameters:
    Ensure the collection name and record ID are correctly set and non-empty.

Links and References

Discussion