DocumentationAPIv1

API reference

Send an obfuscated script or file and get back the decoded layers, the readable final payload and the indicators found in it, as JSON. The API runs the same analysis as the site, on your account and plan.

Quick start#

Create a key under API keys on your Account page, then send your first sample.

Request
# 1. Keep the key out of your shell history and source control
export KLAROSKOPE_KEY="ks_live_..."

# 2. Send a sample: Base64 hiding a one-line PowerShell command
curl -s https://klaroskope.com/api/v1/analyze \
  -H "Authorization: Bearer $KLAROSKOPE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"V3JpdGUtSG9zdCAiaGVsbG8gZnJvbSBodHRwczovL2V4YW1wbGUuY29tL2RlbW8i"}'

The response, shortened here, names each layer that was peeled and carries the readable result.

Response
{
  "schema_version": "1",
  "id": "ab921047-9010-4e97-a2a1-c0da752c49d1",
  "status": "complete",
  "delivery_confidence": "standard",
  "decoder_chain": [
    { "label": "Base64", "category": "Encoding", "key": null }
  ],
  "layer_count": 1,
  "iocs": { "urls": ["https://example.com/demo"], "ips": [], "domains": [] },
  "final_layer": {
    "text": "Write-Host \"hello from https://example.com/demo\"",
    "length": 48,
    "truncated": false
  },
  "view": "full"
}

Authentication#

Send your key as a Bearer token on each request: Authorization: Bearer ks_live_...

A key acts as your account. It can submit samples and read your stored results, and its analyses count against your plan. A key expires on the date you chose when creating it. Remove a key on the Account page and it stops working at once. If a key may have leaked, remove it and create another.

Analyze text#

POST/api/v1/analyze

For a pasted script or an encoded string.

Request

Authorizationheaderrequired
Bearer followed by your key.
Content-Typeheaderrequired
application/json
textbodyrequired
The sample, as a string. It is the only field the body accepts.
viewquery
full or compact. See response options.
ioc_formatquery
raw or defanged. See response options.
curl -s https://klaroskope.com/api/v1/analyze \
  -H "Authorization: Bearer $KLAROSKOPE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"V3JpdGUtSG9zdCAiaGVsbG8gZnJvbSBodHRwczovL2V4YW1wbGUuY29tL2RlbW8i"}'

Returns

200 with a result object, or an error.

Analyze a file#

POST/api/v1/analyze/file

For a file on disk: scripts, Office documents, PDFs, emails, archives, images and SVG. The accepted formats are the ones the site accepts, listed in the FAQ, with the same size limits.

Request

Authorizationheaderrequired
Bearer followed by your key.
Content-Typeheaderrequired
multipart/form-data. Most HTTP clients set it for you.
fileform partrequired
The file. One per request.
viewquery
full or compact. See response options.
ioc_formatquery
raw or defanged. See response options.
curl -s https://klaroskope.com/api/v1/analyze/file \
  -H "Authorization: Bearer $KLAROSKOPE_KEY" \
  -F "file=@invoice.js"

Returns

200 with a result object, or an error.

Fetch a stored result#

GET/api/v1/results/{id}

Reads back a result of your account. It does not start an analysis and does not count against your plan.

Request

Authorizationheaderrequired
Bearer followed by your key.
idpathrequired
The id an analysis returned.
viewquery
full or compact. See response options.
ioc_formatquery
raw or defanged. See response options.
curl -s "https://klaroskope.com/api/v1/results/ab921047-9010-4e97-a2a1-c0da752c49d1?view=compact&ioc_format=defanged" \
  -H "Authorization: Bearer $KLAROSKOPE_KEY"

Returns

200 with a result object, or 404 when no result with that id belongs to your account.

Response options#

Two query parameters shape the response. Both work on all three endpoints.

viewquery
full (default) or compact. Compact shortens a long final_layer.text, reports outputs as booleans and leaves out detail. It suits a model with a limited context window.
ioc_formatquery
raw (default) or defanged. Defanged rewrites URLs, domains, IP addresses and email addresses so they cannot be clicked or resolved by accident.
With ioc_format=defanged
{
  "ioc_format": "defanged",
  "iocs": { "urls": ["hxxps://example[.]com/demo"] }
}

The result object#

An analysis that ran returns 200 with this object, including when the engine declined the sample or could not decode it. Check status and delivery_confidence before using the payload.

