Skip to main content

REST API overview

Use REST to automate the same workspace resources available in the dashboard. Start with authentication and workspace discovery, then operate on the returned IDs. A route's existence, check health, and rotator eligibility are separate states in API responses too.

Base URLs​

In the default stack, use either the frontend's same-origin API at http://localhost:5050/api or the direct loopback backend at http://127.0.0.1:5656/api. In a deployed instance, use its configured public HTTPS origin. Examples in endpoint headings include /api already.

Observability endpoints are at the backend root: /healthz, /readyz, and /metrics. They have separate access protection and are not under /api.

First authenticated workflow​

Scroll to see a wide diagram, or open a larger view.
  1. Send POST /api/login with your account's email and password as JSON. Copy the returned token into your client's bearer-token configuration.
  2. Send GET /api/workspaces and choose an ID from your memberships.
  3. Send X-Workspace-ID on resource requests so an account-default change cannot silently redirect your automation to another workspace.
  4. Start with a read such as GET /api/getProxyPage/1?pageSize=20.
  5. For writes, check the endpoint's required workspace role. Import accepts multipart data; a successful import is followed by asynchronous checking.

A read request has this shape:

GET /api/getProxyPage/1?pageSize=20
Authorization: Bearer <token-from-login>
X-Workspace-ID: 42

For Bash/curl examples on the reference pages, define the base origin and read your token without echoing it into the terminal. Choose a workspace ID returned by your own installation:

MAGLANE_ORIGIN=http://127.0.0.1:5656
MAGLANE_WORKSPACE_ID=42
read -rs -p 'Maglane bearer token: ' MAGLANE_TOKEN

Then make a request:

curl --silent --show-error --fail-with-body \
-H "Authorization: Bearer $MAGLANE_TOKEN" \
-H "X-Workspace-ID: $MAGLANE_WORKSPACE_ID" \
"$MAGLANE_ORIGIN/api/getProxyPage/1?pageSize=20"

These variables are client-side conveniences. They are not backend settings. Replace example IDs and reserved hostnames before live calls. Treat bearer tokens and credential-bearing API responses as secrets.

Authentication headers​

HeaderPurpose
Authorization: Bearer <token>Authenticates the account on protected API routes.
X-Workspace-ID: 42Chooses a workspace the account is allowed to access. Omission uses its default membership.
Content-Type: application/jsonDescribes a JSON request body. Let curl choose the multipart boundary when using -F.
X-Observability-Token: <token>Authenticates a monitoring request when public observability is disabled. Separate from the account JWT.

The token's global admin claim does not grant membership in every workspace. See authentication and workspace selection.

Choose an endpoint group​

TaskReference
Sign in, rotate tokens, recover passwords, edit account/settingsAuth and account
Discover workspaces, invite members, change rolesWorkspaces
Import, tag, filter, inspect, export, manage lifecycleProxies
Create listener ports and select upstreamsRotating proxies
Subscribe to webpages and inspect scrape outcomesScrape sources
Configure threshold rules, destinations, and delivery retriesAlerts
Change instance settings, requeue, inspect releases/probesAdmin and system
Select related read fields or update workspace settingsGraphQL

Data formats​

Most routes exchange JSON objects. Import routes use multipart/form-data. Exports return text, some legacy actions return JSON strings, and 204 has no response body. Auth middleware can return plain-text errors. Check status and content type before decoding. Error handling gives a client strategy for these differences.

Pagination and filtering​

Proxy list pages are one-based. Use /getProxyPage/1, then increment the page while keeping the same filters. Choose a small pageSize while learning. Source lists use their own paged endpoint; source-proxy lists use a page query parameter.

For example:

/api/getProxyPage/1?pageSize=20&state=active&status=alive&protocol=http&tagId=4&tagId=9

Repeated tagId values match ANY selected tag. Repeated lifecycle states also match any selected state. Different filter groups combine, so this request still requires active state, alive health, and the HTTP filter. Unknown health is excluded by alive/dead health filters. Preserve health_known when presenting list results; false alive alone does not prove a failed check.

Sorting and pages describe the inventory as it is read. Concurrent imports, deletions, and new check results can change later pages. They are not a transactional inventory snapshot. Use the export workflow for a formatted selection rather than treating a paginated UI list as an immutable dataset.

Request size limits​

API_UPLOAD_MAX_BODY_BYTES limits multipart uploads, API_JSON_MAX_BODY_BYTES limits JSON bodies, and GRAPHQL_MAX_QUERY_BYTES limits GraphQL query text. Oversized requests return 413. Split an import into bounded batches when appropriate; do not retry the same oversized payload indefinitely.

Response status conventions​

StatusMeaning for a client
200, 201, 204Success. Creation commonly uses 201; do not decode a body for 204.
400Correct invalid input or parameters.
401Sign in again or supply a valid token.
403Inspect global role, workspace membership/role, CORS, or endpoint protection.
404Resource is unavailable in the request's scope.
409Resolve duplicate/conflicting state, empty eligible pool, or activation capacity.
413Reduce request/query size.
429Respect Retry-After.
500, 503Inspect the error and retry policy. A mutation may have partially committed.

Error handling explains which operations to inspect before a retry.