# Log sources

The sources that send logs: their tokens, their settings and what they have sent.

Its operations need the scopes `log_sources.edit`, `log_sources.view` or `log_sources.delete`.

**Endpoints**

- `POST/v1/log-sources`
- `PUT/v1/log-sources/{log_source_uuid}`
- `GET/v1/log-sources/{log_source_uuid}`
- `GET/v1/log-sources`
- `DELETE/v1/log-sources/{log_source_uuid}`
- `POST/v1/log-sources/{log_source_uuid}/revoke-token`
- `POST/v1/log-sources/{log_source_uuid}/rotate-token`

## The Log source object

### Attributes

- `uuid` (string): The source’s uuid.
- `name` (string): The source’s name.
- `slug` (string): The source’s slug, its identifier within the organisation.
- `description` (string or null): The source’s description; null for none.
- `source_type` (string): The source’s type: `custom_source`; an open set.
- `health_status` (string): One of `unknown`, `healthy`, `warning`, `critical`.
- `last_received_at` (integer or null): Epoch milliseconds. When a line last arrived; null if none ever did. An instant: epoch milliseconds, UTC.
- `silence_warning_minutes` (integer or null): Minutes of silence before a warning; null for the platform default.
- `silence_critical_minutes` (integer or null): Minutes of silence before a critical alarm; null for the platform default.
- `active` (boolean): Whether the source is switched on.
- `has_ingest_token` (boolean): Whether a usable ingest token exists: a source created and not yet given one, or whose token was revoked, accepts no lines.
- `ingest_token_last_four` (string or null): The last four characters of the token; never the token.
- `ingest_token_created_at` (integer or null): Epoch milliseconds. When the ingest token was minted; null if none was. An instant: epoch milliseconds, UTC.
- `ingest_token_revoked_at` (integer or null): Epoch milliseconds. When the ingest token was revoked; null otherwise. An instant: epoch milliseconds, UTC.
- `created_at` (integer or null): Epoch milliseconds. When the source was created. An instant: epoch milliseconds, UTC.
- `tags` (array of objects): The source’s own tags.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.

**The Log source object**

```json
{
  "uuid": "75666699-b77d-4631-b576-041e8102a55b",
  "name": "example",
  "slug": "example",
  "description": "example",
  "source_type": "example",
  "health_status": "example",
  "last_received_at": 1794214800000,
  "silence_warning_minutes": 1,
  "silence_critical_minutes": 1,
  "active": true,
  "has_ingest_token": true,
  "ingest_token_last_four": "example",
  "ingest_token_created_at": 1794214800000,
  "ingest_token_revoked_at": 1794214800000,
  "created_at": 1794214800000,
  "tags": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    }
  ]
}
```

## Create a log source

POST/v1/log-sources

Creates a log source with no ingest token; mint one with the rotate-token operation. The slug defaults to a slug of the name and cannot be changed afterwards. The call is refused when the plan or the organisation’s log source limit does not allow it.

Needs the scope `log_sources.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Body parameters

- `name` (string, required): The source’s display name.
- `slug` (string or null): The source’s slug, a lowercase identifier of letters, digits, `.`, `_` and `-` up to 100 characters; defaults to a slug of the name and cannot be changed afterwards.
- `description` (string or null): A description of the source, up to 2000 characters; null for none.
- `source_type` (string or null): The source’s type: `custom_source`, the one type that can be created. Values:`custom_source`(an open set: new values may be added)
- `silence_warning_minutes` (integer or null): Minutes without a log line before a warning, from 1 to 10080 (one week); null for the platform default.
- `silence_critical_minutes` (integer or null): Minutes without a log line before a critical alarm, from 1 to 10080 (one week); null for the platform default.
- `active` (boolean or null): Whether the source is switched on.
- `tag_uuids` (array of strings or null): The uuids of the tags to put on the source.

### Returns

`201 Created`:

The created log source.

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.

**POST /v1/log-sources**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/log-sources \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "name": "example"
  }'
```

PHP:

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

$logSource = $wt15->logSources->create(['name' => 'example']);
```

Node.js:

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

const result = await wt15.logSources.create({ name: 'example' });
```

Python:

```python
client = Client.from_environment()

result = client.log_sources.create(name='example')
```

**Response (201 Created)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "slug": "example",
    "description": "example",
    "source_type": "example",
    "health_status": "example",
    "last_received_at": 1794214800000,
    "silence_warning_minutes": 1,
    "silence_critical_minutes": 1,
    "active": true,
    "has_ingest_token": true,
    "ingest_token_last_four": "example",
    "ingest_token_created_at": 1794214800000,
    "ingest_token_revoked_at": 1794214800000,
    "created_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "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 (402 Payment Required)**

