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

# Update API Key Expiry

> Update the expiry date for an API key. If expires_at is not set or is null, the current expiry will be removed, making the API key non-expiring.

Update the expiry date for an API key. If `expires_at` is not set or is null, the current expiry will be removed, making the API key non-expiring.

<Tip>
  Setting an expiry date helps ensure API keys are automatically invalidated after a certain time period, improving security for temporary access scenarios.
</Tip>

<Warning>
  You cannot update the expiry for an API key that has already expired. Once an API key is expired, it cannot be un-expired.
</Warning>


## OpenAPI

````yaml POST /v1/manage/apikey/{id}/expiry
openapi: 3.0.3
info:
  title: Requesty API
  description: Requesty API for AI model routing and key management
  version: 1.0.0
servers:
  - url: https://api-v2.requesty.ai
    description: Management API endpoint
  - url: https://router.requesty.ai
    description: Inference router endpoint
security:
  - BearerAuth: []
paths:
  /v1/manage/apikey/{id}/expiry:
    servers:
      - url: https://api-v2.requesty.ai
        description: Management API endpoint
    post:
      summary: Update API key expiry
      description: >-
        Update the expiry date for an API key. If expires_at is not set or is
        null, the current expiry will be removed, making the API key
        non-expiring.
      operationId: updateApiKeyExpiry
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateExpiryRequest'
      responses:
        '204':
          description: Expiry updated successfully
        '400':
          description: Bad request - malformed payload or invalid parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - missing or empty Authorization header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Payment required - organization balance exhausted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - invalid token or model not in access list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - provider/model not supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded. Retry after the Retry-After header value.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Bad gateway - upstream provider returned an invalid response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    UpdateExpiryRequest:
      type: object
      properties:
        expires_at:
          type: string
          format: date-time
          description: >-
            Expiry date in RFC3339 format (e.g., 2025-12-31T23:59:59Z). If not
            set or null, the current expiry will be removed, making the API key
            non-expiring.
          example: '2025-12-31T23:59:59Z'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - origin
            - message
          properties:
            origin:
              type: string
              enum:
                - router
                - provider
              description: >-
                Whether the error originated from Requesty's router or an
                upstream provider.
            message:
              type: string
              description: Human-readable error description.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````