API Reference
Complete API reference for the Sophonz platform.
Authentication
All API requests require authentication using an API key.
1Authorization: Bearer YOUR_API_KEY
2Content-Type: application/json
Base URL
1https://api.sophonz.com/v1
Core Endpoints
Applications
List Applications
1GET /applications
Response:
1{
2 "applications": [
3 {
4 "id": "app_123",
5 "name": "My Application",
6 "status": "active",
7 "created_at": "2024-01-01T00:00:00Z",
8 "updated_at": "2024-01-15T12:30:00Z"
9 }
10 ],
11 "total": 1,
12 "page": 1
13}
Get Application
1GET /applications/{id}
Response:
1{
2 "id": "app_123",
3 "name": "My Application",
4 "description": "Application description",
5 "status": "active",
6 "environment": "production",
7 "metrics": {
8 "uptime": 99.9,
9 "response_time": 245,
10 "error_rate": 0.01
11 }
12}
Create Application
1POST /applications
Request Body:
1{
2 "name": "New Application",
3 "description": "Description of the application",
4 "environment": "production",
5 "config": {
6 "monitoring": true,
7 "alerts": true
8 }
9}
Monitoring
Get Metrics
1GET /applications/{id}/metrics
Query Parameters:
start
: Start time (ISO 8601)end
: End time (ISO 8601)metric
: Metric type (response_time, error_rate, throughput)granularity
: Data granularity (1m, 5m, 1h, 1d)
Response:
1{
2 "metric": "response_time",
3 "granularity": "5m",
4 "data": [
5 {
6 "timestamp": "2024-01-15T12:00:00Z",
7 "value": 245.5
8 },
9 {
10 "timestamp": "2024-01-15T12:05:00Z",
11 "value": 238.2
12 }
13 ]
14}
Create Alert
1POST /applications/{id}/alerts
Request Body:
1{
2 "name": "High Error Rate",
3 "condition": {
4 "metric": "error_rate",
5 "operator": ">",
6 "threshold": 0.05
7 },
8 "actions": [
9 {
10 "type": "email",
11 "recipients": ["admin@company.com"]
12 },
13 {
14 "type": "slack",
15 "channel": "#alerts"
16 }
17 ]
18}
AI Insights
Get Insights
1GET /applications/{id}/insights
Response:
1{
2 "insights": [
3 {
4 "id": "insight_123",
5 "type": "performance",
6 "severity": "medium",
7 "title": "Response time increase detected",
8 "description": "Average response time increased by 40% in the last hour",
9 "recommendation": "Consider scaling your application or optimizing slow queries",
10 "timestamp": "2024-01-15T12:30:00Z"
11 }
12 ]
13}
Get Predictions
1GET /applications/{id}/predictions
Query Parameters:
metric
: Metric to predicthorizon
: Prediction horizon (1h, 6h, 24h, 7d)
Response:
1{
2 "metric": "response_time",
3 "horizon": "24h",
4 "predictions": [
5 {
6 "timestamp": "2024-01-15T13:00:00Z",
7 "predicted_value": 250.3,
8 "confidence": 0.85
9 }
10 ]
11}
Deployments
List Deployments
1GET /applications/{id}/deployments
Response:
1{
2 "deployments": [
3 {
4 "id": "deploy_123",
5 "version": "v1.2.4",
6 "status": "success",
7 "started_at": "2024-01-15T10:00:00Z",
8 "completed_at": "2024-01-15T10:05:00Z",
9 "changes": [
10 "Fixed payment processing bug",
11 "Updated user interface"
12 ]
13 }
14 ]
15}
Create Deployment
1POST /applications/{id}/deployments
Request Body:
1{
2 "version": "v1.2.5",
3 "description": "Bug fixes and performance improvements",
4 "config": {
5 "rollback_on_error": true,
6 "health_check_url": "/health"
7 }
8}
Error Codes
| Code | Description |
|------|-------------|
| 400 | Bad Request - Invalid request parameters |
| 401 | Unauthorized - Invalid or missing API key |
| 403 | Forbidden - Insufficient permissions |
| 404 | Not Found - Resource not found |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error - Server error |
Rate Limits
- Standard Plan: 1,000 requests per hour
- Pro Plan: 10,000 requests per hour
- Enterprise Plan: Unlimited
Rate limit headers are included in all responses:
1X-RateLimit-Limit: 1000
2X-RateLimit-Remaining: 999
3X-RateLimit-Reset: 1642248000
SDKs
Official SDKs are available for:
- JavaScript/Node.js
- Python
- Go
- Java
- C#
JavaScript Example
1import { Sophonz } from '@sophonz/sdk';
2
3const client = new Sophonz({
4 apiKey: 'your-api-key'
5});
6
7const apps = await client.applications.list();
8console.log(apps);
Python Example
1from sophonz import Client
2
3client = Client(api_key='your-api-key')
4apps = client.applications.list()
5print(apps)