# Log ingest API

The endpoint a [log source](https://docs.watchtower15.com/logs/custom-sources/) posts to. It is deliberately undemanding: one header, a JSON array, done.

```plaintext
POST https://api.watchtower15.com/api/log-sources/ingest
Authorization: Bearer wt15ls_…
Content-Type: application/json
```

The source’s page in the dashboard shows this URL. Behind a firewall that allows outbound traffic by IP address, allow `3.11.48.155`, `18.171.1.44` and `18.135.154.177` on port 443: those addresses serve `api.watchtower15.com` only. See the **Restricted egress** tab under [Install](https://docs.watchtower15.com/server-agent/installation/#install) for the list and when it changes.

Official SDKs build, retry and batch these calls for you: see [SDKs](https://developer.watchtower15.com/sdks/).

Generating your own client? This API’s contract is an OpenAPI document, [`ingest.json`](https://developer.watchtower15.com/openapi/ingest.json), with every form, answer and limit on this page. It is written from the code, so it is the same as the page.

## Request

The body may be **any** of the following — the format is detected from the content, not from `Content-Type`:

| Form | Example |
| --- | --- |
| JSON array | `[{"message":"a"},{"message":"b"}]` |
| Envelope | `{"lines":[{"message":"a"}]}` |
| Single object | `{"message":"a"}` |
| NDJSON | one JSON object per line |
| gzip | any of the above, gzipped |

### Fields

| Field | Required | Notes |
| --- | --- | --- |
| `message` | **yes** | The log line. A line without one is skipped. |
| `logged_at` | no | RFC 3339 (`2026-10-06T14:03:22.481+01:00`) **or** a Unix epoch in seconds or milliseconds, as a number or a string. A time without a timezone is read as UTC, and fractions of a second are kept. A missing or unreadable time is the time the line was received. Timestamps more than 5 minutes in the future are clamped to now. |
| `log_level` | no | One of `debug`, `info`, `notice`, `warning`, `error`, `critical`, `alert`, `emergency`. Anything else is dropped rather than stored. |
| `stream_name` | no | The [stream](https://docs.watchtower15.com/logs/custom-sources/#sources-and-streams) this line belongs to. Defaults to the source’s slug. |
| `raw_line` | no | The original unparsed line, if you have one. |

`log_source` is accepted as an alias for `stream_name`, so an agent-shaped payload works unchanged.

> **Keep stream_name low-cardinality:** Stream names are part of how lines are indexed. Use a stable label — a file name, a service name, an AWS service slug. Do **not** put a request id, container id, or timestamp in it: a value that changes on every call degrades query performance for your whole organisation. Values outside `A-Z a-z 0-9 . _ / @ : + -` are ignored and replaced with the source’s slug.

## Response

```json
{ "status": "success", "data": { "accepted": true, "batch_id": "…", "lines": 2 } }
```

`accepted` means the batch is **durably stored**. Lines usually become searchable within a second, but the two are not the same guarantee.

## Limits and errors

| Code | Meaning |
| --- | --- |
| `200` | Accepted. `lines` reports how many were usable. |
| `400` | The body could not be parsed, or contained no readable lines. |
| `403` | The token is missing, unknown, revoked, or the source is paused or deleted. All of these return the same response deliberately. |
| `413` | Too many lines (max 1,000 per request), or the body is too large (5 MB on the wire, 20 MB decompressed). |
| `422` | The `Idempotency-Key` was already used, in the last 24 hours, for a **different** batch. `data.code` is `idempotency_key_reused` and `errors` names the header. See [Retries](https://developer.watchtower15.com/ingest/logs/#retries). |
| `429` | Rate limited. Retry with back-off. Also returned while your organisation’s [log ingestion limit](https://docs.watchtower15.com/platform/account-limits/#log-ingestion-stopped) is reached for the billing period: `data.code` is `log_volume_limit_reached`, `data.resumes_at` says when ingestion restarts, in epoch milliseconds, and `Retry-After` is at most an hour. Lines sent until then are discarded. Also returned when many requests from one address carry an invalid token: if `403`s came first, check the token. |
| `503` | We could not store the batch. Retry later. |

Rate limiting is keyed to the **token**, not your IP, so a fleet of workers behind one NAT address shares one generous budget rather than competing for a per-IP one.

## Retries

Send an **`Idempotency-Key`** header with each batch, and send the same value when you retry that batch. A request that worked at our end and timed out at yours is the common case, and retrying it is the right instinct.

```plaintext
Idempotency-Key: orders-lambda/run-8812/batch-17
```

-   **With a key**, a repeat of the same batch within **24 hours** is answered exactly as the first was, with the first batch’s `batch_id` and `lines`, and the lines are stored **once** and billed once. The repeat counts as a request for the rate limit, as any request does.
    
-   A key is **yours alone**: it is kept per log source, so two sources never see each other’s keys.
    
-   A **different** batch under a key used in the last 24 hours is refused with `422`, never dropped silently, so no lines are lost without a word:
    
    ```json
    { "status": "failure",
      "message": "This Idempotency-Key was used for a different batch in the last 24 hours.",
      "data": { "code": "idempotency_key_reused" },
      "errors": { "Idempotency-Key": ["This Idempotency-Key was used for a different batch in the last 24 hours."] } }
    ```
    
    Use a new key for a new batch. Whether a batch is the same is judged on its lines, not its bytes: the same lines gzipped differently are the same batch.
    
-   A batch that fails with a `413` or a `503` leaves its key unused, so retrying it with the same key stores it.
    
-   **Without a key** (or with a header of only spaces, which counts as no key), a retried batch is stored and billed twice. Only retry on a response that is not a `2xx`.
    

After 24 hours a key is forgotten and may be used again for any batch.

## AWS Lambda

A Lambda function can forward log lines to this endpoint, or mirror a CloudWatch Logs group through a subscription filter: see the [AWS Lambda recipe](https://developer.watchtower15.com/sdks/recipes/aws-lambda/).

## Related

-   [Log sources](https://docs.watchtower15.com/logs/custom-sources/) — creating a source and managing its token.
-   [Search & explore](https://docs.watchtower15.com/logs/search/) — finding the lines once they are in.
-   [SDKs](https://developer.watchtower15.com/sdks/) — the official SDKs, which build, retry and batch these calls for you.

Source: https://developer.watchtower15.com/ingest/logs/
