Skip to main content
The Records API provides CRUD operations for your application’s data tables through type-safe, configurable REST endpoints. Base Path: /api/records/v1

Create Record

Create a new record in the specified table.
POST /api/records/v1/{name}

Path Parameters

string
required
Record API name (configured in your TrailBase setup)

Request Body

Single record as JSON object:
Or bulk create with array of records:
Bulk creation is limited to 1024 records per request. All records are created in a transaction - if any record fails, all are rolled back.

Query Parameters

string
Redirect URL after successful creation (for form submissions)

Response

array
Array of base64-encoded record IDs for created records

Auto-fill User ID Columns

If autofill_missing_user_id_columns is enabled in the API configuration, TrailBase automatically fills missing user ID foreign key columns with the authenticated user’s ID:

Conflict Resolution

Configure conflict resolution strategy in the API settings:
  • None (default): Fail on constraint violations
  • Replace: Replace existing record with same primary key
  • Ignore: Skip records that would violate constraints

Read Record

Retrieve a single record by ID.
GET /api/records/v1/{name}/{record}

Path Parameters

string
required
Record API name
string
required
Record ID (base64-encoded UUID or integer)

Query Parameters

string
Comma-separated list of foreign key columns to expand (e.g., expand=author,category)

Response

Foreign Key Expansion

When using the expand parameter, foreign key references are replaced with full record data:
Expansion must be explicitly enabled in the API configuration for each foreign key column.

Update Record

Update an existing record.
PATCH /api/records/v1/{name}/{record}

Path Parameters

string
required
Record API name
string
required
Record ID to update

Request Body

Partial record update (only include fields to change):

Response

OK
Record updated successfully (empty response body)
Update operations only work on tables, not views. The API must be configured with is_table = true.

Delete Record

Delete a record by ID.
DELETE /api/records/v1/{name}/{record}

Path Parameters

string
required
Record API name
string
required
Record ID to delete

Response

OK
Record deleted successfully

File Cleanup

If the record has file columns, associated files are marked for deletion and cleaned up asynchronously.

List Records

Retrieve multiple records with filtering, sorting, and pagination.
GET /api/records/v1/{name}

Path Parameters

string
required
Record API name

Query Parameters

integer
default:"50"
Maximum number of records to return
integer
default:"0"
Number of records to skip (alternative to cursor)
string
Encrypted cursor for pagination (returned in previous response)
boolean
Include total count of matching records (adds total_count to response)
string
Sort order. Prefix with - for descending (e.g., -created_at or status,-created_at)
string
Comma-separated foreign keys to expand

Response

array
Array of record objects matching the query
string
Encrypted cursor for fetching the next page (omitted if no more pages)
integer
Total number of matching records (only if count=true)

Filtering

Filter records using query parameters with filter[field]=value syntax.

Simple Filters

Comparison Operators

Pattern Matching

Multiple Values (IN)

Null Checks

Complex Filter Example

Filters are validated against the table schema - unknown columns are silently ignored to prevent SQL injection.

Pagination Strategies

Use encrypted cursors for consistent pagination:
Advantages:
  • Consistent results even with concurrent modifications
  • Better performance for deep pagination
  • Encrypted to prevent tampering

Offset-Based Pagination

Use offset for simpler pagination:
Disadvantages:
  • Results may shift if records are added/deleted
  • Slower performance for large offsets

GeoJSON Support

For tables with geometry columns, fetch results as GeoJSON:
GET /api/records/v1/{name}?geojson={column}

Response

Access Control

Record APIs support both table-level and row-level access control.

Table-Level ACLs

Configure in API settings:
  • acl_world: Permissions for unauthenticated users
  • acl_authenticated: Permissions for authenticated users
Permissions: Create, Read, Update, Delete, Schema

Row-Level Access Rules

Define SQL expressions for fine-grained access control:
Available Variables:
  • _USER_.id: Current user’s UUID (NULL if not authenticated)
  • _ROW_: The record being accessed (read, update, delete)
  • _REQ_: The request data (create, update)
  • __fields: Array of field names in the request (JSON string)

Access Control Example

JSON Schema Validation

Retrieve the JSON schema for a record API:
GET /api/records/v1/{name}/schema

Response

File Columns

See the Files API documentation for working with file uploads in records.

Transaction API

For atomic multi-record operations:
POST /api/transaction/v1/execute
All operations execute atomically - if any fails, all are rolled back.

Best Practices

  1. Use cursor pagination for consistent results with concurrent modifications
  2. Request only needed fields using projection (if supported)
  3. Filter on indexed columns for better query performance
  4. Limit list queries to avoid performance issues with large result sets
  5. Use bulk create for inserting multiple records (up to 1024 per request)
  6. Enable row-level access for multi-tenant applications
  7. Validate data client-side before submission to reduce API round trips
  8. Cache JSON schemas to avoid repeated schema fetches

Error Responses

Bad Request
Invalid parameters, malformed JSON, or constraint violation
Forbidden
Access denied by ACL or row-level access rule
Not Found
Record or API not found
Method Not Allowed
API not found or operation not supported (e.g., update on view)