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.
Base URLhttps://klaroskope.com/api/v1
Quick start#
Create a key under API keys on your Account page, then send your first sample.
# 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.
{
"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
idan 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) orcompact. Compact shortens a longfinal_layer.text, reportsoutputsas booleans and leaves outdetail. It suits a model with a limited context window.- ioc_formatquery
raw(default) ordefanged. Defanged rewrites URLs, domains, IP addresses and email addresses so they cannot be clicked or resolved by accident.
{
"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.
| Field | Type | Meaning |
|---|---|---|
| schema_version | string | The contract version. "1" for this reference. |
| id | string | null | Id of the stored result. Null when the result was not stored, for example on a refusal. |
| created_at | string | null | ISO 8601 UTC time of a stored result. Null on the analyze response itself. |
| status | enum | complete, refused, failed or timeout. |
| delivery_confidence | enum | standard, low or none. none means no decoded layer was delivered. Read this before trusting final_layer. |
| quality_score | number | 0 to 1. How readable the delivered layer is judged to be. |
| decoder_chain | object[] | One entry per decoded layer, in order. |
| .label | string | Display name of the technique. Wording may change. |
| .category | string | The family the technique belongs to, such as Encoding or PowerShell. |
| .key | string | null | The key the layer used, when the layer names one. |
| layer_count | integer | Number of layers decoded. |
| family | string | null | A recognised obfuscator or kit name, when one is identified. |
| file_type | string | null | The detected input type. |
| iocs | object | Indicators 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_confidence | object | The subset of iocs judged low confidence, in the same format. Empty types are omitted. |
| ioc_format | enum | raw or defanged. Applies to iocs and ioc_low_confidence. final_layer, outputs and detail stay raw. |
| final_layer | object | The decoded payload. |
| .text | string | null | The readable text. Shortened in the compact view when long. |
| .length | integer | Length of the full text, in characters. |
| .truncated | boolean | True when text is shorter than the full payload. |
| mitre_techniques | object[] | ATT&CK techniques observed, each with id, name and tactic. |
| processing_time_ms | number | Engine time for the analysis. |
| message | string | null | A plain-language note when the result needs one, such as the reason for a refusal. |
| view | enum | full or compact, echoing the request. |
| outputs | object | Full 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. |
| detail | object | Full 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.
{
"schema_version": "1",
"error": {
"code": "key_expired",
"message": "This API key has expired."
}
}| Status | Code | What to do |
|---|---|---|
| 400 |
| The body or a query option is not valid. |
| 401 |
| Send a valid key. Create a new one if this one was removed or has expired. |
| 403 |
| The account or key is not allowed to do this. |
| 404 |
| No stored result with that id belongs to this account. |
| 411 |
| Send a Content-Length header. |
| 413 |
| The sample is over the size the site accepts. |
| 415 |
| Use application/json for text and multipart/form-data for files. |
| 429 |
| The daily API allowance or the plan's submissions are used up. Honour Retry-After when present. |
| 500 |
| Our fault. Retry, and tell us if it persists. |
| 503 |
| Temporary. Retry after a short wait. |
| 504 |
| 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 aRetry-Afterheader 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=defangedto keep the response small and the indicators inert. - When
delivery_confidenceislowornone, 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.