Postgres Databases - API Documentation
Full reference for all commands and admin features.
In all URLs below, replace XXX with your AI Apps Account ID, found in your account settings.
How Endpoints Work
Two ways to call each endpoint - read this first
App Command (API Call)
POST your request to
Mode / Webhook (Direct URL)
POST directly to the endpoint URL shown in each section. The fields go in the POST body as standard form fields (the same fields you would include in an HTML form POST). Use this method for provider webhooks, website forms, or any third-party system that sends form data. No API key is required - the account ID is part of the URL.
POST your request to
https://api.aiappsapi.com with your API key and account ID in the POST body. The fields described in each section below go inside the jsonData POST field as a JSON-encoded string. Use this method when your server is making the call and you have your API credentials available.Mode / Webhook (Direct URL)
POST directly to the endpoint URL shown in each section. The fields go in the POST body as standard form fields (the same fields you would include in an HTML form POST). Use this method for provider webhooks, website forms, or any third-party system that sends form data. No API key is required - the account ID is part of the URL.
Two ways to call each action: You can use the unified
postgrescommand with an action field set to query, insert, update, or delete. Or you can call the individual shortcut commands (postgresquery, postgresinsert, postgresupdate, postgresdelete) which do the same thing without needing the action field. Both methods are shown in each section below.
Query Data
command: postgrescommand (action=query) | shortcut: postgresquery
Read data from your PostgreSQL database. You can provide a raw SQL query string for full control, or use the structured fields to build a query without writing SQL. Supports single table queries, multi-table JOINs, column selection, and WHERE filtering. PostgreSQL-specific features like JSON columns and array types are fully supported when using raw SQL. Returns an array of matching rows and a row count.
POST App Command URL
https://api.aiappsapi.com app: postgres command: postgrescommand (with action=query)
https://api.aiappsapi.com app: postgres command: postgresquery
This command is only available as an App Command. It is not available as a direct mode/webhook URL.
Required Fields
| Field Name | Field Key | Notes |
|---|---|---|
| Database Name | db | The name of the database connection to use. Must match a connection you configured in the admin area. |
You must provide one of the following:
sql for a raw SQL query, table for a single table query, or tables for a multi-table JOIN query.Query Fields (provide one)
| Field Name | Field Key | Notes |
|---|---|---|
| Raw SQL | sql | A complete SQL query string. Use this for full control including PostgreSQL-specific syntax. Example: SELECT * FROM users WHERE age > 21 |
| Table | table | A single table name to query. Use with fields and where to build the query automatically. |
| Tables | tables | An array of table names for a JOIN query. The first table is the primary table. Use with joinOn to specify the column to join on. |
Optional Fields
| Field Name | Field Key | Notes |
|---|---|---|
| Columns | fields | An array of column names to return. If omitted, all columns are returned. Example: ["name", "email"] |
| Where Clause | where | A SQL WHERE condition to filter results. Example: age > 21 AND status = 'active' |
| Join Column | joinOn | The column name to JOIN on when using the tables array. All tables are joined on this same column. |
Insert Data
command: postgrescommand (action=insert) | shortcut: postgresinsert
Insert one or more new rows into a PostgreSQL table. Provide your data as an array of row objects where each object maps column names to values. You can insert multiple rows in a single call.
POST App Command URL
https://api.aiappsapi.com app: postgres command: postgrescommand (with action=insert)
https://api.aiappsapi.com app: postgres command: postgresinsert
This command is only available as an App Command. It is not available as a direct mode/webhook URL.
Required Fields
| Field Name | Field Key | Notes |
|---|---|---|
| Database Name | db | The name of the database connection to use. |
| Table | table | The table to insert rows into. |
| Row Data | newValues | An array of row objects. Each object maps column names to values. Example: [{"name": "John", "email": "john@test.com"}, {"name": "Jane", "email": "jane@test.com"}] |
Update Data
command: postgrescommand (action=update) | shortcut: postgresupdate
Update a single column value on one or more rows that match a WHERE condition. Specify the column to update, the new value, and a WHERE clause to target the right rows.
POST App Command URL
https://api.aiappsapi.com app: postgres command: postgrescommand (with action=update)
https://api.aiappsapi.com app: postgres command: postgresupdate
This command is only available as an App Command. It is not available as a direct mode/webhook URL.
Required Fields
| Field Name | Field Key | Notes |
|---|---|---|
| Database Name | db | The name of the database connection to use. |
| Table | table | The table containing the rows to update. |
| Column Name | field | The name of the column to update. |
| New Value | newValue | The value to set in the specified column. |
| Where Clause | where | A SQL WHERE condition to match the rows to update. Example: id = 5 or status = 'pending' |
Delete Data
command: postgrescommand (action=delete) | shortcut: postgresdelete
Delete one or more rows from a PostgreSQL table that match a WHERE condition. This cannot be undone.
POST App Command URL
https://api.aiappsapi.com app: postgres command: postgrescommand (with action=delete)
https://api.aiappsapi.com app: postgres command: postgresdelete
This command is only available as an App Command. It is not available as a direct mode/webhook URL.
Required Fields
| Field Name | Field Key | Notes |
|---|---|---|
| Database Name | db | The name of the database connection to use. |
| Table | table | The table to delete rows from. |
| Where Clause | where | A SQL WHERE condition to match the rows to delete. Example: id = 5 or created_at < '2024-01-01' |
Admin: Database Connections
Connect and manage your PostgreSQL databases
The Manage Databases page in the admin area is where you add, edit, and remove your PostgreSQL database connections. Each connection stores the hostname, database name, port, username, and password needed to reach your PostgreSQL server.
Features
| Feature | Description |
|---|---|
| Add a Database | Enter your PostgreSQL server hostname, database name, port (default 5432), username, and password. The system connects to your server and creates the database if it does not already exist. |
| Multiple Connections | Connect as many databases as you need. Each one gets a name you can reference in API calls using the db field. |
| Remove a Database | Delete a connection when you no longer need it. You can also drop the database from the server entirely. |
Your PostgreSQL server must be remotely accessible. This works with AWS RDS, any cloud-hosted database, or any self-hosted server that allows remote connections.
Admin: SQL Editor with AI Assistant
Browse, query, and edit your data from the dashboard
The SQL Editor gives you a full database management interface directly in the admin dashboard. Select any connected database and start browsing tables, running queries, and editing data. The built-in AI assistant can write SQL queries for you from plain English descriptions. Full PostgreSQL syntax is supported including JSON columns, arrays, and advanced query types.
SQL Editor Features
| Feature | Description |
|---|---|
| Browse Tables | View all tables in your database. Click any table to see its rows with pagination for large datasets. |
| Run Queries | Type any SQL query and execute it. Full PostgreSQL syntax is supported. Results are displayed in an editable table format. |
| Inline Editing | Click on any cell in the results table to edit its value directly. Changes are saved back to your database immediately. |
| Bulk Delete | Select multiple rows using checkboxes and delete them all at once. |
| Pagination | Large result sets are automatically paginated so you can browse through thousands of rows efficiently. |
AI SQL Assistant
| Feature | Description |
|---|---|
| Natural Language Queries | Type what you want in plain English and the AI writes the SQL for you. For example, type "show me all orders from last month" and the AI generates the correct SELECT statement with proper PostgreSQL syntax. |
| Smart Query Mode | When enabled, the AI automatically reads your database schema including table names, column names, and primary keys. This lets the AI write accurate, ready-to-run queries without any manual setup or schema description. |
| One-Click Execute | After the AI generates a query, run it with one click and see the results instantly in the editor. |