OneSoluAPI Reference

API Documentation

Everything you need to integrate with the OneSolu platform. RESTful APIs, webhooks, and analytics endpoints.

Authentication

All API requests require authentication via a Bearer token. Include your API key in the Authorization header of every request.

Authorization: Bearer YOUR_API_KEY

Important: Keep your API keys secure. Do not expose them in client-side code or public repositories. Use environment variables to store keys securely.

Base URL

https://api.onesolu.dev/v1

Orders API

POST/api/orders

Create a new order. Provide the items and customer ID in the request body.

Example Request

curl -X POST https://api.onesolu.dev/v1/api/orders \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      { "menu_id": "menu_001", "quantity": 2 },
      { "menu_id": "menu_002", "quantity": 1 }
    ],
    "customer_id": "cust_abc123"
  }'

Example Response

{
  "data": {
    "id": "order_xyz789",
    "customer_id": "cust_abc123",
    "items": [
      { "menu_id": "menu_001", "quantity": 2, "subtotal": 70000 },
      { "menu_id": "menu_002", "quantity": 1, "subtotal": 42000 }
    ],
    "total": 112000,
    "currency": "IDR",
    "status": "pending",
    "created_at": "2025-02-18T10:30:00Z"
  }
}
GET/api/orders/:id

Get the current status and details of an order by its ID.

Example Request

curl -X GET https://api.onesolu.dev/v1/api/orders/order_xyz789 \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

{
  "data": {
    "id": "order_xyz789",
    "customer_id": "cust_abc123",
    "status": "preparing",
    "estimated_ready": "2025-02-18T10:45:00Z",
    "total": 112000,
    "currency": "IDR",
    "created_at": "2025-02-18T10:30:00Z"
  }
}
PUT/api/orders/:id/status

Update the status of an existing order. Valid statuses: pending, preparing, ready, completed, cancelled.

Example Request

curl -X PUT https://api.onesolu.dev/v1/api/orders/order_xyz789/status \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "ready" }'

Example Response

{
  "data": {
    "id": "order_xyz789",
    "status": "ready",
    "updated_at": "2025-02-18T10:42:00Z"
  },
  "message": "Order status updated successfully"
}

Webhooks

POST/api/webhooks

Register a webhook to receive real-time notifications for events like order updates, parking sessions, and analytics triggers.

Example Request

curl -X POST https://api.onesolu.dev/v1/api/webhooks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhooks/onesolu",
    "events": ["order.created", "order.updated", "park.session.ended"],
    "secret": "whsec_your_signing_secret"
  }'

Example Response

{
  "data": {
    "id": "wh_abc123",
    "url": "https://yourapp.com/webhooks/onesolu",
    "events": ["order.created", "order.updated", "park.session.ended"],
    "active": true,
    "created_at": "2025-02-18T10:00:00Z"
  }
}

Webhook Payload Example

{
  "id": "evt_xyz789",
  "type": "order.updated",
  "data": {
    "order_id": "order_xyz789",
    "status": "ready",
    "updated_at": "2025-02-18T10:42:00Z"
  },
  "created_at": "2025-02-18T10:42:01Z"
}

Analytics

GET/api/analytics/daily

Get daily analytics data including API call counts, response times, error rates, and top endpoints. Defaults to the last 7 days.

Example Request

curl -X GET "https://api.onesolu.dev/v1/api/analytics/daily?days=7" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

{
  "data": {
    "period": "7d",
    "total_requests": 4180,
    "avg_response_time_ms": 85,
    "error_rate": 0.023,
    "daily": [
      { "date": "2025-02-12", "requests": 580, "errors": 12 },
      { "date": "2025-02-13", "requests": 720, "errors": 8 },
      { "date": "2025-02-14", "requests": 650, "errors": 15 },
      { "date": "2025-02-15", "requests": 890, "errors": 20 },
      { "date": "2025-02-16", "requests": 1100, "errors": 25 },
      { "date": "2025-02-17", "requests": 430, "errors": 5 },
      { "date": "2025-02-18", "requests": 310, "errors": 3 }
    ],
    "top_endpoints": [
      { "endpoint": "/api/menu", "count": 1540 },
      { "endpoint": "/api/orders", "count": 1280 },
      { "endpoint": "/api/analytics/daily", "count": 860 }
    ]
  }
}

Rate Limits

PlanRequests/minRequests/day
Free601,000
Pro30050,000
EnterpriseUnlimitedUnlimited
Rate limit headers are included in every response:
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 298
X-RateLimit-Reset: 1708257600

Error Codes

CodeStatusDescription
200OKRequest succeeded
201CreatedResource created successfully
400Bad RequestInvalid request body or parameters
401UnauthorizedMissing or invalid API key
404Not FoundResource not found
429Too Many RequestsRate limit exceeded
500Server ErrorInternal server error

Error Response Format

{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or expired API key",
    "status": 401
  }
}