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:string
required
Your Supabase API key (anon key for client requests, service role key for server requests).
string
Bearer token for authenticated requests:
Bearer <JWT_TOKEN>string
Set to
application/json for POST/PATCH requests.string
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:string
PostgREST error code.
string
Human-readable error message.
string | null
Additional error details if available.
string | null
Suggested fix for the error.
HTTP Status Codes
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
