/api/records/v1
Create Record
Create a new record in the specified table.POST /api/records/v1/{name}
Path Parameters
Record API name (configured in your TrailBase setup)
Request Body
Single record as JSON object: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
Redirect URL after successful creation (for form submissions)
Response
Array of base64-encoded record IDs for created records
Auto-fill User ID Columns
Ifautofill_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
Record API name
Record ID (base64-encoded UUID or integer)
Query Parameters
Comma-separated list of foreign key columns to expand (e.g.,
expand=author,category)Response
Foreign Key Expansion
When using theexpand 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
Record API name
Record ID to update
Request Body
Partial record update (only include fields to change):Response
Record updated successfully (empty response body)
Delete Record
Delete a record by ID.DELETE /api/records/v1/{name}/{record}
Path Parameters
Record API name
Record ID to delete
Response
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
Record API name
Query Parameters
Maximum number of records to return
Number of records to skip (alternative to cursor)
Encrypted cursor for pagination (returned in previous response)
Include total count of matching records (adds
total_count to response)Sort order. Prefix with
- for descending (e.g., -created_at or status,-created_at)Comma-separated foreign keys to expand
Response
Array of record objects matching the query
Encrypted cursor for fetching the next page (omitted if no more pages)
Total number of matching records (only if
count=true)Filtering
Filter records using query parameters withfilter[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
Cursor-Based Pagination (Recommended)
Use encrypted cursors for consistent pagination:- Consistent results even with concurrent modifications
- Better performance for deep pagination
- Encrypted to prevent tampering
Offset-Based Pagination
Use offset for simpler pagination:- 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 usersacl_authenticated: Permissions for authenticated users
Create, Read, Update, Delete, Schema
Row-Level Access Rules
Define SQL expressions for fine-grained access control:_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
Best Practices
- Use cursor pagination for consistent results with concurrent modifications
- Request only needed fields using projection (if supported)
- Filter on indexed columns for better query performance
- Limit list queries to avoid performance issues with large result sets
- Use bulk create for inserting multiple records (up to 1024 per request)
- Enable row-level access for multi-tenant applications
- Validate data client-side before submission to reduce API round trips
- Cache JSON schemas to avoid repeated schema fetches
Error Responses
Invalid parameters, malformed JSON, or constraint violation
Access denied by ACL or row-level access rule
Record or API not found
API not found or operation not supported (e.g., update on view)