Skip to Content
ZITADEL Docs
APIsCore ResourcesV2Session

Create Session

Create a new session with initial checks, metadata and challenges for further verification. A token will be returned, which is required for using the session as authentication, e.g. when authenticating an OIDC auth request or SAML request. Additionally, the session token can be used as OAuth2 access token to authenticate against the Zitadel APIs.

Required permissions:

  • session.write
POST
/v2/sessions

Request Body

application/json
  1. body
checks?

The checks to be performed during session creation. Note that a user check can only be performed once per session and cannot be changed afterwards. Some checks require that the user is already checked, either in the previous or the same request. For example, a password check requires that the user is already checked. Other checks, like WebAuthN or IDP intent, require that the user is already checked and a challenge was requested in any previous request. On successful checks, the session's factors field will be updated.

metadata?

Custom key value list to be stored on the session.

challenges?

Challenges to be requested for further verification. The challenges will be created and returned in the response. The challenges can then be used for further checks with the following SetSession method.

userAgent?

Store information about the user agent of the client. This information is stored on the session and can be used for auditing or security purposes. Sessions can also be filtered by user agent information.

lifetime?|

Duration after which the session will be automatically invalidated. If not set, the session will not expire automatically and must be deleted manually. Note that an expired session cannot be used for authentication anymore, but will still be listed until it is deleted.

Response Body

Success

application/json
  1. response
details?
sessionId?session_id

Unique identifier of the session.

sessionToken?session_token

The current token of the session, which is required for using the session as authentication, e.g.when authenticating an OIDC auth request or SAML request. Additionally, the session token can be used as OAuth2 access token to authenticate against the Zitadel APIs.

challenges?

The challenges that were requested for the session. The challenges can be used for further checks with the SetSession method.

Example Request
curl -X POST 'https://example.com/v2/sessions' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response200
{  "details": {    "sequence": 0,    "changeDate": "2023-01-15T01:30:15.01Z",    "resourceOwner": "string",    "creationDate": "2023-01-15T01:30:15.01Z"  },  "sessionId": "string",  "sessionToken": "string",  "challenges": {    "webAuthN": {      "publicKeyCredentialRequestOptions": {        "property1": null,        "property2": null      }    },    "otpSms": "string",    "otpEmail": "string"  }}

Was this page helpful?