Skip to content

Latest commit

 

History

History
508 lines (399 loc) · 21.2 KB

API.md

File metadata and controls

508 lines (399 loc) · 21.2 KB

Beamline API

Beamline tells you whether a software artifact is hostile. /v1/lookup reports what is already known, /v1/analyze finds out, and /v1/flush forgets.

GET  /v1/lookup?purl={purl}                 what is known about a release
GET  /v1/lookup?url={url}                   ... about an exact URL
GET  /v1/lookup?sha256={64hex}              ... about exact bytes
GET  /v1/lookup?purl=a&purl=b               up to 50 per request

POST /v1/analyze?purl={purl}                analyze a release; streams
POST /v1/analyze?url={url}                  analyze what a URL serves
POST /v1/analyze?sha256={64hex}&refresh=1   re-analyze bytes already held
POST /v1/analyze                            analyze the request body

POST /v1/flush?purl=|url=|sha256=           forget the cached answers for one
                                            artifact; token required

GET  /healthz                               liveness

A lookup never starts an analysis. An analyze call starts one only when the answer is not already known. A typical client looks up first and analyzes only what comes back unanalyzed.

Authentication

A token is optional for lookups and analyses. Send one as Authorization: Bearer … to raise your quota. /v1/flush always requires one. Get a token at https://console.atomdrift.com/.

A self-hosted deployment may require a token on every API route. Your token goes no further than Beamline.

Quotas

Requests are counted per UTC day: per organization with a token, otherwise per address (per /64 for IPv6). Refused requests and the health route are not counted.

caller requests per day
No token 1,024
Community 2,048
Supporter 4,096
Superfan 8,192
Zero-Day Basic 20,000
POC 20,000
Zero-Day Enhanced 100,000
Zero-Day Critical 1,000,000

Over quota, requests are a 429 with code quota_exceeded and a Retry-After giving the seconds until UTC midnight. A request is counted just after it is answered, so the first few past the limit may still be served. Get a larger quota at https://console.atomdrift.com/. For more than Zero-Day Critical, write to support@isotope13.io.

Keys

Name an artifact by purl, url, or sha256, and use only one kind per request. Each names something different:

key names format
purl A release. A package URL; see below.
url Whatever a server sends today. An absolute http or https URL without credentials, percent-encoded. Beamline fetches it verbatim.
sha256 Exact bytes. 64 hexadecimal characters.

Mixing kinds is refused with 409 multiple_locators. If you hold both a digest and a PURL, ask by digest for those bytes or by PURL for the release.

Once an artifact is analyzed, its URL, its PURL when known, and its SHA-256 all find the answer.

PURL spelling

  • The pkg: prefix is optional, and the type is case-insensitive: npm/left-pad@1.3.0 and PKG:NPM/left-pad@1.3.0 are the same package.
  • Namespace, name, and version keep their case.
  • @ and + may be sent raw or percent-encoded: npm/@types/node@22.0.0 equals npm/%40types/node@22.0.0, and @v4.4.0+incompatible equals @v4.4.0%2Bincompatible.

Responses carry the canonical spelling, such as pkg:npm/%40types/node@22.0.0. Match a reply to its request by position or by parsed coordinate, not by string. To prove that two spellings are one package, compare sha256.

GET /v1/lookup

$ curl 'https://api.atomdrift.org/v1/lookup?purl=npm/left-pad@1.3.0'
{
  "status": "analyzed",
  "purl": "pkg:npm/left-pad@1.3.0",
  "sha256": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
  "severity": "benign",
  "fires_at": -1,
  "findings": [],
  "engine_version": "2.8.0",
  "analyzed_at": "2026-08-01T00:00:00Z",
  "schema": 3
}

Repeat purl or sha256 to ask about several artifacts, up to 50 per request; more is a 413. One parameter answers with one object. A repeated parameter answers with a list, in the order asked.

For an exact URL, use one url parameter. The response echoes url as sent. It may include a resolved purl, and includes sha256 when the artifact was fetched.

HEAD takes the same parameters and returns the same status and headers with no body. It counts against your quota like a GET.

Releases with several payloads

A versioned PURL can name several payloads, such as a wheel and a source distribution. The answer describes the worst one:

  1. The analyzed payload with the lowest fires_at above -1.
  2. If none fires, a clean (-1) payload before one with no level.
  3. On equal levels, the most recent analysis.

The returned sha256 and findings belong to that payload. A versionless lookup returns the newest analysis. For the verdict on specific bytes, ask by sha256.

POST /v1/analyze

Analyzes one artifact per request: named by purl, url, or sha256, or sent as the request body.

