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

# Authenticate user and obtain JWT tokens

> **System Function**: Authenticates a user with email/password credentials and returns JWT tokens for API access.
    This endpoint validates user credentials and provides both access and refresh tokens. The access token is used for authenticating API requests, while the refresh token can be used to obtain new access tokens when they expire.



## OpenAPI

````yaml POST /login
openapi: 3.0.0
info:
  title: DeFindex API
  description: API documentation for DeFindex endpoints
  version: 1.0.0
  contact: {}
  x-logo:
    url: https://links.paltalabs.io/defindex-full.svg
    backgroundColor: '#0e0e0e'
    altText: DeFindex Logo
    href: https://defindex.io
servers: []
security: []
tags: []
paths:
  /login:
    post:
      tags:
        - Auth
      summary: Authenticate user and obtain JWT tokens
      description: >-
        **System Function**: Authenticates a user with email/password
        credentials and returns JWT tokens for API access.
            This endpoint validates user credentials and provides both access and refresh tokens. The access token is used for authenticating API requests, while the refresh token can be used to obtain new access tokens when they expire.
      operationId: AuthController_login
      parameters: []
      requestBody:
        required: true
        description: User login credentials.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthLoginDto'
            examples:
              User login:
                value:
                  email: user@example.com
                  password: SecurePassword123!
      responses:
        '200':
          description: Authentication successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  username:
                    type: string
                    description: Username of the authenticated user
                  role:
                    type: string
                    description: Role of the authenticated user
                  access_token:
                    type: string
                    description: JWT access token for API authentication
                  refresh_token:
                    type: string
                    description: JWT refresh token for renewing access tokens
                example:
                  username: defi_investor
                  role: USER
                  access_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
                  refresh_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        '401':
          description: Unauthorized - invalid credentials
components:
  schemas:
    AuthLoginDto:
      type: object
      properties:
        email:
          type: string
          example: test@example.com
        password:
          type: string
          example: strongpassword123
      required:
        - email
        - password

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.