> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ownid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a new session

> Creates a new session.



## OpenAPI

````yaml post /accounts/sessions
openapi: 3.1.0
info:
  title: OwnID API
  version: 1.0.0
  description: Server API for integrating with the OwnID
servers:
  - url: https://server.ownid.com/{appId}
security:
  - AdminAccessToken: []
paths:
  /accounts/sessions:
    post:
      tags:
        - Session
      summary: Create a new session
      description: Creates a new session.
      operationId: createSession
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              allOf:
                - properties:
                    expiration:
                      type: integer
                      minimum: 0
                - $ref: '#/components/schemas/WithSessionPayload'
      responses:
        '201':
          description: Successfully created a new session.
          headers:
            Set-Cookie:
              description: Setting the session (access token) as a cookie
              schema:
                type: string
                regex: ^ownid-at=(.*); Path=/; HttpOnly; Secure;$
                examples:
                  - ownid-at={accessToken};  Path=/; HttpOnly; Secure;
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
        '400':
          description: Invalid request data.
components:
  schemas:
    WithSessionPayload:
      properties:
        payload:
          type: object
          additionalProperties: true
      examples:
        - payload:
            preferences:
              theme: dark
              resolution: wide
    Session:
      type: object
      required:
        - created
      allOf:
        - properties:
            created:
              type: string
              format: date-time
            timeout:
              type: integer
            lastActive:
              type: string
              format: date-time
        - $ref: '#/components/schemas/WithSessionPayload'
      examples:
        - created: '2000-10-31T06:30:00.000Z'
          timeout: 10000
          lastActive: '2000-10-31T06:30:00.000Z'
          payload:
            preferences:
              theme: dark
              resolution: wide
  securitySchemes:
    AdminAccessToken:
      type: http
      scheme: bearer
      bearerFormat: JWT

````