Ga naar inhoud

API

Deze inhoud is nog niet vertaald.

Everything you set in the dashboard for a site is one document: mode, bot score bands, firewall rules, rate limits, gates, waiting room, headers and policy. With the account key you read that document, change it and write it back. The rules of a site can then live in your repository, go through review and be applied from a pipeline. The API works on every plan.

One key per account, for every site in it. Create it in Account › API key. It is shown once, so store it then. Making a new key stops the old one within a minute, so update your scripts first. See Account, plans and security.

Every call carries two things:

  • the key, as Authorization: Bearer your_api_key;
  • the site id, in the X-Tenant-ID header or as ?tenant_id= in the address.

Each IP address can make 60 calls a minute. AI assistants use the same key through MCP.

Terminal window
curl -H "Authorization: Bearer $QLYNE_API_KEY" -H "X-Tenant-ID: your_site_id" \
"https://app.qlyne.com/api/protection?format=yaml" > qlyne.yaml

GET /api/protection returns JSON by default. Ask for YAML with ?format=yaml or Accept: application/yaml. The YAML lists one item per line, so a change reads well in a diff.

Terminal window
# check without saving
curl -X PUT -H "Authorization: Bearer $QLYNE_API_KEY" -H "X-Tenant-ID: your_site_id" \
-H "Content-Type: application/yaml" --data-binary @qlyne.yaml \
"https://app.qlyne.com/api/protection?dry_run=1"
# apply: the same call without ?dry_run=1

PUT /api/protection takes JSON or YAML, by the Content-Type, up to 256 KB. It replaces the rules of the site:

  • a section missing from the document goes back to its default;
  • a list in the document replaces the whole list;
  • an unknown setting is an error, so a typo does not pass silently.

With ?dry_run=1 Qlyne checks the document and saves nothing. The answer is 200 with valid, saved and protection, the rules as they would be saved. Without it, the connector picks up the new rules within a minute.

In a pipeline, run the call with ?dry_run=1 on pull requests and the real one on merge. The dashboard checks with the same rules, so a document the API accepts is one the screen accepts.

FieldWhat it setsPage
modeobserve or enforce, for the whole siteEvents and reports
under_attackUnder attack mode, a challenge on every pageBot Management
challengeChallenged routes, difficulty, how long a pass lastsBot Management
bot_scoreBot score on or off, and what to do in each bandBot Management
block_ai, trap, tor, reputationAI crawlers, scanner trap, Tor exit nodes, shared reputationBot Management
waf, rules, ip, rate_limitsManaged rules, your own rules, IP lists, rate limitsWAF & Firewall
login, formsLogin protection and form protectionAccount Protection
gatesAccess gatesAccess
queue_routesRoutes that go through the waiting roomWaiting Room
headers, csp, page_cache, consentSecurity headers, Content Security Policy, page cache, consent bannerPage Shield
signalsWhether the connector sends the Qlyne-* headers to your appSignals to your app

A Free site accepts the paid fields, but the connector does not apply them: see Plans. Gate passwords never come back in the document. It carries only a hash, so the document you read can be sent back as it is.

GET /api/metrics, with the same key and site, returns the Prometheus metrics of your account only: decisions by action, waiting room sizes and the rest. Point your own Prometheus or Grafana at it. When the Qlyne server does not answer, the call returns 503 with a line of text; try again in a minute.

With the page cache on the Qlyne proxy or hosted, you purge it on your own site’s address. This call uses the connector secret, not the account key, so keep it on your server:

Terminal window
curl -X POST -H "Authorization: Bearer your_connector_secret" \
-H "Content-Type: application/json" -d '{"paths": ["/blog/"]}' \
"https://example.com/__qlyne/purge"

The body takes {"all": true}, {"paths": [...]} (by prefix) or {"tags": [...]}. The answer is {"purged": n}, the number of copies cleared. A call without the right secret gets 404. Tags and the dashboard button are under Purge.

Errors come back as JSON. The error field holds a stable code; decide on it, since the text next to it can change.

HTTPerrorWhen
400TENANT_REQUIREDThe site id is missing.
400INVALID_BODYThe body is not valid JSON or YAML, or is not an object. message says what failed.
401UNAUTHORIZEDThe key is missing or wrong, or the site is not in this account.
403TENANT_BLOCKEDThe site is blocked or inactive.
413TOO_LARGEThe document is over 256 KB.
422INVALID_RULESA field failed. errors maps each field to its message, like challenge.routes or rules.0.conditions.1.values.

More than 60 calls in a minute from one IP address get 429; wait for the minute to turn.

The connector also tells your app what it saw about each request in Qlyne-* headers, such as Qlyne-Bot-Score and Qlyne-Verified-Bot. Your code reads them like any other header. The full list is under Signals to your app.