---
title: "POST /api/obtain-token"
method: POST
path: "/api/obtain-token"
tags: ["obtain-token"]
---

# POST /api/obtain-token

`POST /api/obtain-token`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - API key in cookie `sessionid`

If we don't restrict this to JSON-only, the Python generated
code tries to both send form-multipart and JSON.

## Request body

- AuthTokenWithSecondFactorRequest: DRF's token login (username/password), plus `otp` for accounts with 2FA. Codes only: an account with nothing but security keys uses a recovery code here.
  - `username` string, required
  - `password` string, required
  - `otp` string

## Response `200`

- AuthTokenWithSecondFactor: DRF's token login (username/password), plus `otp` for accounts with 2FA. Codes only: an account with nothing but security keys uses a recovery code here.
  - `token` string, required

## Other responses

- `400`
- `401`
- `404`
- `405`
- `406`
- `415`
- `500`

## Changes

- **2026-11-13** `f930f1978e15`: 1 breaking, 2 info
  - added `#/components/schemas/ObtainTokenCreateOtpErrorComponent` to the `oneOf[#/components/schemas/ObtainTokenCreateValidationError]/errors/items/` response property `oneOf` list for the response status `400`
  - added the new optional request property `otp`
  - added `otp` discriminator mapping keys to the `oneOf[#/components/schemas/ObtainTokenCreateValidationError]/errors/items/` response property for the response status `400`
- **2026-08-15** `9164f6763019`: 1 info
  - added the non-success response with the status `404`
- **2025-08-17** `14b27b584fd2`: 6 info
  - added the non-success response with the status `400`
  - added the non-success response with the status `401`
  - added the non-success response with the status `405`
  - added the non-success response with the status `406`
  - …2 more
- **2025-08-04** `ec9531386449`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/frikanalen/apis/frikanalen-django-api/changes/api/obtain-token/post.md)

---

[API](https://skmtc.dev/frikanalen/apis/frikanalen-django-api.md) - [All operations](https://skmtc.dev/frikanalen/apis/frikanalen-django-api/llms.txt) - [OpenAPI document](https://skmtc.dev/frikanalen/apis/frikanalen-django-api/revisions/ebd4175e41fe?raw)
