Introduction
Supabase provides a RESTful API that is automatically generated from your PostgreSQL database schema. The API is powered by PostgREST, which provides instant RESTful APIs for your database.Base URL
Your API is available at:<PROJECT_REF> with your project reference ID found in your project settings.
Auto-Generated API
Every time you create or modify a table, view, or function in your database, the REST API is automatically updated to reflect those changes. No additional configuration is required.Example
If you create a table namedcountries with the following schema:
GET /rest/v1/countries- List all countriesPOST /rest/v1/countries- Create a new countryPATCH /rest/v1/countries?id=eq.1- Update a countryDELETE /rest/v1/countries?id=eq.1- Delete a country
API Documentation
You can view the auto-generated API documentation for your project at:Common Headers
All API requests require specific headers:Your Supabase API key (anon key for client requests, service role key for server requests).
Bearer token for authenticated requests:
Bearer <JWT_TOKEN>Set to
application/json for POST/PATCH requests.Control the response format:
return=representation- Return the full object after insert/updatereturn=minimal- Return no content (204 response)return=headers-only- Return only headers
Example Request
Response Format
Success Responses
Successful responses return JSON data:Error Responses
Error responses include a message and details:PostgREST error code.
Human-readable error message.
Additional error details if available.
Suggested fix for the error.
HTTP Status Codes
| Status Code | Description |
|---|---|
200 | Successful GET request |
201 | Successful POST request (created) |
204 | Successful DELETE or update with no content |
400 | Bad request (invalid parameters) |
401 | Unauthorized (missing or invalid API key) |
403 | Forbidden (insufficient permissions) |
404 | Not found (table or resource doesn’t exist) |
406 | Not acceptable (invalid Accept header) |
409 | Conflict (unique constraint violation) |
416 | Range not satisfiable (invalid pagination) |
500 | Internal server error |
Filtering and Querying
The REST API supports powerful filtering using query parameters:Basic Filters
Combining Filters
Multiple filters are combined with AND logic:Ordering
Pagination
Selecting Columns
Vertical Filtering (Relationships)
Query related data using foreign keys:Stored Procedures
Call PostgreSQL functions via the API:Performance Tips
Use select to limit columns
Use select to limit columns
Only request the columns you need to reduce payload size:
Use indexes for filtered columns
Use indexes for filtered columns
Create database indexes on columns you frequently filter by:
Implement pagination
Implement pagination
Always use pagination for large datasets:
Use count=exact sparingly
Use count=exact sparingly
Only request total counts when necessary as it can be expensive:
Rate Limits
API rate limits vary by plan:- Free tier: Unlimited requests (with CPU limits)
- Pro tier: Unlimited requests (higher CPU limits)
- Enterprise: Custom limits
Next Steps
Authentication
Learn how to authenticate API requests
Database Operations
Explore CRUD operations
Storage API
Work with file storage
Edge Functions
Call serverless functions
