- Home
- Integrations
- Webhook
- Webhook + PostgreSQL
PostgreSQL API without a backend: write and read data through a webhook
A PostgreSQL API without a backend in nana800 takes three blocks: a webhook receives the request, the PostgreSQL block runs your SQL with data from that request, and the response block returns the result. Values from the request reach the database as separate parameters, so quotes and semicolons in them cannot break your SQL. All you need is a database reachable from the internet and its login and password.
Build it in the builderWhat you can automate
- Save website leads to your own table and return the new record id to the form
- Serve data from the database to a site or mobile app at an address like /orders/:id
- Update the order status when a payment service or CRM sends a notification to the webhook
- Collect events and logs from your services in one table without a separate server
- Work with a database on Supabase, Neon, AWS RDS, Render or your own server
How to set it up
- 1
Prepare the database
The database must be reachable from the internet: the block does not accept localhost or internal network addresses (10.x.x.x, 192.168.x.x). It is a good idea to create a separate database user with access to the needed tables only.
- 2
Add the webhook
A webhook is an address your site or app sends data to. Create a scheme and add the webhook trigger. For writing, set method to POST and a path like /leads. For reading, GET with a path parameter works, for example /orders/:id: the value from the path lands in params, the request body in body.
- 3
Connect PostgreSQL
Add the Postgres external database operation block. Paste the connection string from your provider panel, or fill in the host, port, database name, user and password. SSL mode require fits most cloud databases, disable is for servers without SSL.
- 4
Write the SQL query
In the SQL query field write a command such as INSERT INTO leads (name, phone) VALUES (...) RETURNING id, and put fields from the webhook body in place of the values. A quoted value together with all text inside the quotes becomes one parameter. A query with variables must be a single command.
- 5
Return the result
Add the webhook response block. Return result of the PostgreSQL block through body json: the found rows, or the changed rows for INSERT, UPDATE and DELETE with RETURNING. The number of rows is in row_count. Keep status OK.
- 6
Turn the scheme on and test it
A webhook answers only while its scheme is on. Click the API button in the builder, fill in the body on the Try it tab and click Send: the request really writes to the database. If something is wrong, the reason is in the error_text field of the block. An enabled scheme costs $0.0042 per hour.
Pricing
A run of a Webhook block costs up to $0.001, a run of a PostgreSQL block costs $0.002. Every month the balance is topped up to $3.50 for free, an enabled scheme costs $0.0042 per hour.
Services in this connection
- Webhook
Receive website leads and service events with a webhook and answer requests with no server and no code. Free balance every month, no card needed.
- PostgreSQL
Connect your PostgreSQL database to nana800: save leads, look up orders and update statuses with an SQL query in a scheme. Free balance every month, no card needed.
Frequently asked questions
Build your first scheme for free
Sign-up is free and needs no card. Every month the balance is topped up to $3.50 for free, enough for about 3,500 runs of basic blocks.
Build it in the builder