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

# Update Proxy Key

> Update an existing proxy key's configuration

Identify the key with body field proxy\_key. Legacy POST /v1/auth/proxy/update/{proxy_key} still works but is discouraged.

<RequestExample>
  ```bash cURL theme={null}
  curl https://api.electronhub.ai/v1/auth/proxy/update \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $ELECTRONHUB_API_KEY" \
    -d '{
      "proxy_key": "ek-proxy-1234567890abcdef",
      "name": "Updated Production Key",
      "expires_at": 1767225600,
      "allocated_ammount": 150.0,
      "model_whitelist": ["gpt-4o", "claude-3-5-sonnet-20241022", "dall-e-3"],
      "ip_whitelist": ["192.168.1.0/24"]
    }'
  ```

  ```python Python theme={null}
  import httpx
  import time

  expires_at = int(time.time()) + (60 * 24 * 60 * 60)

  response = httpx.post(
      "https://api.electronhub.ai/v1/auth/proxy/update",
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json",
      },
      json={
          "proxy_key": "ek-proxy-1234567890abcdef",
          "name": "Updated Production Key",
          "expires_at": expires_at,
          "allocated_ammount": 150.0,
          "model_whitelist": ["gpt-4o", "claude-3-5-sonnet-20241022", "dall-e-3"],
          "ip_whitelist": ["192.168.1.0/24"],
      },
  )

  result = response.json()
  print(f"Update result: {result['message']}")
  ```

  ```javascript Node.js theme={null}
  const expiresAt = Math.floor(Date.now() / 1000) + (60 * 24 * 60 * 60);

  const response = await fetch('https://api.electronhub.ai/v1/auth/proxy/update', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.ELECTRONHUB_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      proxy_key: 'ek-proxy-1234567890abcdef',
      name: 'Updated Production Key',
      expires_at: expiresAt,
      allocated_ammount: 150.0,
      model_whitelist: ['gpt-4o', 'claude-3-5-sonnet-20241022', 'dall-e-3'],
      ip_whitelist: ['192.168.1.0/24'],
    }),
  });

  const result = await response.json();
  console.log(`Update result: ${result.message}`);
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "message": "Proxy key updated"
  }
  ```

  ```json Error Response theme={null}
  {
    "detail": "Allocated ammount cannot exceed your daily limit of 100"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /auth/proxy/update
openapi: 3.0.1
info:
  title: Electron Hub API
  description: >-
    Unified API platform integrating 200+ AI models for chat, image generation,
    speech-to-text, embeddings, and more.
  version: 1.0.0
  contact:
    name: Electron Hub Support
    email: support@electronhub.ai
    url: https://discord.com/invite/electronhub
  license:
    name: MIT
servers:
  - url: https://api.electronhub.ai/v1
    description: Production API v1
security:
  - bearerAuth: []
paths:
  /auth/proxy/update:
    post:
      summary: Update Proxy Key
      description: >-
        Update an existing proxy key's configuration. Replaces the legacy `POST
        /auth/proxy/update/{proxy_key}`; the proxy key identifier is sent in the
        request body so the URL is static.
      operationId: updateProxyKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateProxyKeyRequest'
      responses:
        '200':
          description: Proxy key updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Proxy key updated
        '401':
          description: Missing, invalid, or non-API-key Authorization header
        '403':
          description: Proxy key is owned by a different account
        '404':
          description: Proxy key not found
components:
  schemas:
    UpdateProxyKeyRequest:
      type: object
      required:
        - proxy_key
        - name
        - expires_at
        - allocated_ammount
      properties:
        proxy_key:
          type: string
          description: The proxy key to update (must be one you own)
          minLength: 1
          maxLength: 256
          example: ek-proxy-1234567890abcdef
        name:
          type: string
          description: Name of the proxy key
          maxLength: 25
          example: Updated API Key
        expires_at:
          type: integer
          description: Expiration timestamp in seconds (-1 for no expiration)
          example: 1735689600
        allocated_ammount:
          type: number
          description: Allocated credit amount
          minimum: 0
          example: 15
        limit_type:
          type: string
          description: Spend window for the allocation
          enum:
            - daily
            - weekly
            - monthly
          default: daily
        model_whitelist:
          type: array
          items:
            type: string
          description: List of allowed models (empty for all models)
          example:
            - gpt-4o
            - claude-3-5-sonnet-20241022
          default: []
        ip_whitelist:
          type: array
          items:
            type: string
          description: List of allowed IP addresses or CIDR blocks (empty for all IPs)
          example:
            - 192.168.1.0/24
            - 203.0.113.42
          default: []
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your API key (starts with 'ek-')

````