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

# Log in

> Create an API session for use with API endpoints that require
authentication.



## OpenAPI

````yaml /openapi/cluster-api-v2.json post /login/
openapi: 3.0.0
info:
  description: >-
    REST API for querying information about CockroachDB cluster health, nodes,
    ranges,

    sessions, and other meta information. For additional details, see
    cockroachlabs.com/docs/stable/cluster-api.
  title: CockroachDB v2 API
  license:
    name: Business Source License
  version: '2.0'
  x-logo:
    url: https://www.cockroachlabs.com/docs/images/cockroachlabs-logo-170.png
    backgroundColor: '#FFFFFF'
    altText: Cockroach Labs logo
servers:
  - url: https://localhost/api/v2
  - url: http://localhost/api/v2
security: []
paths:
  /login/:
    post:
      summary: Log in
      description: |-
        Create an API session for use with API endpoints that require
        authentication.
      operationId: login
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - username
                - password
              properties:
                password:
                  type: string
                username:
                  type: string
        description: Credentials for login.
        required: true
      responses:
        '200':
          description: Login response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/loginResponse'
        '400':
          description: Bad request, if required parameters absent.
        '401':
          description: Unauthorized, if credentials do not match.
      x-codeSamples:
        - lang: Shell + Curl
          source: |-
            curl --request POST \
              --url https://localhost/api/v2/login/ \
              --header 'content-type: application/x-www-form-urlencoded'
components:
  schemas:
    loginResponse:
      type: object
      properties:
        session:
          description: >-
            Session string for a valid API session. Specify this in header for
            any API

            requests that require authentication.
          type: string
          x-go-name: Session
      x-go-package: github.com/cockroachdb/cockroach/pkg/server

````