Connect Supabase storage to ittybit

View Markdown

This guide shows you how to connect your Supabase Storage bucket to ittybit using connections, and trigger automations when new files are uploaded.

1. Get S3 credentials from Supabase

First, ensure your storage bucket exists.

Using SQL (recommended):

INSERT INTO storage.buckets (id, name) VALUES ('ittybit-files', 'ittybit-files');

Get credentials:

  • Go to Settings → API in Supabase.
  • Copy the S3 Access Keys (access key ID and secret access key).
  • Note the S3 endpoint for your region.

2. Create a connection in ittybit

Save the credentials as a connection via the webapp or the API:

curl -X POST "https://api.ittybit.com/connections" \
-H "Authorization: Bearer ITTYBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "name": "Supabase Storage",
  "kind": "s3",
  "endpoint": "https://YOUR_PROJECT_REF.supabase.co/storage/v1/s3",
  "region": "us-east-1",
  "access_key_id": "YOUR_ACCESS_KEY_ID",
  "secret_access_key": "YOUR_SECRET_ACCESS_KEY"
}'

3. Trigger automations on upload

Create a database trigger to run your ittybit automation on each new upload:

CREATE OR REPLACE FUNCTION trigger_ittybit_on_insert()
RETURNS TRIGGER LANGUAGE PLPGSQL AS $$
BEGIN
  PERFORM NET.HTTP_POST(
    URL := 'https://api.ittybit.com/automations/YOUR_AUTOMATION_ID/run',  -- Replace with your automation ID
    HEADERS := JSONB_BUILD_OBJECT(
      'Content-Type', 'application/json',
      'Authorization', 'Bearer YOUR_ITTYBIT_API_KEY'  -- Replace with your key
    ),
    BODY := JSONB_BUILD_OBJECT(
      'url', CONCAT('https://YOUR_SUPABASE_PROJECT.supabase.co/storage/v1/object/public/ittybit-files/', NEW.NAME)
    )
  );
  RETURN NEW;
END;
$$;

CREATE TRIGGER on_new_object
  AFTER INSERT ON storage.objects
  FOR EACH ROW EXECUTE FUNCTION trigger_ittybit_on_insert();

4. Trigger automations via API

You can also trigger an automation run directly via the API:

curl -X POST https://api.ittybit.com/automations/YOUR_AUTOMATION_ID/run \
  -H "Authorization: Bearer YOUR_ITTYBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://YOUR_SUPABASE_PROJECT.supabase.co/storage/v1/object/public/ittybit-files/my-file.mp4"
  }'

5. Push outputs back to Supabase

Use the destination prop on tasks or the upload task kind in runs to push processed files back to your Supabase bucket using the connection you created:

curl -X POST "https://api.ittybit.com/tasks" \
-H "Authorization: Bearer ITTYBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://YOUR_SUPABASE_PROJECT.supabase.co/storage/v1/object/public/ittybit-files/my-file.mp4",
  "kind": "video",
  "connection_id": "con_your_supabase_connection",
  "destination": "s3://ittybit-files/processed/my-file-720p.mp4",
  "options": {
    "width": 1280,
    "format": "mp4"
  }
}'

See Push output files to your own storage for more details on using connections with tasks and runs.

On this page