Reading the response

The reply is newline-delimited JSON: progress frames while the analysis runs, then the assessment. Read lines until one carries status. That line is the answer.

$ curl -sN -X POST \
    'https://api.atomdrift.org/v1/analyze?purl=pypi/tensorflow@2.15.0'
{"state":"analyzing","elapsed_ms":1002,"phase":"fetch","phase_state":"started",…}
{"state":"analyzing","elapsed_ms":6004,"phase":"unpack","phase_state":"started",…}
{"status":"analyzed","purl":"pkg:pypi/tensorflow@2.15.0","fires_at":-1,…}
  • A stream that ends without a status line was cut short, not answered. Retry it. The analysis finishes regardless, so the retry usually answers in milliseconds, and a retry during the run rejoins it rather than starting a second one.
  • An answer that is already known, or an analysis that finishes quickly, is a single line with no progress frames.
  • The heaviest packages take up to 30 minutes. The connection stays open throughout, so set your client timeout accordingly.

Progress frames keep the connection alive and show that a long analysis is not hung. You may ignore them. If you display them:

  • phase names the current step and phase_state is started, running, or completed. Treat phase as a display string.
  • elapsed_ms and total_elapsed_ms never go backwards.
  • A frame with "state":"resumed" means the analysis moved to another worker. Phases start over. It carries no status, so keep reading.

Uploading an artifact

To analyze unpublished bytes (a build output, a file from disk, a mirror download), send them as the request body:

$ curl -sN -X POST --data-binary @suspect.tgz \
    -H 'Content-Type: application/octet-stream' \
    'https://api.atomdrift.org/v1/analyze'
  • Uploads are capped at 100 MiB. Name anything larger by purl.
  • An upload over 16 MiB must declare its Content-Length, as curl --data-binary @file does; one sent chunked without a length is refused. If such an upload is answered unavailable, send it again.
  • ?purl= may accompany the bytes. It records where they came from and is echoed in each finding's pkg; the verdict is still about the bytes.
  • ?url= may accompany the bytes (http, https, ftp, scp, or sftp without credentials). It records where the bytes were observed in provenance; the verdict is still keyed and cached by the bytes' digest alone.
  • Two callers uploading the same bytes share one analysis.

Analyzing a URL

POST /v1/analyze?url=https%3A%2F%2F… fetches that exact URL and reports the SHA-256 of what it received. A URL can serve different bytes tomorrow, so compare the response's sha256 with the digest of the bytes you deliver.

Re-analyzing by digest

POST /v1/analyze?sha256={64hex}&refresh=1 re-analyzes bytes Beamline already holds. It skips the cache. If the existing verdict was produced under the current detection rules it is returned; otherwise the bytes are analyzed again and the new answer replaces the cached one.

refresh=1 is required with sha256, and only that exact spelling counts.

Following references

The requested artifact is always analyzed. follow selects which references found inside it are also fetched, analyzed, and folded into its verdict:

value follows
none Nothing beyond the requested artifact.
dependencies Dependencies declared in manifests and lockfiles.
references Packages and URLs named by install or download commands.
ci-actions Third-party CI actions; implies dependencies.
all Every category above.

Values may be comma-separated or repeated: follow=dependencies,references or follow=dependencies&follow=references. Limits on depth, size, and fan-out still apply.

Without follow, the default depends on how you named the artifact:

named by default why
purl, sha256 references Your dependency graph already names each package. It cannot show an install or download command that fetches something no manifest declares.
url none You already hold every URL.
uploaded bytes all Bytes come with no dependency graph and no lockfile, so nothing else reveals what they reference. A PURL sent alongside does not change this.

/v1/lookup takes follow too, with the same defaults.

A wider answer can serve a narrower question. If you ask follow=none and an all verdict is already known, you get the all verdict: a hostile dependency makes the answer hostile, and findings[].pkg names the component. The X-Beamline-Follow response header names the policy that answered when it is not the one you asked for. A narrower answer is never served for a wider question.

follow therefore limits what a new analysis does. It does not hide what an earlier, wider analysis found.

POST /v1/flush

Forgets every cached answer for one artifact, named by exactly one of ?purl=, ?url=, or ?sha256=. Requires a token.

