# Sources

```
GET /api/v1/sources
```

Lists the sources reachable by your token: always your token's own team,
never any other team's, and only the ones its owner can open (a member
restricted to certain client groups sees just those groups' sources).
Requires `sources:read`, `logs:read` or `issues:read`.

## Example

```bash
curl https://tailcove.dev/api/v1/sources \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

```json
{
    "data": [
        {
            "id": "src_01jbx5q8k7m3n2p4r6s8t0v1w3",
            "name": "checkout-api",
            "platform": "laravel",
            "environment": "production",
            "retentionDays": 14,
            "clientGroupId": null,
            "lastIngestedAt": "2026-07-03T18:42:11.000000Z",
            "temporary": false,
            "expiresAt": null,
            "createdAt": "2026-06-01T09:03:44.000000Z"
        }
    ]
}
```

Ids are opaque strings (a prefix for what the thing is, then a ULID): never parse or compare them as numbers. Use a source's `id` with the [Logs](https://tailcove.dev/docs/api/logs) and
[Issues](https://tailcove.dev/docs/api/issues) endpoints.

## Writing sources

```
GET    /api/v1/sources/{id}
POST   /api/v1/sources
PUT    /api/v1/sources/{id}
DELETE /api/v1/sources/{id}
POST   /api/v1/sources/{id}/rotate-token
```

Needs `sources:write` (reads need `sources:read`). A source takes `name`, and optionally `platform`, `environment` (`production`, `staging` or `development`; the dashboard's environment switcher narrows to it), `retention_days` (your plan's retention when left out; longer, up to the plan's add-on ceiling, is [billed per GB](https://tailcove.dev/docs/billing-quotas#add-ons)) and `client_group_id`. Creating is

A source keeps the `platform` it was created with: an update that sends a different one is refused with `422`. A source that has none yet can be given one, once.
limited by your plan's source limit (`403`). **The ingest token is in the answer to the create and to `rotate-token` only**; the old token stops working at once on rotation.
Deleting a source is for owners and admins, and starts the purge of its data. See [Writing](https://tailcove.dev/docs/api/writing).

## A temporary source for `tailcove dev`

```
POST /api/v1/sources/dev
```

What [`tailcove dev`](https://tailcove.dev/docs/cli#local-development) calls before it starts your command. Needs `sources:write` (a Viewer's token can't have it). The body names the machine and the project:

| Field         | Required | Notes                                                                 |
| ------------- | -------- | --------------------------------------------------------------------- |
| `device_name` | yes      | The machine, usually its hostname. Up to 64 characters after cleaning |
| `project`     | yes      | The project, usually the folder's name. Up to 64 characters           |

Control and invisible characters are dropped and runs of spaces collapsed before the length is checked. The pair (case doesn't matter) names one source per person and team: the first call makes it and answers `201`, a later one answers `200` with the same `id`.

```bash
curl -X POST https://tailcove.dev/api/v1/sources/dev \
  -H "Authorization: Bearer $TAILCOVE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"device_name": "ranas-mac", "project": "my-app"}'
```

```json
{
    "data": {
        "id": "src_01jbx5q8k7m3n2p4r6s8t0v1w3",
        "name": "dev · ranas-mac · my-app",
        "ingest_token": "a1b2c3d4e5f6…",
        "ingest_url": "https://ingest.tailcove.dev/api/v1/logs",
        "tail_url": "https://tailcove.dev/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/tail?team=team_01jbx5q8k7m3n2p4r6s8t0v1w4",
        "expires_at": "2026-12-01T14:05:00.000000Z"
    }
}
```

Every call returns a new `ingest_token`, and the one before it stops working at once. Two runs of the same project at the same time share the source, so the first run's lines stop arriving when the second starts. Each call also moves `expires_at` to 24 hours from now; after that the source and its logs are deleted. It keeps logs for a day, belongs to no client group, and is seen only by you and the team's owners and admins (the [list](#example) above shows it to them with `"temporary": true` and its `expiresAt`). It isn't counted in your plan's source limit, so a team at its limit can still open one, but its logs count toward your monthly GB. You can have 3 at a time in a team: a fourth device or project is refused with `422` and an `error.details.project` message saying so. Alerts can't be added to it (`403`).

## Upload a source map

```
POST /api/v1/sources/{id}/sourcemaps
```

Needs `sourcemaps:write`. A CI step uploads the `.map` of each minified JavaScript file it deploys, so browser stack traces show the original code ([Code links and source maps](https://tailcove.dev/docs/code-links)). The body is a multipart form:

| Field     | Required | Notes                                                                                                                |
| --------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `url`     | yes      | The minified file's public URL, `https://app.example.com/assets/app-3f9a1c.js`, or its path, `/assets/app-3f9a1c.js` |
| `file`    | yes      | The `.map` file: source map version 3, at most 25 MB                                                                 |
| `release` | no       | Up to 200 characters. Hashed file names don't need one                                                               |

