---
title: "Get time-to-live for a key"
method: POST
path: "/kv/ttl"
tags: ["KV Store"]
---

# Get time-to-live for a key

`POST /kv/ttl`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/kv/ttl`
- Auth: HTTP bearer

## Request body

- TtlRequest: Request to get TTL for a key
  - `key` string, required: The key to check TTL for
  - `project_id` integer, nullable: Project ID (required for API key/session auth, optional for deployment tokens)

## Response `200`

TTL retrieved

- TtlResponse: Response for TTL operation
  - `ttl` integer, required: TTL in seconds, -1 if no expiration, -2 if key doesn't exist

## Other responses

- `401`: Unauthorized
- `500`: Internal server error

## Changes

- **2026-04-25** `774be20905f2`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/kv/ttl/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)
