Getting Started
Learn how to authenticate and make your first API request
Authentication
The Berican API uses API keys for authentication. Include your API key in the Authorization header of each request.
Authorization Header:
Authorization: Bearer YOUR_API_KEYGet Your API Key
Generate API keys from your Dashboard → API Keys. You can create multiple keys with different permissions.
Example Request
curl https://bericanlabs.com/api/v1/sites \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"Rate Limits
All API endpoints are rate limited to ensure fair usage and system stability.
100
requests per minute
429
status code when exceeded
Rate limit headers are included in every API response:
X-RateLimit-Limit: 100 X-RateLimit-Remaining: 95 X-RateLimit-Reset: 1609459200
Error Handling
The API uses standard HTTP status codes to indicate success or failure. All errors return JSON with an error message.
Error Response Format:
{
"error": "Invalid site type",
"details": "Type must be 'static' or 'wordpress'",
"received": "invalid"
}Pagination
List endpoints support pagination via query parameters. Results are returned with pagination metadata.
Query Parameters:
page- Page number (default: 1)limit- Results per page (default: 25, max: 100){
"data": [...],
"pagination": {
"page": 1,
"limit": 25,
"total": 100,
"totalPages": 4
}
}Sites API
Create and manage static sites and WordPress installations
/api/v1/sitesRetrieve a paginated list of all sites for the authenticated user. Supports filtering by type and status.
Query Parameters
pageintegerPage number for pagination
Example: 1limitintegerNumber of results per page (max: 100)
Example: 25typestringFilter by site type: 'static' or 'wordpress'
Example: staticstatusstringFilter by status: 'active', 'pending', 'provisioning', 'error', 'stopped'
Example: activeResponse
200Success{
"data": [
{
"id": "site_abc123",
"name": "My Portfolio",
"slug": "my-portfolio",
"type": "static",
"status": "active",
"url": "https://my-portfolio.bericanlabs.com",
"subdomain": "my-portfolio",
"repository": {
"url": "github.com/user/portfolio",
"branch": "main"
},
"domains": [
{
"id": "dom_xyz789",
"name": "example.com",
"status": "active"
}
],
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}
],
"pagination": {
"page": 1,
"limit": 25,
"total": 1,
"totalPages": 1
}
}Code Examples
curl https://bericanlabs.com/api/v1/sites?page=1&limit=25 \
-H "Authorization: Bearer YOUR_API_KEY"/api/v1/sitesCreate a new static site or WordPress installation. The site will be provisioned asynchronously.
Request Body
Site configuration
{
"name": "My Awesome Site",
"type": "static",
"repository": "github.com/username/repo",
"branch": "main"
}Response
201Created{
"data": {
"id": "site_abc123",
"name": "My Awesome Site",
"slug": "my-awesome-site",
"type": "static",
"status": "pending",
"url": "https://my-awesome-site.bericanlabs.com",
"subdomain": "my-awesome-site",
"repository": {
"url": "github.com/username/repo",
"branch": "main"
},
"createdAt": "2024-01-15T10:30:00Z"
},
"message": "Site created successfully. Provisioning will begin shortly."
}Code Examples
curl -X POST https://bericanlabs.com/api/v1/sites \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My Awesome Site",
"type": "static",
"repository": "github.com/username/repo",
"branch": "main"
}'Get your API key from Dashboard → API Keys
/api/v1/sites/:idRetrieve detailed information about a specific site.
Path Parameters
idstringrequiredSite ID
Example: site_abc123Response
200{
"id": "site_abc123",
"name": "My Portfolio",
"slug": "my-portfolio",
"type": "static",
"status": "active",
"url": "https://my-portfolio.bericanlabs.com",
"subdomain": "my-portfolio",
"repository": {
"url": "github.com/user/portfolio",
"branch": "main"
},
"domains": [],
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}Code Examples
curl https://bericanlabs.com/api/v1/sites/site_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"/api/v1/sites/:id/deployManually trigger a deployment for a site. The deployment will run asynchronously.
Path Parameters
idstringrequiredSite ID
Example: site_abc123Response
200{
"message": "Deployment triggered successfully",
"deploymentId": "dep_xyz789",
"status": "pending"
}Code Examples
curl -X POST https://bericanlabs.com/api/v1/sites/site_abc123/deploy \
-H "Authorization: Bearer YOUR_API_KEY"/api/v1/sites/:idPermanently delete a site and all associated resources.
Path Parameters
idstringrequiredSite ID
Example: site_abc123Response
200{
"message": "Site deleted successfully"
}Code Examples
curl -X DELETE https://bericanlabs.com/api/v1/sites/site_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"Domains API
Manage custom domains and check availability
/api/v1/domainsRetrieve a list of all domains associated with your sites.
Response
200{
"data": [
{
"id": "dom_xyz789",
"name": "example.com",
"status": "active",
"sslStatus": "active",
"siteId": "site_abc123",
"createdAt": "2024-01-15T10:30:00Z"
}
]
}Code Examples
curl https://bericanlabs.com/api/v1/domains \
-H "Authorization: Bearer YOUR_API_KEY"/api/v1/domains/checkCheck if a domain is available for registration or transfer.
Request Body
{
"domain": "example.com"
}Response
200{
"domain": "example.com",
"available": true,
"price": 1200,
"currency": "KES"
}Deployments API
Monitor and manage site deployments
/api/v1/deployments/:idRetrieve information about a specific deployment.
Path Parameters
idstringrequiredDeployment ID
Example: dep_xyz789Response
200{
"id": "dep_xyz789",
"siteId": "site_abc123",
"status": "success",
"commitHash": "abc123def456",
"branch": "main",
"startedAt": "2024-01-15T10:30:00Z",
"completedAt": "2024-01-15T10:32:00Z",
"duration": 120
}/api/v1/deployments/:id/logsRetrieve logs for a specific deployment.
Path Parameters
idstringrequiredDeployment ID
Example: dep_xyz789Response
200{
"logs": [
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "info",
"message": "Starting deployment..."
},
{
"timestamp": "2024-01-15T10:30:05Z",
"level": "info",
"message": "Building site..."
}
]
}Webhooks API
Configure webhooks for real-time event notifications
/api/v1/webhooksRetrieve a list of all configured webhooks.
Response
200{
"data": [
{
"id": "hook_abc123",
"url": "https://example.com/webhook",
"events": ["deployment.success", "deployment.failed"],
"active": true,
"createdAt": "2024-01-15T10:30:00Z"
}
]
}/api/v1/webhooksCreate a new webhook to receive event notifications.
Request Body
{
"url": "https://example.com/webhook",
"events": ["deployment.success", "deployment.failed"],
"secret": "your-webhook-secret"
}Response
201{
"id": "hook_abc123",
"url": "https://example.com/webhook",
"events": ["deployment.success", "deployment.failed"],
"active": true,
"createdAt": "2024-01-15T10:30:00Z"
}