---
related_nodes: []
---

# Supabase

## Overview

Interact with your Supabase PostgreSQL database using the PostgREST API. This node provides a power-user interface that maps directly to Supabase's REST API, allowing you to perform select, insert, update, delete, and upsert operations on your tables.

## When to Use

Use this node when you need to:
- Query data from your Supabase database
- Insert new records into tables
- Update existing records
- Delete records
- Upsert (insert or update) records

This is a power-user node that requires familiarity with Supabase's PostgREST query syntax.

## Prerequisites

1. A Supabase project
2. Supabase connection configured in Verdalia with:
   - **Project Reference** (from your Supabase URL: `https://<project_ref>.supabase.co`)
   - **API Key** (service_role key for full access, or anon key for public tables)

## Configuration

### Connection
Select your Supabase connection. The connection should have been created with:
- **Key ID**: Your Supabase project reference (the subdomain part of your Supabase URL)
- **Secret**: Your Supabase API key

### Operation
Choose the operation to perform:
- **Select**: Query records from a table
- **Insert**: Create new records
- **Update**: Modify existing records
- **Delete**: Remove records
- **Upsert**: Insert or update records (inserts if not exists, updates if exists)

### Table
The name of the table to operate on (e.g., `users`, `orders`, `products`).

### Query
PostgREST query string for filtering/sorting. Only used for Select, Update, Delete, and Upsert operations.

**Examples:**
- `id=eq.123` - Filter by ID equals 123
- `status=eq.active&created_at=gt.2024-01-01` - Multiple conditions
- `order=created_at.desc&limit=10` - Sort and limit

**Supported Operators:**
| Operator | Description | Example |
|----------|-------------|---------|
| `eq` | Equals | `?name=eq.John` |
| `neq` | Not equals | `?status=neq.deleted` |
| `gt` | Greater than | `?age=gt.18` |
| `gte` | Greater than or equal | `?score=gte.100` |
| `lt` | Less than | `?price=lt.50` |
| `lte` | Less than or equal | `?stock=lte.10` |
| `like` | Pattern match | `?name=like.*son` |
| `ilike` | Case-insensitive | `?email=ilike.*@gmail.com` |
| `in` | In array | `?id=in.(1,2,3)` |
| `is` | Is null/not null | `?deleted_at=is.null` |

**Modifiers:**
- `order=column.asc` or `order=column.desc` - Sort results
- `limit=10` - Limit number of results
- `offset=20` - Skip first N results
- `select=col1,col2` - Return only specific columns

### Body
JSON body for Insert, Update, and Upsert operations. Supports template syntax.

**Examples:**
```json
{
  "name": "John Doe",
  "email": "john@example.com"
}
```

**Template Syntax:**
Reference input data using `{{ input.field }}`:
```json
{
  "user_id": "{{ input.user.id }}",
  "name": "{{ input.user.name }}"
}
```

### Retry
Whether a request is sent again after a failure that passes: a rate limit, a busy server, a dropped connection. Off by default; see [Retries](http_get.md#retries) for how attempts and waits work. Select and Delete are sent again freely. Insert, Update and Upsert are writes, sent again only when Supabase refused them before acting: the connection never opened, or Supabase answered 425 or 429.

## Inputs

| Name | Type | Required | Description |
|------|------|----------|-------------|
| input | any | No | Input data that can be referenced in body using template syntax |

## Outputs

| Name | Type | Description |
|------|------|-------------|
| rows | array | Array of records (for Select, Insert, Update, Upsert) |
| deleted_count | integer | Number of deleted rows (for Delete) |
| error | string | Error message if the request failed; `null` on success |

### Route to error output

With the failure mode set to **Route to error output** (`base_config.failure_mode: "route_to_error"`), a failed request fails the node instead of returning `rows: []`. `rows` and `deleted_count` are skipped, and `error` carries the node error value (`node_id`, `node_type`, `message`, `causes`) in place of the string, with Supabase's message in `message`. The run records the node as failed with its error routed and completes with warnings. On success `error` is skipped. In every other mode `error` is the string above.

## Examples

### Select Active Users

**Configuration:**
- Operation: `select`
- Table: `users`
- Query: `status=eq.active&order=created_at.desc&limit=10`

**Output:**
```json
{
  "rows": [
    {"id": 1, "name": "Alice", "status": "active", "created_at": "2024-01-15T..."},
    {"id": 2, "name": "Bob", "status": "active", "created_at": "2024-01-14T..."}
  ]
}
```

### Insert New User

**Configuration:**
- Operation: `insert`
- Table: `users`
- Body:
```json
{
  "name": "Jane Smith",
  "email": "jane@example.com",
  "status": "active"
}
```

### Update User Status

**Configuration:**
- Operation: `update`
- Table: `users`
- Query: `id=eq.123`
- Body:
```json
{
  "status": "inactive"
}
```

### Delete User

**Configuration:**
- Operation: `delete`
- Table: `users`
- Query: `id=eq.123`

**Output:**
```json
{
  "deleted_count": 1
}
```

### Upsert with Template

**Configuration:**
- Operation: `upsert`
- Table: `users`
- Query: `email=eq.{{ input.user_email }}`
- Body:
```json
{
  "email": "{{ input.user_email }}",
  "name": "{{ input.user_name }}",
  "last_login": "{{ input.login_time }}"
}
```

## Tips

- **Row Level Security**: The service_role key bypasses RLS. Use anon key if you want RLS policies to apply.
- **Query Building**: Build complex queries step by step. Test in Supabase's SQL editor first.
- **Error Handling**: Check the `error` output for detailed error messages from Supabase, or set the failure mode to Route to error output to branch on a failure.
- **Performance**: Use `limit` and `select` to reduce payload size for large tables.
- **URL Encoding**: Special characters in query values should be URL-encoded.

## Troubleshooting

**"Connection not found" error:**
- Verify the connection ID is correct
- Check that the connection is created with the correct project reference and API key

**"Table not found" error:**
- Verify the table name is correct (case-sensitive)
- Check that the table exists in your Supabase project

**"Invalid API key" error:**
- Verify the API key is correct
- For protected tables, ensure you're using the service_role key

**"Row not found" on update/delete:**
- Verify the query matches an existing row
- Check that ID values are correct type (string vs number)
