Supabase: Write transformed rows to a table
Time: ~15 minutes | Difficulty: Intermediate | Prerequisites: A Supabase project, a Supabase API key, and a Slashbin data stream with a published model
TL;DR: A Slashbin custom destination can post to Supabase’s REST API. Supabase maps the top-level keys of the request to table columns, and Slashbin sends an envelope around your transformed row. So create a landing table with the envelope’s keys as columns. Your row arrives in the payload column.
The Problem
You want transformed rows in a Supabase table, with no code of your own in between. Supabase’s REST API is built on PostgREST, which turns each top-level key of the request body into a column. Slashbin does not send your row bare: every custom destination receives an envelope with your transformed row nested inside it. A table shaped like your row alone rejects the envelope.
The Solution
Make the table match the envelope. The envelope’s top-level keys are:
slashbin_job_idproject_iddata_stream_idtopictransformed_atpayload: your transformed rowmetadata
Create a landing table with one column for each key. Make payload and metadata jsonb columns. Query or copy from payload into your own tables from there.
Step 1: Create a Landing Table in Supabase
Create a table with the seven columns above. Name it something you will recognize, since its name goes in the destination URL.
Step 2: Add a Custom Destination in Slashbin
- Add a custom destination to your data stream.
- Set its URL to your project’s REST address for the table:
https://<ref>.supabase.co/rest/v1/<table>, where<ref>is your project reference and<table>is the landing table. - Send your key on the
apikeyheader. Supabase’s API keys guide says to send publishable and secret keys on theapikeyheader, not onAuthorization: Bearer.
A secret key bypasses row-level security. Use it only if you mean to, and keep it out of anything shared. A publishable key is subject to your row-level security policies, so the table needs a policy that allows the insert.
Step 3: Confirm the Row
Send an event through the stream, then check the Delivery Log and the table:
201 Createdmeans the row was written. Supabase returns no body by default, so an empty response is success. (PostgREST preferences )- A 4xx response usually means a column is missing or misnamed, or the key was refused. The response body in the Delivery Log says which.
- Retries and replays send the destination’s own headers, so the
apikeyheader goes out with them.
Next Steps
- Receive Supabase changes in Slashbin: Supabase: Send database webhooks to Slashbin.
- Compare with a destination that takes your payload verbatim: VideoAsk to Klaviyo.
- Browse every supported source and destination on Integrations.