The organisation's payment gate blocks the action: `payment_required` (no payment method) or `invoice_overdue`. Nothing is billed and nothing is started.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/payment_required/",
  "title": "Payment required",
  "status": 402,
  "code": "payment_required",
  "detail": "A payment method must be set before adding resources for monitoring.",
  "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 log_sources.edit 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; `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"
}
```

## Update a log source

PUT/v1/log-sources/{log\_source\_uuid}

Changes the fields sent: name, description, silence thresholds, whether it is switched on and tags. Switching a source on is refused when the plan does not allow it.

Needs the scope `log_sources.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `log_source_uuid` (string (uuid), required): The uuid of the log source in the path.

### Body parameters

- `name` (string or null): The source’s display name.
- `description` (string or null): A description of the source, up to 2000 characters; null for none.
- `silence_warning_minutes` (integer or null): Minutes without a log line before a warning, from 1 to 10080 (one week); null for the platform default.
- `silence_critical_minutes` (integer or null): Minutes without a log line before a critical alarm, from 1 to 10080 (one week); null for the platform default.
- `active` (boolean or null): Whether the source is switched on.
- `tag_uuids` (array of strings or null): The uuids of the tags to put on the source.

### Returns

`200 OK`:

The log source after the update.

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.

**PUT /v1/log-sources/{log_source_uuid}**

curl:

```bash
curl -X PUT https://rest.watchtower15.com/v1/log-sources/3831fa3c-a7ba-4635-8cda-718b3d974560 \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$logSource = $wt15->logSources->update('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Node.js:

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

const result = await wt15.logSources.update('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Python:

```python
client = Client.from_environment()

result = client.log_sources.update('3831fa3c-a7ba-4635-8cda-718b3d974560')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "slug": "example",
    "description": "example",
    "source_type": "example",
    "health_status": "example",
    "last_received_at": 1794214800000,
    "silence_warning_minutes": 1,
    "silence_critical_minutes": 1,
    "active": true,
    "has_ingest_token": true,
    "ingest_token_last_four": "example",
    "ingest_token_created_at": 1794214800000,
    "ingest_token_revoked_at": 1794214800000,
    "created_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "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 (402 Payment Required)**

The organisation's payment gate blocks the action: `payment_required` (no payment method) or `invoice_overdue`. Nothing is billed and nothing is started.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/payment_required/",
  "title": "Payment required",
  "status": 402,
  "code": "payment_required",
  "detail": "A payment method must be set before adding resources for monitoring.",
  "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 log_sources.edit 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; `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"
}
```

## Get a log source

GET/v1/log-sources/{log\_source\_uuid}

Returns one log source with its tags and silence thresholds. The token is never returned. Reading a source also adds any default alarm the platform has introduced since it was created, as opening it in the console does.

Needs the scope `log_sources.view`.

### Path parameters

- `log_source_uuid` (string (uuid), required): The uuid of the log source in the path.

### Returns

`200 OK`:

The log source.

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/log-sources/{log_source_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/log-sources/3831fa3c-a7ba-4635-8cda-718b3d974560 \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$logSource = $wt15->logSources->view('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Node.js:

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

const result = await wt15.logSources.view('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Python:

```python
client = Client.from_environment()

result = client.log_sources.view('3831fa3c-a7ba-4635-8cda-718b3d974560')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "slug": "example",
    "description": "example",
    "source_type": "example",
    "health_status": "example",
    "last_received_at": 1794214800000,
    "silence_warning_minutes": 1,
    "silence_critical_minutes": 1,
    "active": true,
    "has_ingest_token": true,
    "ingest_token_last_four": "example",
    "ingest_token_created_at": 1794214800000,
    "ingest_token_revoked_at": 1794214800000,
    "created_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "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 log_sources.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"
}
```

## List log sources

GET/v1/log-sources

Returns the organisation’s log sources. A source’s token is never returned, only whether one is set and its last four characters. Pages by `page` and `per_page` (`limit` is the same as `per_page`); every page carries `current_page`, `per_page`, `last_page` and `total`.

Needs the scope `log_sources.view`.

### Query parameters

- `limit` (integer or null): The same as `per_page`, kept for existing clients.
- `include_total` (string or null): Ignored: `total` is always present. Values:`true``false``1``0`(an open set: new values may be added)
- `per_page` (integer or null): The page size, from 1 to 100.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the organisation’s log sources.

Each item of the page:

- `uuid` (string): The source’s uuid.
- `name` (string): The source’s name.
- `slug` (string): The source’s slug, its identifier within the organisation.
- `description` (string or null): The source’s description; null for none.
- `source_type` (string): The source’s type: `custom_source`; an open set.
- `health_status` (string): One of `unknown`, `healthy`, `warning`, `critical`.
- `last_received_at` (integer or null): Epoch milliseconds. When a line last arrived; null if none ever did. An instant: epoch milliseconds, UTC.
- `active` (boolean): Whether the source is switched on.
- `has_ingest_token` (boolean): Whether a usable ingest token exists: a source created and not yet given one, or whose token was revoked, accepts no lines.
- `ingest_token_last_four` (string or null): The last four characters of the token; never the token.
- `tags` (array of objects): The source’s own tags.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.

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/log-sources**

curl:

```bash
curl https://rest.watchtower15.com/v1/log-sources \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