```bash
curl -X POST https://tailcove.dev/api/v1/sources/$TAILCOVE_SOURCE_ID/sourcemaps \
  -H "Authorization: Bearer $TAILCOVE_API_TOKEN" \
  -F url=https://app.example.com/assets/app-3f9a1c.js \
  -F file=@dist/assets/app-3f9a1c.js.map
```

The answer is `201` with the map itself (not wrapped in `data`):

```json
{
    "id": "smap_01jbx5q8k7m3n2p4r6s8t0v1w3",
    "url_path": "/assets/app-3f9a1c.js",
    "release": null,
    "size": 48211,
    "created_at": "2026-11-30T12:00:00+00:00"
}
```

A map for the same path and release replaces the one before it, so a retried upload is harmless; that's also why this endpoint takes no `Idempotency-Key`. A file over 25 MB is `413`, one that isn't a version 3 source map is `422` with `error.code` `not_a_source_map` and the reason, and a source that already holds its plan's number of maps (50 on Free, 2,000 on Pro, 10,000 on Business) is `429` with `error.code` `limit_reached`. Uploads count toward the token's write limit of 30 a minute: a client sending many maps waits for `Retry-After` and carries on.

## Log level overrides

Turn on debug logging for one user, host, path or field value for a while, without a redeploy (see
[Debug Logging](https://tailcove.dev/docs/debug-logging)). Reading needs `sources:read`, starting and stopping `sources:write`.

| Method | Path | What it does |
| ------ | ---- | ------------ |
| `GET` | `/api/v1/sources/{id}/log-levels` | The source's overrides from the last day, newest first |
| `POST` | `/api/v1/sources/{id}/log-levels` | Starts one; answers `201` with it |
| `DELETE` | `/api/v1/sources/{id}/log-levels/{override id}` | Stops it now; answers `204` with no body |

The body of a `POST`:

| Field | Required | Values |
| ----- | -------- | ------ |
| `level` | yes | `debug`, `info`, `notice`, `warning` or `error`: the lowest level to send while it lasts |
| `type` | yes | `user`, `host`, `path`, `field` or `all` |
| `value` | unless `type` is `all` | the user id, host, path prefix or field value |
| `field` | when `type` is `field` | the context field, like `tenant_id` |
| `minutes` | yes | `5`, `15`, `30`, `60`, `120` or `240` |
| `reason` | no | up to 200 characters, shown next to it |

```json
{
  "data": {
    "id": "lvl_01jbz3x8k7m3n2p4r6s8t0v1w3",
    "sourceId": "src_01jbx5q8k7m3n2p4r6s8t0v1w3",
    "level": "debug",
    "match": { "type": "user", "value": "42" },
    "reason": "ticket 8812",
    "active": true,
    "expiresAt": "2026-11-30T15:15:00+00:00",
    "endedAt": null,
    "createdAt": "2026-11-30T15:00:00+00:00",
    "createdBy": "Ana Silva"
  }
}
```

A source can have 10 on at once; the 11th is a `422`. The Tailcove clients read the active ones from
`GET /api/v1/log-levels` with the source's ingest token, which you don't need to call yourself.
