---
title: "Create a new session (login)"
method: POST
path: "/api/session"
tags: ["Session"]
---

# Create a new session (login)

`POST /api/session`

If no users are defined, this will create an initial user with the given credentials.

## Request body

- union
  - UserPassword
    - `username` string, required — Username of the user.
    - `scope` 'admin' | 'install' | 'update' | 'read'
    - `totp_enabled` boolean — Whether two-factor authentication is enabled/required using TOTP. Not available if Passkey is used.
    - `passkey` boolean — Whether this user authenticates using a Passkey.
    - `limited` boolean — In case the user was authenticated with a passwordless link, the scope of the API token used for generating that link is inherited to the user session. This flag is `true` if the user would have more permissions than currently given by the passwordless link.
    - `password` string, password, required — Password of the user.
  - object
    - `token` string — A one-time login token.

## Response `200`

On successful login the server will set the authentication cookies.

- User
  - `username` string — Username of the user.
  - `scope` 'admin' | 'install' | 'update' | 'read'
  - `totp_enabled` boolean — Whether two-factor authentication is enabled/required using TOTP. Not available if Passkey is used.
  - `passkey` boolean — Whether this user authenticates using a Passkey.
  - `limited` boolean — In case the user was authenticated with a passwordless link, the scope of the API token used for generating that link is inherited to the user session. This flag is `true` if the user would have more permissions than currently given by the passwordless link.

## Other responses

- `401` — If the authentication was not successful.
- `403` — If the Contao Manager is locked after three unsuccessful login attempts.

## Changes

- **2025-03-06** `4dc3bf84edf7` — 1 warning, 2 info
  - the optional response header `Cookie` removed for the status `200`
  - added the new optional request property `oneOf[#/components/schemas/UserPassword]/allOf[#/components/schemas/User]/limited`
  - added the optional property `limited` to the response with the `200` status
- **2025-01-29** `b0fe14acdeaf` — 2 info
  - added the new optional request property `oneOf[#/components/schemas/UserPassword]/allOf[#/components/schemas/User]/passkey`
  - added the optional property `passkey` to the response with the `200` status
- **2024-11-07** `0caa21a70faf` — 2 info
  - added the new optional request property `oneOf[#/components/schemas/UserPassword]/allOf[#/components/schemas/User]/totp_enabled`
  - added the optional property `totp_enabled` to the response with the `200` status
- **2024-11-06** `e06d9f9dee25` — 2 warning, 2 info
  - removed the request property `oneOf[#/components/schemas/UserPassword]/allOf[#/components/schemas/User]/roles`
  - removed the optional property `roles` from the response with the `200` status
  - added the new optional request property `oneOf[#/components/schemas/UserPassword]/allOf[#/components/schemas/User]/scope`
  - added the optional property `scope` to the response with the `200` status
- …earlier changes not shown

[Full history](https://skmtc.dev/contao/apis/contao-manager-api/changes/api/session/post.md)

---

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