# Scans

Scans: the checks run on domains and servers, their results and their changes over time.

Its operations need the scope `domains.view`.

**Endpoints**

- `GET/v1/scans/{scan_uuid}`

## The Scan object

### Attributes

- `uuid` (string): The scan’s uuid.
- `scan_type` (string): One of `dns`, `expiry`, `information`, `ssl`.
- `domain_uuid` (string): The uuid of the domain that was scanned.
- `status` (string): `queued`, `running`, `completed`, `failed` or `timeout`: an open set.
- `outcome` (string or null): What a finished scan found, for example `data_found` or `no_data`; null until it ends. An open set.
- `queued_at` (integer or null): Epoch milliseconds. When the scan was queued. An instant: epoch milliseconds, UTC.
- `started_at` (integer or null): Epoch milliseconds. When the scan started running; null until it has. An instant: epoch milliseconds, UTC.
- `completed_at` (integer or null): Epoch milliseconds. When the scan ended; null until it has. An instant: epoch milliseconds, UTC.
- `execution_time_ms` (integer or null): How long the scan took, in milliseconds; null until it has ended.
- `error_message` (string or null): Why a scan failed, as the console shows it; null otherwise.

**The Scan object**

```json
{
  "uuid": "75666699-b77d-4631-b576-041e8102a55b",
  "scan_type": "example",
  "domain_uuid": "67b3f541-4111-4930-921e-7cdc105c9fdb",
  "status": "example",
  "outcome": "example",
  "queued_at": 1794214800000,
  "started_at": 1794214800000,
  "completed_at": 1794214800000,
  "execution_time_ms": 1,
  "error_message": "example"
}
```

## Get a domain scan

GET/v1/scans/{scan\_uuid}

Returns the lifecycle of one domain scan of any kind: its status, outcome, timings and error. It carries no findings; read them from the domain’s scans.

Needs the scope `domains.view`.

### Path parameters

- `scan_uuid` (string (uuid), required): The uuid of the domain scan.

### Returns

`200 OK`:

The scan’s lifecycle.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/scans/{scan_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/scans/7edfbf48-4812-43c4-b362-63f374779348 \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$scan = $wt15->scans->view('7edfbf48-4812-43c4-b362-63f374779348');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.scans.view('7edfbf48-4812-43c4-b362-63f374779348');
```

Python:

```python
client = Client.from_environment()

result = client.scans.view('7edfbf48-4812-43c4-b362-63f374779348')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "scan_type": "example",
    "domain_uuid": "67b3f541-4111-4930-921e-7cdc105c9fdb",
    "status": "example",
    "outcome": "example",
    "queued_at": 1794214800000,
    "started_at": 1794214800000,
    "completed_at": 1794214800000,
    "execution_time_ms": 1,
    "error_message": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the domains.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

Source: https://developer.watchtower15.com/api/reference/scans/
