API Overview
REST API fundamentals, authentication, and getting started.
Introduction
The pxlpeak API is organized around REST principles. It accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes and authentication.
Authentication
Authenticate your requests using API keys. Include your key in the Authorization header:
curl https://api.pxlpeak.com/v1/analytics \
-H "Authorization: Bearer pk_live_xxx..."API Key Types
| Type | Prefix | Usage |
|------|--------|-------|
| Live | pk_live_ | Production requests |
| Test | pk_test_ | Development & testing |
Security: Never expose your API keys in client-side code. Use environment variables and server-side requests.
Base URL
All API requests should be made to:
https://api.pxlpeak.com/v1Request Format
Send data as JSON with the appropriate content type:
const response = await fetch('https://api.pxlpeak.com/v1/leads', {
method: 'POST',
headers: {
'Authorization': 'Bearer pk_live_xxx...',
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: 'user@example.com',
source: 'website',
metadata: {
campaign: 'summer_sale'
}
}),
});Response Format
All responses follow a consistent structure:
{
"success": true,
"data": {
"id": "lead_abc123",
"email": "user@example.com",
"created_at": "2026-01-11T10:30:00Z"
},
"meta": {
"request_id": "req_xyz789"
}
}Error Handling
Errors return appropriate HTTP status codes with detailed messages:
{
"success": false,
"error": {
"code": "invalid_request",
"message": "The 'email' field is required",
"field": "email"
},
"meta": {
"request_id": "req_xyz789"
}
}Common Status Codes
| Code | Description | |------|-------------| | 200 | Success | | 201 | Created | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 404 | Not Found | | 429 | Rate Limited | | 500 | Server Error |