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

# Refresh Tokens

> Refresh access and refresh tokens.

Validates the provided refresh token, issues new tokens, and invalidates
the old refresh token (token rotation).

Flow:
1. Validate refresh token (signature, expiration, type)
2. Check if token is revoked in database
3. Get user information from token claims
4. Revoke old refresh token
5. Generate new access token and refresh token
6. Store new refresh token
7. Return new tokens



## OpenAPI

````yaml post /api/v1/auth/refresh
openapi: 3.1.0
info:
  title: SnackBase
  description: Open-source Backend-as-a-Service (BaaS)
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/auth/refresh:
    post:
      tags:
        - auth
      summary: Refresh Tokens
      description: |-
        Refresh access and refresh tokens.

        Validates the provided refresh token, issues new tokens, and invalidates
        the old refresh token (token rotation).

        Flow:
        1. Validate refresh token (signature, expiration, type)
        2. Check if token is revoked in database
        3. Get user information from token claims
        4. Revoke old refresh token
        5. Generate new access token and refresh token
        6. Store new refresh token
        7. Return new tokens
      operationId: refresh_tokens_api_v1_auth_refresh_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RefreshRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenRefreshResponse'
        '401':
          description: Invalid or expired refresh token
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    RefreshRequest:
      properties:
        refresh_token:
          type: string
          minLength: 1
          title: Refresh Token
          description: JWT refresh token
      type: object
      required:
        - refresh_token
      title: RefreshRequest
      description: Request body for token refresh.
    TokenRefreshResponse:
      properties:
        token:
          type: string
          title: Token
          description: New JWT access token
        refresh_token:
          type: string
          title: Refresh Token
          description: New JWT refresh token
        expires_in:
          type: integer
          title: Expires In
          description: Access token expiration time in seconds
      type: object
      required:
        - token
        - refresh_token
        - expires_in
      title: TokenRefreshResponse
      description: Response for successful token refresh.
    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

````