Skip to Content
DocsRecipesSupabase: Write transformed rows to a table

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_id
  • project_id
  • data_stream_id
  • topic
  • transformed_at
  • payload: your transformed row
  • metadata

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

  1. Add a custom destination to your data stream.
  2. 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.
  3. Send your key on the apikey header. Supabase’s API keys guide  says to send publishable and secret keys on the apikey header, not on Authorization: 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 Created means 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 apikey header goes out with them.

Next Steps