Integrating bkend in Your App
Overview
This document covers:
Essential setup for calling the bkend API from your app
A fetch helper function with common headers for all requests
Distinguishing between authenticated and unauthenticated requests
Prerequisites
Publishable Key
Console > API Keys
Client key with pk_ prefix
Access Token
Login API response
JWT (for authenticated APIs)
Required Headers
All REST API requests require the following headers.
Content-Type
application/json
Yes
Request body format
X-API-Key
{pk_publishable_key}
Yes
Publishable Key (issued in the console). Includes project ID and environment
Authorization
Bearer {accessToken}
Conditional
Only for APIs that require authentication
API Base URL
All endpoints are relative to this URL.
Fetch Helper Function
Use this helper function to call the bkend API throughout your app. It automatically includes the required headers with every request.
Usage Examples
Unauthenticated Request (Signup)
Authenticated Request (Create Data)
List Data
Testing with curl
Before integrating with your app, verify that the API works correctly using curl.
CORS
The bkend API supports direct calls from browsers. You can call the API using fetch from your client app without any additional CORS configuration.
Error Handling
400
Missing required field or type mismatch
Check the request body
401
Token expired or missing
refreshAccessToken() handles automatic refresh
403
Permission denied (RLS rejection)
Check permission settings
404
Resource not found (table/data)
Check path and table name
429
Rate limit exceeded
Add retry interval
500
Server error
Retry after a short delay
Integration Flow Summary
Next Steps
Token Storage and Refresh — Detailed token management strategies
Auth Form Patterns — Signup and login form implementation
Data CRUD App Patterns — Managing data in your app
File Upload App Patterns — File upload implementation
Error Handling Guide — Error response handling strategies
Hands-on Project Cookbook — Apply integration patterns in real apps
Last updated