API Reference Overview
This section provides complete documentation for all Lorn AI API endpoints.
Base URL
| Environment | Base URL |
|---|---|
| Production | https://{{YOUR_STORE_URL}} |
| Sandbox | https://sandbox.{{YOUR_STORE_URL}} |
| Local Development | http://localhost:8000 |
All API requests should be made to your assigned base URL.
Authentication
Include your API key in the X-ACP-API-Key header:
curl "https://{{YOUR_STORE_URL}}/acp/products" \
-H "X-ACP-API-Key: {{YOUR_API_KEY}}"See Authentication for details on API keys, request signing, and security.
Request Format
Headers
| Header | Required | Description |
|---|---|---|
X-ACP-API-Key | Yes | Your API authentication key |
Accept | Recommended | application/json |
Content-Type | For POST/PATCH | application/json |
Idempotency-Key | Recommended | Unique key for idempotent operations |
Request Body
All POST and PATCH requests accept JSON bodies:
curl -X POST "https://{{YOUR_STORE_URL}}/checkout_sessions" \
-H "Content-Type: application/json" \
-H "X-ACP-API-Key: {{YOUR_API_KEY}}" \
-d '{"items": [{"product_id": "prod_123", "quantity": 1}]}'Response Format
All responses are JSON with consistent structure.
Success Response
{
"items": [...],
"page": 1,
"page_size": 10,
"total": 42
}Error Response
{
"detail": "Error message describing what went wrong"
}Or for structured errors:
{
"error": {
"type": "invalid_request",
"code": "missing_required_field",
"message": "The 'items' field is required",
"param": "items"
}
}HTTP Status Codes
| Code | Description |
|---|---|
200 | Success |
201 | Created (for POST creating resources) |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
404 | Not Found - Resource doesn’t exist |
405 | Method Not Allowed - Invalid operation |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error |
503 | Service Unavailable - Backend not configured |
Pagination
List endpoints support pagination:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number (1-indexed) |
page_size | integer | 10 | Results per page (max: 100) |
Example
curl "https://{{YOUR_STORE_URL}}/acp/products?page=2&page_size=20" \
-H "X-ACP-API-Key: {{YOUR_API_KEY}}"Response
{
"items": [...],
"page": 2,
"page_size": 20,
"total": 150
}Rate Limits
| Tier | Requests/Minute | Requests/Day |
|---|---|---|
| Sandbox | 60 | 1,000 |
| Production | 600 | 100,000 |
| Enterprise | Custom | Custom |
Rate limit headers are included in responses:
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 599
X-RateLimit-Reset: 1705312260API Versioning
The current API version is 2025-01-01. Include the version header for stability:
curl "https://{{YOUR_STORE_URL}}/acp/products" \
-H "X-ACP-API-Key: {{YOUR_API_KEY}}" \
-H "API-Version: 2025-01-01"Endpoints Summary
Product Discovery
| Method | Endpoint | Description |
|---|---|---|
GET | /acp/products | Search products |
GET | /acp/products/search | Search products (alias) |
GET | /acp/products/{id} | Get product by ID |
Checkout Sessions
| Method | Endpoint | Description |
|---|---|---|
POST | /checkout_sessions | Create checkout |
GET | /checkout_sessions/{id} | Get checkout state |
PATCH | /checkout_sessions/{id} | Update checkout |
POST | /checkout_sessions/{id}/complete | Complete purchase |
POST | /checkout_sessions/{id}/cancel | Cancel checkout |
Webhooks
| Method | Endpoint | Description |
|---|---|---|
POST | /webhooks/emit | Emit webhook event |
Utilities
| Method | Endpoint | Description |
|---|---|---|
GET | /health | Health check |
SDKs & Libraries
Official examples are available in:
Testing
Sandbox Environment
Use the sandbox environment for development and testing:
- No real payments processed
- Fixed tax rate (8%) and shipping ($7.99)
- Test data that can be freely modified
Health Check
Verify connectivity:
curl "https://{{YOUR_STORE_URL}}/health"Expected response:
{
"status": "ok",
"supabase": "configured"
}Support
- Documentation Issues: Open a GitHub issue
- API Support: mayank@lornai.com.com
- Enterprise: mayank@lornai.com