FieldTypeMeaning
schema_versionstringThe contract version. "1" for this reference.
idstring | nullId of the stored result. Null when the result was not stored, for example on a refusal.
created_atstring | nullISO 8601 UTC time of a stored result. Null on the analyze response itself.
statusenumcomplete, refused, failed or timeout.
delivery_confidenceenumstandard, low or none. none means no decoded layer was delivered. Read this before trusting final_layer.
quality_scorenumber0 to 1. How readable the delivered layer is judged to be.
decoder_chainobject[]One entry per decoded layer, in order.
.labelstringDisplay name of the technique. Wording may change.
.categorystringThe family the technique belongs to, such as Encoding or PowerShell.
.keystring | nullThe key the layer used, when the layer names one.
layer_countintegerNumber of layers decoded.
familystring | nullA recognised obfuscator or kit name, when one is identified.
file_typestring | nullThe detected input type.
iocsobjectIndicators by type, each an array of strings: urls, ips, domains, emails, file_paths, registry_keys, hashes, crypto_addresses, mutexes, credentials, api_keys, sensitive_paths.
ioc_low_confidenceobjectThe subset of iocs judged low confidence, in the same format. Empty types are omitted.
ioc_formatenumraw or defanged. Applies to iocs and ioc_low_confidence. final_layer, outputs and detail stay raw.
final_layerobjectThe decoded payload.
.textstring | nullThe readable text. Shortened in the compact view when long.
.lengthintegerLength of the full text, in characters.
.truncatedbooleanTrue when text is shorter than the full payload.
mitre_techniquesobject[]ATT&CK techniques observed, each with id, name and tactic.
processing_time_msnumberEngine time for the analysis.
messagestring | nullA plain-language note when the result needs one, such as the reason for a refusal.
viewenumfull or compact, echoing the request.
outputsobjectFull view: yara, sigma, yara_low_confidence, sigma_low_confidence and report, each text or null. Compact view: the same keys as booleans. A stored result does not keep them.
detailobjectFull view only. Container and format-specific analysis (PDF, Office, email, archive, SVG, image). Informational: its shape follows the site and is not versioned.

Errors#

A failed call returns a non-2xx status and a body with a stable code and a human-readable message. Branch on the code, not on the message text. New codes may be added, so handle an unfamiliar one by its HTTP status.

Error body
{
  "schema_version": "1",
  "error": {
    "code": "key_expired",
    "message": "This API key has expired."
  }
}
StatusCodeWhat to do
400
  • invalid_request
The body or a query option is not valid.
401
  • key_missing
  • key_malformed
  • key_unknown
  • key_revoked
  • key_expired
Send a valid key. Create a new one if this one was removed or has expired.
403
  • account_suspended
  • key_scope
  • forbidden
The account or key is not allowed to do this.
404
  • not_found
No stored result with that id belongs to this account.
411
  • length_required
Send a Content-Length header.
413
  • payload_too_large
The sample is over the size the site accepts.
415
  • unsupported_media_type
Use application/json for text and multipart/form-data for files.
429
  • api_daily_cap
  • quota_exceeded
The daily API allowance or the plan's submissions are used up. Honour Retry-After when present.
500
  • internal_error
Our fault. Retry, and tell us if it persists.
503
  • service_unavailable
Temporary. Retry after a short wait.
504
  • analysis_timeout
The analysis ran out of time. A smaller sample may complete.

Usage and limits#

  • An analysis through the API counts against your plan in the same way as one on the site.
  • Fetching a stored result is free.
  • Each account also has a daily API allowance. When it is used up the API answers 429 with api_daily_cap, and a Retry-After header where a wait time applies.
  • Most analyses finish in seconds. Allow up to 90 seconds on the client before giving up.
  • Results appear in your dashboard history alongside the ones submitted on the site.

Notes for AI agents#

  • Ask for ?view=compact&ioc_format=defanged to keep the response small and the indicators inert.
  • When delivery_confidence is low or none, say so to the person you are working for.
  • Analysis is static. The service reads the sample and does not run it.

Versioning#

The version is in the path and in schema_version. Within v1, fields may be added and enumerations may gain values, so ignore fields you do not recognise. Removing or renaming a documented field would ship as a new version. The detail object and the wording of labels and messages are outside that promise.

Questions or a problem with the API: contact us.