Skip to content

API Overview

The можно REST API provides programmatic access to feature flags, segments, environments, API keys, and audit data. It is the same API that powers the web dashboard and SDKs.

Base URL

All API requests use your можно instance as the base URL:

http://localhost:8080/api/v1

For production:

https://<your-mozhno-instance>/api/v1

Authentication

можно supports two authentication methods, both using the Authorization: Bearer header:

JWT (JSON Web Token)

Used for human users accessing the web dashboard. JWTs are obtained by logging in.

bash
curl -X POST "http://localhost:8080/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"email": "admin@example.com", "password": "your-password"}'

Response:

json
{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "refreshToken": "dGhpcyBpcyBhIHJlZnJlc2ggdG9rZW4...",
  "user": {
    "id": 1,
    "email": "admin@example.com",
    "name": "Admin",
    "role": "ADMIN",
    "status": "ACTIVE",
    "avatar": null,
    "locale": "en",
    "createdAt": "2026-01-01T00:00:00Z",
    "lastActiveAt": "2026-06-21T10:00:00Z"
  }
}
PropertyDescription
Access token lifetime15 minutes (configurable via JWT_ACCESS_TOKEN_TTL_MINUTES)
Refresh token lifetime30 days (configurable via JWT_REFRESH_TOKEN_TTL_DAYS)
Refresh rotationToken family rotation — old token revoked on refresh, reuse of revoked token revokes entire family

Refresh tokens:

bash
curl -X POST "http://localhost:8080/api/v1/auth/refresh" \
  -H "Content-Type: application/json" \
  -d '{"refreshToken": "dGhpcyBpcyBhIHJlZnJlc2ggdG9rZW4..."}'

API Key

Used for machine clients — SDKs, CI/CD pipelines, and automated scripts. API keys are created and managed in the dashboard under Settings → API Keys.

bash
curl "http://localhost:8080/api/v1/flags" \
  -H "Authorization: Bearer <your-api-key>"
PropertyDescription
Format64-character Base64url-encoded random string (no prefix)
EnvironmentEach key is bound to a specific environment
TypesSERVER (read+write) or FRONTEND (read-only)
LifetimeUntil revoked

The API key is sent in the Authorization: Bearer header, the same as JWT. The server distinguishes JWT from API key automatically.

Warning: API keys are secrets. Never commit them to source control or expose them in client-side browser code. For browser applications, use the FRONTEND key type and restrict access.

Request & Response Format

  • Content-Type: application/json
  • Accept: application/json

Success Response

Single resource — returned directly:

json
{
  "id": 1,
  "key": "checkout_v2",
  "name": "Checkout Redesign v2",
  "description": "New checkout flow",
  "flagType": "RELEASE",
  "enabled": true,
  "archived": false,
  "tags": ["checkout", "ui-redesign"],
  "createdAt": "2026-06-01T10:00:00Z",
  "lastUsedAt": "2026-06-15T14:30:00Z"
}

List (paginated) response:

json
{
  "items": [...],
  "page": 0,
  "size": 20,
  "totalItems": 142,
  "totalPages": 8
}

Error Response

json
{
  "error": "human-readable error message",
  "code": "NOT_FOUND",
  "traceId": "abc123"
}

Common Error Codes

HTTP StatusError CodeDescription
400BAD_REQUESTRequest body or parameters invalid
400VALIDATION_ERRORRequest body failed validation (includes details array)
401UNAUTHORIZEDMissing or invalid authentication
401INVALID_CREDENTIALSLogin failed
401TOKEN_REUSEStolen refresh token detected
403FORBIDDENInsufficient permissions
404NOT_FOUNDResource does not exist
409CONFLICTResource already exists
405METHOD_NOT_ALLOWEDWrong HTTP method
500INTERNAL_ERRORUnexpected server error

Pagination

List endpoints support offset-based pagination:

bash
curl "http://localhost:8080/api/v1/flags?page=0&size=20" \
  -H "Authorization: Bearer $TOKEN"
ParameterTypeDefaultDescription
pageInteger0Zero-based page number
sizeInteger20Items per page (max: 100)

API Categories

CategoryBase PathUsed By
Flags/api/v1/flagsDashboard, CI/CD
Segments/api/v1/segmentsDashboard
Environments/api/v1/environmentsDashboard
Contexts/api/v1/contextsDashboard
API Keys/api/v1/api-keysDashboard
Audit/api/v1/auditDashboard
Projects/api/v1/projectsDashboard
Users/api/v1/usersDashboard (Admin)
Settings/api/v1/settingsDashboard (Admin)
Integrations/api/v1/integrationsDashboard
Tags/api/v1/tagsDashboard
Metrics/api/v1/metricsDashboard
Auth/api/v1/authLogin, refresh, logout

SDK Endpoints

EndpointMethodAuthDescription
/api/client/featuresGETAPI KeyFetch all flags for the environment (ETag support)
/api/client/evaluatePOSTAPI KeyEvaluate flags with a given context
/api/client/metricsPOSTAPI KeySend usage metrics

Swagger UI & OpenAPI

Interactive API documentation is available at:

http://localhost:8080/swagger-ui.html

Machine-readable OpenAPI 3.1 specification:

http://localhost:8080/v3/api-docs

Generate client libraries:

bash
openapi-generator generate \
  -i http://localhost:8080/v3/api-docs \
  -g java \
  -o ./generated-client

Examples

Create a Flag

bash
curl -X POST "http://localhost:8080/api/v1/flags" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "checkout_v2",
    "name": "Checkout Redesign v2",
    "description": "New checkout flow with one-click purchase",
    "flagType": "RELEASE",
    "projectId": 1
  }'

Get SDK Rules

bash
curl "http://localhost:8080/api/client/features" \
  -H "Authorization: Bearer <your-api-key>"

Archive a Flag

bash
curl -X POST "http://localhost:8080/api/v1/flags/42/archive" \
  -H "Authorization: Bearer $TOKEN"

Next Steps

Released under the AGPL v3.0 License.