$ curl -X POST -H "Authorization: Bearer $TOKEN" \
    'https://api.atomdrift.org/v1/flush?purl=pypi/ddtrace@3.18.1'
{"status":"flushed",
 "caches":{"edge":{"dropped":4},
           "kv":{"dropped":4},
           "zone":{"purge":"ok","purged":42}},
 "locators":[{"locator":"purl=pkg:pypi/ddtrace@3.18.1","dropped":2},
             {"locator":"sha256=46b28db6…","dropped":1},
             {"locator":"url=https://files.pythonhosted.org/…","dropped":1}],
 "keys_examined":42,"keys_dropped":4}
  • Flushing by one name clears the artifact under all its names and every follow policy. locators lists the names reached.
  • Nothing is re-analyzed. Afterwards /v1/lookup reports unanalyzed and /v1/analyze runs a new analysis.
  • keys_dropped counts the cached answers removed. Flushing something never cached is a 200 with keys_dropped: 0.
  • A 502 with purge_failed means some locations may still hold the old answer. Retry.
  • An old answer can still be served for up to a minute after a flush. Flush again a minute later when that matters.

Status and severity

A response reports facts about the artifact and about Beamline separately. It does not make the install decision for you.

status means severity
analyzed Beamline has an assessment. Derived from fires_at and your budget.
unanalyzed Nobody has analyzed this. unknown
unavailable Beamline could not answer. unknown

unanalyzed and unavailable are distinct so that your policy can treat them differently: you might install unanalyzed packages but refuse everything during an outage, or the reverse.

A partial answer is never an HTTP error. Four of five packages assessed is a 200 with four assessments and one unavailable.

An unavailable row says nothing about the artifact. Its cause says what to do:

cause means what to do
saturated Every worker was busy. Retry with backoff. Capacity frees shortly.
mixed Some workers were busy; others could not be reached. Retry with backoff.
unreachable No worker could be reached. Treat as an outage. Retrying adds load to a service that is already down.
no_workers The deployment has no workers configured. A configuration error. It will not fix itself.

The response object

Fields with no value are omitted, never null. Check optional fields for presence.

field type
status string analyzed, unanalyzed, or unavailable.
purl string The package, in its canonical spelling.
url string The exact URL, as sent.
sha256 string Digest of the exact bytes analyzed.
severity string benign, suspicious, hostile, dual-use, or unknown.
fires_at int How strongly the artifact grades hostile; lower is worse. See below.
reason string One sentence from the analysis.
label string A person's ruling on these exact bytes: good, bad, or dual-use.
cause string Why Beamline could not answer. Only on unavailable.
findings array At most three, worst first. Empty unless one fired.
engine_version string Scanner build that produced the verdict.
traits_version string Revision of the detection rules the verdict was reached under. When omitted, the rules cannot be identified.
traits_at string RFC 3339. When those rules were written. Later means newer rules.
analyzed_at string RFC 3339. When the analysis ran.
schema int Version of this shape; see schema and min_schema.

fires_at, false_positive_budget, and severity

fires_at and false_positive_budget share one scale: false positives per 100 million benign files.

  • fires_at is measured: the tightest budget at which this artifact grades hostile. Lower is worse. -1 means it never fires. It is omitted when no level applies.
  • false_positive_budget is chosen: how many false positives you will tolerate. Pass it to either route. The default is 25; the recommended range is 1 to 250. Values through 3000 are accepted.

Beamline derives severity from the two:

fires_at severity
-1 benign
At or below the budget hostile
Above the budget, up to 100 times it (at least 500, at most 25000) suspicious
Higher benign

At the default budget of 25, hostile is 0 to 25 and suspicious runs through 2500. You can also apply your own policy to fires_at directly.

label

A person's review outranks the measurement:

label means effect
good Cleared. fires_at is -1, so severity is benign.
bad Confirmed malicious. fires_at is 0, so severity is hostile.
dual-use Legitimate, but capable of misuse. fires_at stays as measured; severity is dual-use at every budget. Whether to accept it is your policy.

reason and findings still report what the analysis found, so you can tell a ruling that confirms the analysis from one that overturns it.

findings

field type
id string Stable trait id, e.g. objectives/execution/shell/bash.
crit int 3 notable, 4 suspicious, 5 hostile.
file string Path inside the artifact.
pkg string The component the finding is about.
desc string One line.
off int Byte offset within file.
line int 1-based source line. Text matches only.
url string On a reference: the URL it points at, when that is not a package.
sha256 string On a reference: the bytes it resolved to.
fires_at int On a reference: the level of those bytes.
feeds int How many independent threat feeds call it hostile. 0 when they do but are not counted.

Only id and crit are always present. Some verdicts carry no further detail.

A finding is reported on the file it was found in, not repeated on the archive that contains it.

Verdicts from threat intelligence

Some artifacts have never been analyzed but are known to outside threat intelligence. For those, Beamline answers with what the feeds say instead of unanalyzed:

{
  "status": "analyzed",
  "purl": "pkg:npm/left-pad@1.3.0",
  "severity": "hostile",
  "fires_at": 10,
  "findings": [{"id": "intel/feed/malicious", "crit": 5, "feeds": 2}],
  "schema": 3
}

Branch on engine_version to tell the two apart: it is present exactly when an analysis produced the verdict.

Finding ids under intel/ say where a claim came from, not what the artifact does:

  • intel/feed/… is a threat-feed citation. feeds counts the feeds.
  • intel/corpus/… is an earlier Atomdrift conviction of the same artifact.
  • intel/reference/… is a hostile dependency, URL, or file the artifact points at or holds. desc names it ("Depends on hostile pkg:npm/evil@1.0.0"), and pkg or url, sha256, and fires_at identify it.

More independent agreement gives a lower fires_at. Feeds that mirror one advisory database count once.

The same evidence can tighten the verdict on an analyzed artifact. It never loosens one.

POST /v1/analyze never answers from a citation alone. It runs the analysis and returns the measured answer.

schema and min_schema

Every answer carries schema, the version of its shape: 3 today. An answer without one is 1. From 2 on, the version rises only when a field or a value is added, so code written against an earlier schema still reads a later one.

min_schema is the oldest shape you accept. Pass it to either route, and an older stored answer is not served; Beamline fetches a current one instead.

schema
1 The original shape.
2 fires_at is the level; label and findings say why. A review is label, never a sentence in reason; outside evidence is an intel/ finding. own_fires_at and feed are gone.
3 A finding says where the evidence is. A reference names what it points at (pkg or url, with sha256 and fires_at), and a citation counts its feeds. reason is only the analysis's own sentence.

Errors

{
  "error": {
    "code": "too_many_packages",
    "message": "51 packages exceeds the limit of 50 for a URL."
  }
}

code is stable; branch on it. message is for people and may be reworded.

code status
missing_package 400 No purl, url, or sha256.
multiple_locators 409 More than one of purl, url, and sha256.
invalid_purl 400 Not a package URL.
invalid_url 400 Not an absolute http or https URL (or ftp/scp/sftp with uploaded bytes), or one carrying credentials.
invalid_sha256 400 Not 64 hexadecimal characters.
invalid_follow_policy 400 Unknown, empty, or contradictory follow selection.
invalid_false_positive_budget 400 Not a whole number from 0 to 3000.
invalid_min_schema 400 Not a whole number.
too_many_packages 413 Over 50 in one request. Use several requests.
empty_artifact 400 The uploaded body had no bytes.
artifact_too_large 413 Over the 100 MiB upload cap, or over 16 MiB without a Content-Length.
invalid_body 400 The body could not be read.
refresh_required 400 A SHA-256 analyze request must include refresh=1.
missing_sha256 400 refresh=1 without sha256.
quota_exceeded 429 The daily quota is spent. Wait out Retry-After.
purge_failed 502 A flush did not reach every location. Retry.
status
200 An assessment, or a list of them. Includes unanalyzed and unavailable.
400 Your request. See code.
401 Bad or missing bearer token.
404 No such route.
405 Right route, wrong method. Allow names the one that works.
409 More than one kind of key.
413 Too many packages, or an upload over the cap.
429 quota_exceeded: your daily quota is spent. Wait out Retry-After.
502 purge_failed: retry the flush.

A package that could not be assessed is a 200 carrying unavailable, never a 503.

Headers

header
X-Request-Id Request. Send your own so a request can be found in Beamline's logs; quote it when you ask for support.
Atomdrift-Origin Request. Names your integration: [a-z0-9-], at most 32 characters. Optional. The default is the product token of your User-Agent, or website for a browser.
X-Beamline-Follow Response. The follow policy that answered, when it is wider than the one you asked for.
Cache-Control Response. How long you may reuse the answer; see Caching.
Content-Type Response. application/json; application/x-ndjson from /v1/analyze.

Caching

Cache-Control says how long you may reuse an answer:

answer reuse for
Verdict 3 days
Verdict under a url 30 minutes
unanalyzed 1 minute
unavailable never
  • Beamline may serve a stored verdict for up to 90 days. analyzed_at and engine_version say how current it is. When stored verdicts compete, the newest engine wins.
  • A URL's answer is only as good as the bytes it last served. Compare the response's sha256 with the digest of the bytes you deliver.
  • /v1/analyze answers from the same cache as /v1/lookup, so asking twice costs one analysis. Uploads and refresh=1 requests skip the cache.
  • On a deployment that requires tokens, responses are Cache-Control: private.