foreach ($wt15->logSources->list()->autoPaging() as $logSource) { echo $logSource->uuid, "\n"; }
```

Node.js:

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

for await (const item of wt15.logSources.list()) {
  console.log(item.uuid);
}
```

Python:

```python
client = Client.from_environment()

for item in client.log_sources.list():
    print(item.uuid)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "slug": "example",
      "description": "example",
      "source_type": "example",
      "health_status": "example",
      "last_received_at": 1794214800000,
      "active": true,
      "has_ingest_token": true,
      "ingest_token_last_four": "example",
      "tags": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    }
  ],
  "current_page": 1,
  "per_page": 1,
  "last_page": 1,
  "total": 1
}
```

**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 log_sources.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"
}
```

## Delete a log source

DELETE/v1/log-sources/{log\_source\_uuid}

Deletes the log source. The answer has no body.

Needs the scope `log_sources.delete`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `log_source_uuid` (string (uuid), required): The uuid of the log source in the path.

### Returns

`204 No Content`:

The log source was deleted; there is no body.

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.

**DELETE /v1/log-sources/{log_source_uuid}**

curl:

```bash
curl -X DELETE https://rest.watchtower15.com/v1/log-sources/3831fa3c-a7ba-4635-8cda-718b3d974560 \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$wt15->logSources->delete('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Node.js:

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

await wt15.logSources.delete('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Python:

```python
client = Client.from_environment()

client.log_sources.delete('3831fa3c-a7ba-4635-8cda-718b3d974560')
```

**Response (204 No Content)**

```http
HTTP/1.1 204 No Content
```

**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 log_sources.delete 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; `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"
}
```

## Revoke a log source's token

POST/v1/log-sources/{log\_source\_uuid}/revoke-token

Revokes the source’s ingest token, so the source accepts no lines until a new token is minted.

Needs the scope `log_sources.delete`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `log_source_uuid` (string (uuid), required): The uuid of the log source in the path.

### Returns

`200 OK`:

The log source after its token was revoked.

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.

**POST /v1/log-sources/{log_source_uuid}/revoke-token**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/log-sources/3831fa3c-a7ba-4635-8cda-718b3d974560/revoke-token \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->logSources->revokeToken('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Node.js:

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

const result = await wt15.logSources.revokeToken('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Python:

```python
client = Client.from_environment()

result = client.log_sources.revoke_token('3831fa3c-a7ba-4635-8cda-718b3d974560')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "slug": "example",
    "description": "example",
    "source_type": "example",
    "health_status": "example",
    "last_received_at": 1794214800000,
    "silence_warning_minutes": 1,
    "silence_critical_minutes": 1,
    "active": true,
    "has_ingest_token": true,
    "ingest_token_last_four": "example",
    "ingest_token_created_at": 1794214800000,
    "ingest_token_revoked_at": 1794214800000,
    "created_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "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 log_sources.delete 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; `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"
}
```

## Rotate a log source's token

POST/v1/log-sources/{log\_source\_uuid}/rotate-token

Mints a new ingest token for the source, replacing any earlier one. The token is returned once, in this answer; a replay under the same `Idempotency-Key` answers it as null, so a caller that lost it rotates again under a new key.

Needs the scope `log_sources.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `log_source_uuid` (string (uuid), required): The uuid of the log source in the path.

### Returns

`200 OK`:

The new ingest token, shown once.

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.

**POST /v1/log-sources/{log_source_uuid}/rotate-token**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/log-sources/3831fa3c-a7ba-4635-8cda-718b3d974560/rotate-token \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->logSources->rotateToken('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Node.js:

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

const result = await wt15.logSources.rotateToken('3831fa3c-a7ba-4635-8cda-718b3d974560');
```

Python:

```python
client = Client.from_environment()

result = client.log_sources.rotate_token('3831fa3c-a7ba-4635-8cda-718b3d974560')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "ingest_token": "example",
    "ingest_token_last_four": "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 log_sources.edit 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; `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/log-sources/
