---
title: "Create a log ingest key. The response is the only time the key is shown."
method: POST
path: "/projects/{project_id}/logs/ingest-keys"
tags: ["Logs"]
---

# Create a log ingest key. The response is the only time the key is shown.

`POST /projects/{project_id}/logs/ingest-keys`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/logs/ingest-keys`
- Auth: HTTP bearer

## Path parameters

- `project_id` integer, required

## Request body

- CreateLogIngestKeyRequest
  - `default_service` string, nullable: Service label for lines that do not name one. Default `external`.
  - `environment_id` integer, nullable: Pin the key to one environment of the project. Absent: lines are labelled with the environment `external`.
  - `name` string, required: A label for the collector or host using the key.

## Response `201`

Key created; the plaintext is in `key`

- CreatedLogIngestKeyResponse: A key just created: the only response that carries the plaintext.
  - `created_at` string, date-time, required
  - `created_by_user_id` integer, nullable
  - `default_service` string, required
  - `environment_id` integer, nullable
  - `id` integer, required
  - `is_active` boolean, required
  - `key_prefix` string, required: The first characters of the key, for recognising it.
  - `last_used_at` string, date-time, nullable
  - `line_count` integer, required: Lines ingested with this key. Updated every 30 seconds.
  - `name` string, required
  - `project_id` integer, required
  - `revoked_at` string, date-time, nullable
  - `key` string, required: The full key. Shown once; only its hash is stored.

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Project or environment not found
- `500`: Internal server error

## Changes

- **2026-11-21** `d57a37c13a27`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/logs/ingest-keys/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
