# Check an upload before you accept it

Scan checks a file for malware before your site accepts it. You post the file from your server; Scan streams it to the scanner and answers.

## 1. Get an account

An account is made in the Praecise Cloud console, or by a Praecise product holding the admin key. You are given an account key (`scn_…`) once. Keep it on your server; only its hash is kept here.

## 2. Post the file

The file is the raw request body, not a form:

```js
const res = await fetch("https://scan.praecise.com/scan", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.SCAN_KEY}`, "Content-Type": "application/octet-stream" },
  body: fileStream, duplex: "half",
});
const answer = await res.json();
// { clean: true, sha256, size }   or   { clean: false, name: "Eicar-Signature", sha256, size }
```

## 3. Decide

- `clean: true`: accept the file.
- `clean: false`: refuse it; `name` is the signature that matched.
- **503**: the scanner could not be reached or gave no verdict. The file is neither clean nor infected. You must decide: hold the upload and retry, or refuse it. Never treat a 503 as clean.
- **413**: over 25 MB. **429**: over 60 scans a minute.

`GET /usage` with the same key gives the last seven days: files, bytes, found.

## What Scan does not do

- A clean answer means the scanner knew no signature that matched. It is not proof that a file is safe: new or targeted malware can pass.
- Files are not unpacked beyond what the scanner itself does; an encrypted archive cannot be looked into.
- Files up to 25 MB are accepted; a larger one is refused with 413 and not scanned.
- 60 scans per account per minute; beyond that the answer is 429 with `Retry-After`.
- The scanner's signatures are kept up to date by whoever runs the scanner, not by Scan. Scan does not report their age.
- One instance, one scanner; when the scanner cannot be reached the answer is 503. Scan never reports a file clean without a verdict from the scanner.
- A file is streamed to the scanner and never kept. Scan keeps only counts per account and UTC day: files, bytes, and files found infected.
- Metered: two meters are reported to the Praecise account service, per UTC day, for an account linked to a Praecise account: `files` (files scanned) and `bytes` (their total size). An account that is not linked is counted here and not reported.
