---
title: "Create a new authentication token"
method: POST
path: "/api/auth"
tags: ["authentication"]
---

# Create a new authentication token

`POST /api/auth`

Creates a new authentication token that is returned via the 'renterd_auth' cookie which is set by the server and the json response body. The token can be used as a cookie or as the 'apikey' query parameter for authentication.

## Query parameters

- `validity` integer, required — A duration in milliseconds

## Response `200`

Successfully created a new token

- object
  - `token` string — A hex-encoded string representing the token

## Other responses

- `400` — Bad request

## Changes

- **2025-01-16** `8e78b6754f14` — 1 breaking, 1 info
  - removed the success response with the status `204`
  - added the success response with the status `200`
- **2025-01-14** `7239a7e351de` — 1 info
  - endpoint added
- **2024-12-09** `f062c35d8f47` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/siafoundation/apis/renterd-api/changes/api/auth/post.md)

---

[API](https://skmtc.dev/siafoundation/apis/renterd-api.md) · [All operations](https://skmtc.dev/siafoundation/apis/renterd-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/siafoundation/renterd-api/revisions/c878f2715ffd/schema)
