API Reference

The Lexia Platform API is a RESTful API that allows you to interact with your Lexia project programmatically. All API endpoints are authenticated using your project's API keys.

Base URL

All API requests should be made to your project's API URL:

https://your-project-id.lexiaplatform.com

Authentication

API Keys

Lexia uses API keys to authenticate requests. You can find your API keys in the Lexia Dashboard.

Include your API key in the Authorization header:

curl -H "Authorization: Bearer YOUR_API_KEY" \
     https://your-project-id.lexiaplatform.com/rest/v1/users

Service Role Key

The service role key has full access to your project and bypasses Row Level Security (RLS). Use this key for server-side operations.

Warning: Never expose your service role key in client-side code.

Anonymous Key

The anonymous key is safe to use in client-side code. It respects Row Level Security policies.

Rate Limiting

API requests are rate limited per API key:

  • Free tier: 500 requests per hour
  • Pro tier: 10,000 requests per hour
  • Enterprise: Custom limits

Rate limit headers are included in responses:

X-RateLimit-Limit: 500
X-RateLimit-Remaining: 499
X-RateLimit-Reset: 1640995200

Error Handling

The API uses standard HTTP status codes and returns error details in JSON format:

{
  "code": "23505",
  "details": "Key (email)=([email protected]) already exists.",
  "hint": null,
  "message": "duplicate key value violates unique constraint \"users_email_key\""
}

Common Error Codes

CodeStatusDescription
400Bad RequestInvalid request parameters
401UnauthorizedMissing or invalid API key
403ForbiddenInsufficient permissions
404Not FoundResource not found
409ConflictResource already exists
422Unprocessable EntityValidation error
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error

Endpoints

Authentication

POST /auth/v1/signup

Create a new user account.

Request:

{
  "email": "[email protected]",
  "password": "password123"
}

Response:

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "bearer",
  "expires_in": 3600,
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "email": "[email protected]",
    "created_at": "2023-01-01T00:00:00Z"
  }
}

POST /auth/v1/token

Sign in an existing user.

Request:

{
  "email": "[email protected]",
  "password": "password123"
}

Database

GET /rest/v1/{table}

Query data from a table.

Query Parameters:

  • select: Columns to return
  • filter: Filter conditions
  • order: Sort order
  • limit: Maximum number of rows
  • offset: Number of rows to skip

Example:

curl "https://your-project-id.lexiaplatform.com/rest/v1/users?select=id,email&limit=10"

POST /rest/v1/{table}

Insert new rows into a table.

Request:

[
  {
    "name": "John Doe",
    "email": "[email protected]"
  }
]

PATCH /rest/v1/{table}

Update existing rows.

Request:

{
  "name": "Jane Doe"
}

Query Parameters:

  • id: Row ID to update

DELETE /rest/v1/{table}

Delete rows from a table.

Query Parameters:

  • id: Row ID to delete

SDKs

We provide official SDKs for popular languages:

Webhooks

Lexia can send webhooks when certain events occur in your project. Configure webhooks in the Lexia Dashboard.

Supported Events

  • user.created - New user signs up
  • user.updated - User profile updated
  • user.deleted - User account deleted
  • data.inserted - New row inserted
  • data.updated - Row updated
  • data.deleted - Row deleted

Webhook Payload

{
  "type": "user.created",
  "created_at": "2023-01-01T00:00:00Z",
  "data": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "email": "[email protected]"
  }
}