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

# Authentication

> Authenticate using username and password submitted via form data.

This endpoint is compatible with standard OAuth2 clients that use form-based authentication. Returns an access token upon successful authentication.

The returned token is valid for 1 hour, after which a new token must be requested.

Exchange your API credentials for a bearer token granting time-bound access to your organisation's resources.

<Note>
  This token is valid for **1 hour**. Once it expires you'll need to request a new one. For longer-lived, site-scoped access for end users, see the [Component token](./component-token).
</Note>


## OpenAPI

````yaml POST /auth/token-form
openapi: 3.1.0
info:
  title: Axle API Docs
  description: >-
    For full documentation please see our official docs at <a
    href='http://docs.axle.energy'>docs.axle.energy</a>
  version: 1.4.6
servers:
  - url: https://api-sandbox.axle.energy
security: []
tags:
  - name: 1. Authentication
    description: Authenticate yourself with the Axle API
  - name: 2. Meters
    description: Find key info about your sites
  - name: 3. Sites
    description: Register your sites with Axle; configure market participation
  - name: 4. Assets
    description: Register your assets with Axle
  - name: 5. Data
    description: Send asset metrics to Axle, for analysis and optimisation purposes
  - name: 6. Rewards
    description: >-
      Determine how much your users have earned by participating with Axle;
      allow balance withdrawal
  - name: 7. Validation
    description: Validate structured data against Axle's rules
  - name: 8. Examples
    description: Get example data for testing
paths:
  /auth/token-form:
    post:
      tags:
        - 1. Authentication
      summary: Login For Access Token Form
      description: >-
        Authenticate using username and password submitted via form data.


        This endpoint is compatible with standard OAuth2 clients that use
        form-based authentication. Returns an access token upon successful
        authentication.


        The returned token is valid for 1 hour, after which a new token must be
        requested.
      operationId: login_for_access_token_form_auth_token_form_post
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: >-
                #/components/schemas/Body_login_for_access_token_form_auth_token_form_post
        required: true
      responses:
        '200':
          description: Successfully authenticated with access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Token'
        '401':
          description: Incorrect username or password
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_login_for_access_token_form_auth_token_form_post:
      properties:
        username:
          type: string
          title: Username
        password:
          type: string
          title: Password
        grant_type:
          type: string
          pattern: ^password$
          title: Grant Type
          default: password
      type: object
      required:
        - username
        - password
      title: Body_login_for_access_token_form_auth_token_form_post
    Token:
      properties:
        access_token:
          type: string
          title: Access Token
        token_type:
          type: string
          title: Token Type
      type: object
      required:
        - access_token
        - token_type
      title: Token
      description: Organisation scoped token.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````