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

# Create a session

> Create a session for the supplied credentials and receive access and refresh tokens. These tokens will be used for Bearer authentication, and passed as part of the authorization header where required.

<b>NOTE:</b> <code>walletId</code> should be omitted or set to <code>null</code> <i>unless</i> the API key being used is of type <code>WALLET</code>.




## OpenAPI

````yaml https://docs.api.monacoprotocol.xyz/api/v1/exchange-openapi-general.json post /sessions
openapi: 3.1.0
info:
  title: BetDEX General Integration API
  description: >-
    A RESTful API that allows you to interact with the BetDEX Exchange. Provides
    endpoints for managing Events, Markets, Sessions, Wallets and Orders. To
    interact with the API, a client must have an App Id and an API Key to
    authenticate and create a session.
  version: '0.1'
servers:
  - url: https://sandbox.api.btdx.io/
    description: Sandbox API Server
  - url: https://prod.api.btdx.io/
    description: Production API Server
security: []
tags:
  - name: API Key Management
  - name: App Management
  - name: Currencies
  - name: Event Categories
  - name: Event Groups
  - name: Event Subcategories
  - name: Events
  - name: External Reference Sources
  - name: Heartbeat Management
  - name: Market Prices
  - name: Market Types
  - name: Markets
  - name: Orders
  - name: Participants
  - name: Session Management
  - name: Status
  - name: Trades
  - name: Wallet API Key Management
  - name: Wallets
paths:
  /sessions:
    post:
      tags:
        - Session Management
      summary: Create a session
      description: >
        Create a session for the supplied credentials and receive access and
        refresh tokens. These tokens will be used for Bearer authentication, and
        passed as part of the authorization header where required.


        <b>NOTE:</b> <code>walletId</code> should be omitted or set to
        <code>null</code> <i>unless</i> the API key being used is of type
        <code>WALLET</code>.
      operationId: createSession
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/SessionResponse'
        '404':
          description: >-
            No matching credentials were found. If the provided API key is of
            type WALLET, please be sure the appropriate wallet ID is passed in
            the <code>walletId</code> field.
          content:
            '*/*':
              example:
                title: Not found
                details:
                  - >-
                    APIKey entity with ID of pa****34 not found for App with ID
                    of ANAPPID
components:
  schemas:
    CreateSessionRequest:
      type: object
      example:
        appId: ANAPPID
        walletId: OPTIONAL-ONLY-IF-APIKEY-IS-TYPE-WALLET
        apiKey: password1234
      properties:
        appId:
          type: string
          description: The ID of the app
        walletId:
          type: string
          description: >-
            If using an API key of type WALLET, please supply the ID of the
            wallet
        apiKey:
          type: string
          description: The API key secret
      required:
        - apiKey
        - appId
    SessionResponse:
      type: object
      example:
        _meta:
          _primary_document: sessions
          _count: 1
        sessions:
          - accessToken: eyJ0eXAiOiJh....bBDA
            refreshToken: eyJ0eXAiOiJy....uHCQ
            accessExpiresAt: '2099-01-01T23:59:59.999Z'
            refreshExpiresAt: '2099-01-01T23:59:59.999Z'
      properties:
        _meta:
          $ref: '#/components/schemas/Meta'
        sessions:
          type: array
          items:
            $ref: '#/components/schemas/Session'
    Meta:
      type: object
      properties:
        _primary_document:
          type: string
          enum:
            - apiKeys
            - apps
            - categories
            - commissionRates
            - currencies
            - depositAddresses
            - depositRequests
            - events
            - eventGroups
            - externalReferences
            - externalReferenceSources
            - heartbeats
            - ids
            - markets
            - marketOutcomes
            - marketPositions
            - marketTypes
            - orders
            - participants
            - prices
            - priceLadders
            - sessions
            - statuses
            - subcategories
            - trades
            - transactions
            - wallets
            - walletMetrics
            - withdrawalRequests
        _count:
          type: integer
          format: int32
        _page:
          $ref: '#/components/schemas/PageMeta'
    Session:
      type: object
      properties:
        accessToken:
          type: string
        refreshToken:
          type: string
        accessExpiresAt:
          type: string
          format: date-time
        refreshExpiresAt:
          type: string
          format: date-time
    PageMeta:
      type: object
      properties:
        _pageNumber:
          type: integer
          format: int32
        _pageSize:
          type: integer
          format: int32
        _totalElements:
          type: integer
          format: int64
        _totalPages:
          type: integer
          format: int32

````