Supabase Integration with SmythOS
Need a powerful, open-source backend for your agents? Connect Supabase to SmythOS and empower your agents to directly read from and write to your PostgreSQL database with ease.
List of Supabase Components
Quickly compare Supabase components by what they do and their key I/O. Click any component name to jump directly to its detailed guide.
Component | Action | What it Does | Inputs | Key Outputs | Use Case |
---|---|---|---|---|---|
Insert Row | Write | Inserts a single new row into a table. | required project_id , table , Body | id | Saving a new user profile to a 'users' table. |
Insert Multiple Rows | Write | Inserts a batch of new rows into a table at once. | required project_id , table , Body | rows | Performing a bulk import of product data. |
Read Rows | Read | Retrieves rows from a table, with optional filters. | required project_id , table | rows | Fetching all tasks from a 'todos' table. |
Get Row | Read | Retrieves a single row from a table by its ID. | required project_id , table , id | id | Fetching a specific user's record. |
Update Row | Write | Updates specific fields in an existing row. | required project_id , table , id , Body | id | Changing a user's subscription status. |
Delete Row | Write | Permanently deletes a row from a table by its ID. | required project_id , table , id | Response | Removing user data upon account closure. |
List Projects | Read | Retrieves a list of all your Supabase projects. | required trigger | projects | Finding the correct project_id for other operations. |
Get Columns | Read | Retrieves the schema (all columns) for a specific table. | required project_id , table | columns | Verifying a table's structure before inserting data. |
Prerequisites
Before you begin, please ensure you have the following:
- An active SmythOS account. (Sign up here).
- A Supabase account with a project created.
- Your Supabase Project's URL and
service_role
secret key.
Getting Started With Supabase
The connection between SmythOS and Supabase is configured using your Project URL and a secure API key.
Step 1: Get Your Supabase Credentials
- Log in to your Supabase Dashboard.
- Select the project you want to connect to.
- In the left menu, navigate to Project Settings (the gear icon).
- Click on the API tab.
- On this page, you will find your Project URL and your project API keys.
- Copy the Project URL.
- Under "Project API keys," find the
service_role
secret key and click "reveal" to see the full key. Copy this key.
Step 2: Store Your Credentials in SmythOS Vault
Your service_role
key grants full access to your database, bypassing any Row Level Security policies. It is a highly sensitive credential.
- In your SmythOS dashboard, navigate to the Vault.
- Create new secrets for your Supabase URL and your
service_role
key. Give them memorable names, likesupabase_project_url
andsupabase_service_key
. - For more details, see the Vault Documentation.
Step 3: Configure a Supabase Component
- In your SmythOS agent graph, drag and drop any Supabase component.
- Click the component to open its Settings panel.
- In the
API Key
(for the Project URL) andRole Secret
(for the service_role key) fields, select the corresponding secrets you saved in the Vault. - Your connection is now configured. You will provide the
project_id
(the reference ID from your URL) as a standard input.
Which Supabase Component Should I Use?
If you need to… | Target | Use this Component | Why this one? |
---|---|---|---|
Add a new user record to a users table | A table name and data | Insert Row | The standard method for creating a single new record in your database. |
Import multiple records at once | A table name and an array of data | Insert Multiple Rows | More efficient for bulk inserts than calling "Insert Row" in a loop. |
Get all records from a products table | A table name | Read Rows | Retrieves multiple rows at once, perfect for fetching entire datasets. |
Change a user's email address | A specific row id | Update Row | Modifies the fields of an existing record without overwriting the entire row. |
Permanently remove a user's data | A specific row id | Delete Row | The standard way to delete a record from a table. |
Verify your connection and find your Project ID | Your Supabase account | List Projects | A simple way to get a list of all your projects and their reference IDs. |
Component Details
This section provides detailed information for each Supabase component.
List Projects
Retrieve a list of all Supabase projects associated with your account.
Inputs
Field | Type | Required | Notes |
---|---|---|---|
trigger | any | Yes | Any input value can be used to trigger the component's execution. |
Outputs
Field | Type | Description |
---|---|---|
projects | array | An array of project objects, each containing details like name, ID, and region. |
Response | object | The full, raw JSON response from the Supabase Management API. |
Headers | object | The HTTP headers from the API response. |
Insert Row
Inserts a single new row into a specified table.
Component-Specific Settings
- Body / Table Row: A JSON editor where you define the data for the new row as a single JSON object.
- Prefer: Controls the response.
return=representation
returns the full created row.
Inputs
Field | Type | Required | Notes |
---|---|---|---|
project_id | string | Yes | The reference ID of your Supabase project (from the URL). |
table | string | Yes | The name of the table to insert data into. |
Outputs
Field | Type | Description |
---|---|---|
id | integer | The id of the newly created row (if returned). |
Response | object | The full, raw JSON response from the Supabase API. |
{
"component": "supabase.insertRow",
"project_id": "your-project-ref-id",
"table": "profiles",
"Body": {
"email": "new.user@example.com",
"full_name": "Jane Doe"
}
}
Delete Row
Permanently deletes one or more rows that match a query.
Inputs
Field | Type | Required | Notes |
---|---|---|---|
project_id | string | Yes | The reference ID of your Supabase project. |
table | string | Yes | The name of the table to delete from. |
id | string | Yes | The filter to identify the row(s) to delete (e.g., eq.123 to delete the row where id equals 123). |
Outputs
Field | Type | Description |
---|---|---|
id | string | The unique identifier of the deleted row, if one was returned. |
Response | object | A successful deletion typically returns an empty response body. |
Headers | object | The HTTP headers from the API response. |
Get Columns
Retrieves the schema (all columns and their types) for a specific table.
Inputs
Field | Type | Required | Notes |
---|---|---|---|
project_id | string | Yes | The reference ID of your Supabase project. |
table | string | Yes | The name of the table whose schema you want to retrieve. |
Outputs
Field | Type | Description |
---|---|---|
columns | object | An object containing the collection of columns and their definitions. |
Response | object | The raw JSON response from the API, which contains the schema details. |
Get Row
Retrieve a single row from a Supabase table by its ID.
Inputs
Field | Type | Required | Notes |
---|---|---|---|
project_id | string | Yes | The reference ID of your Supabase project. |
table | string | Yes | The name of the table to read from. |
id | string | Yes | The ID of the specific row you want to retrieve. |
Outputs
Field | Type | Description |
---|---|---|
id | integer | The id of the retrieved row. |
Response | object | The raw JSON response from the API, containing the full row data in an array. |
Update Row
Updates specific fields in one or more existing rows that match a query.
Component-Specific Settings
- Body: A JSON editor where you define the new values for the columns you want to change (e.g.,
{"status": "shipped"}
).
Inputs
Field | Type | Required | Notes |
---|---|---|---|
project_id | string | Yes | The reference ID of your Supabase project. |
table | string | Yes | The name of the table to update. |
id | string | Yes | The filter to identify the row(s) to update (e.g., eq.123 to update the row where id equals 123). |
Outputs
Field | Type | Description |
---|---|---|
id | integer | The id of the updated row, if a single row was updated and return=representation was set. |
Response | object | The raw JSON response from the API. |
Read Rows
Retrieves multiple rows from a specific table in your Supabase project.
Inputs
Field | Type | Required | Notes |
---|---|---|---|
project_id | string | Yes | Your specific Supabase project identifier. |
table | string | Yes | The name of the Supabase table from which to retrieve rows. |
select | string | Optional | Comma-separated columns to return, e.g., id,name,email . Defaults to * . |
[column_filter] | string | Optional | Add inputs to filter by column using PostgREST syntax (e.g., status=eq.active ). |
Outputs
Field | Type | Description |
---|---|---|
rows | array | The data retrieved from the Supabase table, structured as an array of row objects. |
Response | object | The complete API response from Supabase. |
Insert Multiple Rows
Inserts a batch of new rows into a specified table in a single API call.
Component-Specific Settings
- Body: A JSON editor where you define the data for the new rows as an array of JSON objects.
Inputs
Field | Type | Required | Notes |
---|---|---|---|
project_id | string | Yes | The reference ID of your Supabase project. |
table | string | Yes | The name of the table to insert data into. |
Outputs
Field | Type | Description |
---|---|---|
rows | array | An array of the newly created row objects, if return=representation is used. |
Response | object | The full, raw JSON response from the Supabase API. |
Best Practices & Advanced Tips
- Secure Your Service Key: Your
service_role
key can bypass all database security policies. Never expose it publicly. Always store it in the SmythOSVault
. For read-only operations, consider creating and using theanon
key if your security rules allow it. - Use Row Level Security (RLS): For any production application, enable Row Level Security on your Supabase tables. This provides a critical layer of security, even if your
service_role
key were to be compromised. - Master PostgREST Filtering: The power of Supabase's API comes from its PostgREST filtering capabilities. Learn the operators (
eq
,gt
,lt
,like
,in
, etc.) to build precise queries directly in your component inputs for components likeRead Rows
,Update Row
, andDelete Row
. - Create Database Functions: For complex, multi-step database operations (like "increment a value by 10"), create a PostgreSQL function inside your Supabase project. You can then call this single function from your agent, which is more efficient and secure than making multiple API calls.
Troubleshooting Common Issues
-
Error:
401 Unauthorized
- Cause: The API Key (
anon
orservice_role
key) is incorrect or missing from the request headers. - Solution: Verify that the keys in your SmythOS Vault are correct and match those in your Supabase project's API settings. Ensure they are correctly selected in the component settings.
- Cause: The API Key (
-
Error:
404 Not Found
- Cause: The
project_id
is incorrect, or thetable
name does not exist. - Solution: Double-check your project reference ID and the table name for typos. Ensure you are targeting the correct project.
- Cause: The
-
Write Operation Fails (Insert/Update/Delete)
- Cause: This is often due to a database constraint violation. For example, trying to insert a row with a
user_email
that is marked asUNIQUE
but already exists, or trying to insert anull
value into aNOT NULL
column. - Solution: Check the
Response
output for the detailed error message from PostgreSQL. This will usually tell you exactly which constraint was violated. Ensure the data in yourBody
matches your table's schema.
- Cause: This is often due to a database constraint violation. For example, trying to insert a row with a
What's Next?
You are now ready to build powerful, data-driven applications with the SmythOS Supabase Integration!
Consider these ideas:
-
Build an Agent That...
- Acts as a complete serverless backend for a user registration system. It uses the Firebase Auth Integration for authentication, and then
Insert Row
to save new user profiles to your Supabaseprofiles
table. - Creates a logging service. After any critical action (like sending an email with Resend or processing a payment with Stripe), an agent inserts a log record into a
logs
table in Supabase. - Powers a dynamic website. An agent uses
Read Rows
to fetch content (like blog posts or product listings) from your Supabase database and provides it to a frontend framework.
- Acts as a complete serverless backend for a user registration system. It uses the Firebase Auth Integration for authentication, and then
-
Explore Other Integrations:
- Use Supabase as the source of truth for a marketing campaign. An agent can
Read Rows
to get a list of customer emails, then pass them to the Mailchimp Integration to add them to a new campaign. - When a new record is added to a Supabase table (detected via a webhook), trigger an agent to send a notification to a Slack channel.
- Use Supabase as the source of truth for a marketing campaign. An agent can