# Supabase

> Interact with Supabase databases via PostgREST API.

Source: https://cotera.co/docs/reference/tools/individual-tools/supabase

---

**Authentication Type:** API Key\
**Description:** Interact with Supabase databases via PostgREST API.

***

## Authentication

To authenticate, you'll need a Supabase API key. Learn how to get one in the [Supabase API documentation](https://supabase.com/docs/guides/api).

***

## Database Operations

Perform CRUD operations on Supabase database tables.

### Read Records

Query and retrieve records from a database table.

**Operation Type:** Query (Read)

**Parameters:**

* **url** `string` (required): The Supabase project URL (e.g., <https://your-project.supabase.co>)
* **table** `string` (required): The name of the table to read from
* **select** `string` (nullable): Columns to select, comma-separated. Defaults to \* (all columns)
* **filter** `string` (nullable): PostgREST filter query (e.g., "status=eq.active", "age=gte.18")
* **order** `string` (nullable): Order by clause (e.g., "created\_at.desc", "name.asc")
* **limit** `number` (nullable): Maximum number of rows to return
* **offset** `number` (nullable): Number of rows to skip

**Returns:**

* **data** `array of objects`: Array of records from the table
* **count** `number` (nullable): Total count of records (if requested)

**Example Usage:**

```json
{
  "url": "https://xyzcompany.supabase.co",
  "table": "customers",
  "select": "id,name,email,created_at",
  "filter": "status=eq.active",
  "order": "created_at.desc",
  "limit": 50,
  "offset": 0
}
```

### Create Records

Insert new records into a database table.

**Operation Type:** Mutation (Write)

**Parameters:**

* **url** `string` (required): The Supabase project URL (e.g., <https://your-project.supabase.co>)
* **table** `string` (required): The name of the table to insert into
* **data** `any` (required): Record or array of records to insert
* **returning** `string` (nullable): What to return after insert: "minimal", "representation", or column names. Defaults to "representation"

**Returns:**

* **data** `array of objects`: Array of created records
* **count** `number` (nullable): Number of records created

**Example Usage:**

```json
{
  "url": "https://xyzcompany.supabase.co",
  "table": "customers",
  "data": {
    "name": "John Smith",
    "email": "john.smith@example.com",
    "phone": "+1-555-123-4567",
    "status": "active"
  },
  "returning": "representation"
}
```

### Update Records

Modify existing records in a database table.

**Operation Type:** Mutation (Write)

**Parameters:**

* **url** `string` (required): The Supabase project URL (e.g., <https://your-project.supabase.co>)
* **table** `string` (required): The name of the table to update
* **data** `any` (required): Fields to update
* **filter** `string` (required): PostgREST filter to specify which records to update (e.g., "id=eq.123")
* **returning** `string` (nullable): What to return after update: "minimal", "representation", or column names. Defaults to "representation"

**Returns:**

* **data** `array of objects`: Array of updated records
* **count** `number` (nullable): Number of records updated

**Example Usage:**

```json
{
  "url": "https://xyzcompany.supabase.co",
  "table": "customers",
  "data": {
    "status": "inactive",
    "updated_at": "2024-01-15T10:30:00Z"
  },
  "filter": "id=eq.123",
  "returning": "representation"
}
```

### Delete Records

Remove records from a database table.

**Operation Type:** Mutation (Write)

**Parameters:**

* **url** `string` (required): The Supabase project URL (e.g., <https://your-project.supabase.co>)
* **table** `string` (required): The name of the table to delete from
* **filter** `string` (required): PostgREST filter to specify which records to delete (e.g., "id=eq.123")
* **returning** `string` (nullable): What to return after delete: "minimal", "representation", or column names. Defaults to "representation"

**Returns:**

* **data** `array of objects`: Array of deleted records
* **count** `number` (nullable): Number of records deleted

**Example Usage:**

```json
{
  "url": "https://xyzcompany.supabase.co",
  "table": "customers",
  "filter": "status=eq.inactive",
  "returning": "representation"
}
```

### Upsert Records

Insert new records or update existing ones.

**Operation Type:** Mutation (Write)

**Parameters:**

* **url** `string` (required): The Supabase project URL (e.g., <https://your-project.supabase.co>)
* **table** `string` (required): The name of the table to upsert into
* **data** `any` (required): Record or array of records to upsert
* **onConflict** `string` (nullable): Columns to use for conflict resolution (comma-separated)
* **returning** `string` (nullable): What to return after upsert: "minimal", "representation", or column names. Defaults to "representation"

**Returns:**

* **data** `array of objects`: Array of upserted records
* **count** `number` (nullable): Number of records upserted

**Example Usage:**

```json
{
  "url": "https://xyzcompany.supabase.co",
  "table": "customers",
  "data": {
    "email": "john.smith@example.com",
    "name": "John Smith",
    "phone": "+1-555-123-4567",
    "status": "active"
  },
  "onConflict": "email",
  "returning": "representation"
}
```

***

## Common Use Cases

**Data Synchronization:**

* Sync external system data with Supabase tables using upsert operations
* Read filtered data to compare with external sources before updating
* Bulk insert records from CSV files or API responses for data migration

**Application Backend:**

* Create user profiles and customer records for web applications
* Update user preferences and settings with targeted filters
* Delete inactive or expired records to maintain database cleanliness

**Analytics and Reporting:**

* Query filtered and ordered datasets for business intelligence dashboards
* Read time-series data with date range filters for trend analysis
* Aggregate customer data by status, region, or other dimensions

**Real-time Data Management:**

* Insert real-time events and transactions as they occur
* Update inventory levels and product availability in e-commerce systems
* Upsert user activity logs to maintain accurate session tracki

