# Sending Logs: curl

Any language or platform can send logs to Tailcove with a plain HTTP POST,
no client library required. This page covers the curl-based recipes;
see [HTTP API Reference](https://tailcove.dev/docs/sending-logs/http-api) for the full payload
formats, limits, and response codes.

Every request needs your source's ingest token as a bearer token:

```bash@macOS_/_Linux
curl -X POST https://ingest.tailcove.dev/api/v1/logs \
  -H "Authorization: Bearer YOUR_INGEST_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message":"Hello from curl","level":"info"}'
```

```powershell@Windows_(PowerShell)
Invoke-RestMethod -Method Post -Uri https://ingest.tailcove.dev/api/v1/logs `
  -Headers @{ Authorization = "Bearer YOUR_INGEST_TOKEN" } `
  -ContentType "application/json" `
  -Body '{"message":"Hello from PowerShell","level":"info"}'
```

On Windows, use PowerShell's own `Invoke-RestMethod`. In Windows PowerShell 5.1, `curl` is a shortcut for
`Invoke-WebRequest`, which takes different flags, so the curl lines on this page fail there. Windows 10 and 11 do ship
the real curl as `curl.exe`, but the examples below are written for bash: put each one on a single line (drop the `\`
breaks) and escape the JSON's inner quotes as `\"` before running it in `cmd`. Or run them as they are in WSL or Git Bash.

A successful call returns `202 Accepted` right away, before the line is
durably stored; see [HTTP API Reference](https://tailcove.dev/docs/sending-logs/http-api#responses)
for what the response body looks like.

## Send a single line with fields

```bash
curl -X POST https://ingest.tailcove.dev/api/v1/logs \
  -H "Authorization: Bearer YOUR_INGEST_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Payment failed",
    "level": "error",
    "host": "checkout-worker-3",
    "context": {"order_id": 9182, "gateway": "stripe"}
  }'
```

## Send multiple lines in one request (JSON array)

Batching multiple lines into one request is cheaper than one request per
line, up to 1000 lines per request:

```bash
curl -X POST https://ingest.tailcove.dev/api/v1/logs \
  -H "Authorization: Bearer YOUR_INGEST_TOKEN" \
  -H "Content-Type: application/json" \
  -d '[
    {"message": "Request started", "level": "info"},
    {"message": "Cache miss", "level": "debug"},
    {"message": "Request completed", "level": "info"}
  ]'
```

## Send multiple lines as NDJSON

If your logs are already newline-delimited JSON (e.g. tailed from a file),
send them as-is: one JSON object per line, no wrapping array:

```bash
curl -X POST https://ingest.tailcove.dev/api/v1/logs \
  -H "Authorization: Bearer YOUR_INGEST_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary $'{"message":"line one","level":"info"}\n{"message":"line two","level":"warning"}'
```

## Ship a running log file

A minimal tail-and-post loop for shipping an existing log file:

```bash
tail -F /var/log/myapp/app.log | while read -r line; do
  curl -s -X POST https://ingest.tailcove.dev/api/v1/logs \
    -H "Authorization: Bearer YOUR_INGEST_TOKEN" \
    -H "Content-Type: application/json" \
    -d "$(jq -n --arg msg "$line" '{message: $msg, level: "info"}')" \
    > /dev/null
done
```

For anything beyond quick scripting, batch lines client-side before
sending; see the [HTTP API Reference](https://tailcove.dev/docs/sending-logs/http-api) for
the exact limits per request.
