Skip to main content

Overview

The Database API provides PostgREST-style CRUD operations for your database tables. All requests require authentication headers.

Headers


Query Records

Retrieve records from a table with filtering, sorting, and pagination.

Query Parameters

Filter Operators

Example

Response

Response Headers


Create Records

Create one or more records in a table.
Important: Request body MUST be an array, even for single records.

Headers

Example

Response

Without Prefer header:
With Prefer: return=representation:

Update Records

Update records matching query filters.

Query Parameters

Use filter operators to specify which records to update.

Headers

Example

Response


Delete Records

Delete records matching query filters.

Query Parameters

Use filter operators to specify which records to delete.

Headers

Example

Response

Without Prefer header: 204 No Content With Prefer: return=representation:

Error Responses

Table Not Found (404)

Invalid Query (400)

Validation Error (400)


Examples

Pagination

Complex Filters

Upsert (Insert or Update)

Insert a record or update it if a conflict occurs on a unique constraint.

Headers

Example

Response

Upsert requires a unique constraint (e.g., primary key or unique index) on the table. The conflict resolution is based on this constraint.

Call RPC Function

Execute a database function via PostgREST RPC. Supports all HTTP methods (GET, POST, PUT, PATCH, DELETE).

Example

Response


Admin Endpoints

The following endpoints require admin authentication.

Headers for Admin Endpoints


List Database Functions

Get all database functions in the public schema. Requires admin authentication.

Example

Response


List Database Indexes

Get all database indexes. Requires admin authentication.

Example

Response


List RLS Policies

Get all Row Level Security policies. Requires admin authentication.

Example

Response


List Database Triggers

Get all database triggers. Requires admin authentication.

Example

Response


List Database Migrations

Get the history of successful custom migrations. InsForge stores these in system.custom_migrations, but the endpoint returns only the migration metadata and executed statements. Requires admin authentication.

Example

Response


Create Database Migration

Create and immediately execute a custom migration against the database. The migration is recorded only if every statement succeeds. Requires admin authentication.

Request Body

Example

Response

Do not include BEGIN, COMMIT, or ROLLBACK inside a custom migration. InsForge executes the migration inside its own transaction.

Execute Raw SQL (Strict Mode)

Execute raw SQL query with strict sanitization. Blocks access to system tables and auth.users. Requires admin authentication.

Request Body

Example

Response


Execute Raw SQL (Relaxed Mode)

Execute raw SQL query with relaxed sanitization. Allows SELECT and INSERT into system tables. Use with caution. Requires admin authentication.

Request Body

Example

Response

This endpoint has relaxed restrictions and can access system tables. Use only when necessary and ensure proper authorization.

Export Database

Export database schema and/or data in SQL or JSON format. Requires admin authentication.

Request Body

Example

Response


Import Database

Import database from SQL file. Requires admin authentication.

Request (multipart/form-data)

Example

Response


Bulk Upsert

Bulk insert or update data from CSV or JSON file. Requires admin authentication.

Request (multipart/form-data)

Example

Response