API overview
WasFor exposes a JSON API for both consoles. The user API operates on the signed-in customer's resources; the admin API operates on the fleet and requires an operator key or an admin session.
Base URLs
| Surface | Base |
|---|---|
| User API | https://<panel-host>/api/user |
| Admin API | https://<panel-host>/api/admin |
| Licensing API | https://api.wasfor.com/v1 |
All traffic must use HTTPS. Plain HTTP requests are redirected and never accepted for authenticated calls.
Authentication
Interactive sessions receive a JWT signed with HS256.
| Claim | Meaning |
|---|---|
uid | User identifier |
role | user, admin, support, billing |
email | Account email |
ver | Token version, bumped on password change |
iss | Always wasfor |
Access tokens live for 2 hours. Refresh tokens are rotated on use and bound to the session. A token whose ver no longer matches the account is rejected.
Authorization: Bearer <access-token>Admin automation should use scoped API keys instead of operator credentials:
Authorization: Bearer wfk_live_<key>Request conventions
Content-Type: application/jsonfor bodies.- Unknown fields are rejected on writes so typos fail loudly.
- Timestamps are ISO 8601 in UTC.
- Identifiers are integers unless stated otherwise.
- Lists accept
page(1-based),per_page(max 100),sortandq.
GET /api/user/sites?page=2&per_page=25&sort=-created_atResponse envelope
Successful responses wrap the payload:
{
"ok": true,
"data": { "id": 42, "domain": "app.example.com" },
"meta": { "page": 1, "per_page": 25, "total": 61 }
}Errors use a stable shape:
{
"ok": false,
"error": {
"code": "validation_failed",
"message": "memory_limit must be between 64M and 1G",
"fields": { "memory_limit": "out_of_range" },
"request_id": "req_01J8Z3K9"
}
}Quote request_id in support tickets; it links directly to server logs.
Status codes
| Code | Meaning |
|---|---|
| 200 | Success |
| 201 | Created |
| 204 | Deleted, no body |
| 400 | Malformed request |
| 401 | Missing or invalid token |
| 403 | Authenticated but not allowed |
| 404 | Resource not found in scope |
| 409 | Conflict, e.g. duplicate domain |
| 422 | Validation failed |
| 429 | Rate limited |
| 5xx | Server error; retry with backoff |
Rate limits
| Scope | Limit |
|---|---|
| Authenticated user | 600 requests / minute |
| Admin key | 1200 requests / minute |
| Auth endpoints | 10 attempts / minute per IP |
Limits return 429 with Retry-After. Implement exponential backoff with jitter rather than fixed retries.
Pagination and filtering
GET /api/admin/users?status=active&package=business&per_page=100meta.total is the total matching the filter, not the page size. Iterate pages until the returned collection is shorter than per_page.
Idempotency
Write endpoints accept an idempotency key so retries do not create duplicates:
POST /api/admin/users
Idempotency-Key: 7c1f9a2e-4b7d-4a1e-9c3f-2f6a8e5d1b40The same key with the same body returns the original result for 24 hours. A different body with the same key returns 409.
Versioning
The API is versioned in the path. Additive fields may appear within a version; clients must ignore unknown keys. Breaking changes ship under a new version with an overlap period.
Quick example
TOKEN="<access-token>"
curl -s https://panel.example.com/api/user/sites \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json"