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

# Update API key settings

> Update API Key settings (name, read_only, allowed_ips) without rotating the token.
Use PUT to rotate the token.




## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples patch /auth/api_keys/{api_key_id}
openapi: 3.0.1
info:
  title: Latitude.sh API
  version: '2023-06-01'
  description: >-
    The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It
    allows you to perform the same actions as the Latitude.sh dashboard.
servers:
  - url: https://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
  - url: http://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
security: []
tags:
  - name: API keys
  - name: Billing
  - name: Elastic Ips
  - name: Events
  - name: Firewalls
  - name: IP Addresses
  - name: Kubernetes Clusters
  - name: Operating Systems
  - name: Plans
  - name: Private Networks
  - name: Projects
  - name: Regions
  - name: Roles
  - name: SSH Keys
  - name: Servers
  - name: Storage
  - name: Tags
  - name: Teams
  - name: Team members
  - name: Traffic
  - name: User data
  - name: User profile
  - name: VPN Sessions
  - name: Virtual machines
paths:
  /auth/api_keys/{api_key_id}:
    patch:
      tags:
        - API keys
      summary: Update API key settings
      description: >
        Update API Key settings (name, read_only, allowed_ips) without rotating
        the token.

        Use PUT to rotate the token.
      operationId: update-api-key
      parameters:
        - name: api_key_id
          in: path
          required: true
          examples:
            Success - Update name without rotating token:
              value: tok_lpbV0DgRq4AWz
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/update_api_key'
            examples:
              Success - Update name without rotating token:
                summary: Success - Update name without rotating token
                value:
                  data:
                    id: tok_lpbV0DgRq4AWz
                    type: api_keys
                    attributes:
                      name: Updated Name
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/update_api_key'
            examples:
              Success - Update name without rotating token:
                summary: Success - Update name without rotating token
                value:
                  data:
                    id: tok_lpbV0DgRq4AWz
                    type: api_keys
                    attributes:
                      name: Updated Name
        required: true
      responses:
        '200':
          description: Success - Update name without rotating token
          content:
            application/vnd.api+json:
              examples:
                Success - Update name without rotating token:
                  value:
                    data:
                      id: tok_lpbV0DgRq4AWz
                      type: api_keys
                      attributes:
                        name: Updated Name
                        token_last_slice: c10e6
                        api_version: '2023-06-01'
                        read_only: false
                        allowed_ips: null
                        created_at: '2026-01-14T15:56:30+00:00'
                        updated_at: '2026-01-14T15:56:30+00:00'
                        last_used_at: null
                        user:
                          id: user_YLMV5L9oYRFoe4Jo4l2PCGKr8bBa
                          email: jaime@ullrich.example
                    meta: {}
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/api_key'
      security:
        - Bearer: []
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            import latitudesh_python_sdk
            from latitudesh_python_sdk import Latitudesh
            import os


            with Latitudesh(
                bearer=os.getenv("LATITUDESH_BEARER", ""),
            ) as latitudesh:

                res = latitudesh.api_keys.update_api_key(api_key_id="tok_lpbV0DgRq4AWz", data={
                    "id": "tok_lpbV0DgRq4AWz",
                    "type": latitudesh_python_sdk.UpdateAPIKeyType.API_KEYS,
                    "attributes": {
                        "name": "Updated Name",
                    },
                })

                # Handle response
                print(res)
        - lang: go
          label: Go (SDK)
          source: "package main\n\nimport(\n\t\"context\"\n\t\"os\"\n\tlatitudeshgosdk \"github.com/latitudesh/latitudesh-go-sdk\"\n\t\"github.com/latitudesh/latitudesh-go-sdk/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := latitudeshgosdk.New(\n        latitudeshgosdk.WithSecurity(os.Getenv(\"LATITUDESH_BEARER\")),\n    )\n\n    res, err := s.APIKeys.UpdateAPIKey(ctx, \"tok_lpbV0DgRq4AWz\", components.UpdateAPIKey{\n        Data: &components.UpdateAPIKeyData{\n            ID: latitudeshgosdk.Pointer(\"tok_lpbV0DgRq4AWz\"),\n            Type: components.UpdateAPIKeyTypeAPIKeys,\n            Attributes: &components.UpdateAPIKeyAttributes{\n                Name: latitudeshgosdk.Pointer(\"Updated Name\"),\n            },\n        },\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.Object != nil {\n        // handle response\n    }\n}"
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Latitudesh } from "latitudesh-typescript-sdk";

            const latitudesh = new Latitudesh({
              bearer: process.env["LATITUDESH_BEARER"] ?? "",
            });

            async function run() {
              const result = await latitudesh.apiKeys.updateApiKey({
                apiKeyId: "tok_lpbV0DgRq4AWz",
                updateApiKey: {
                  data: {
                    id: "tok_lpbV0DgRq4AWz",
                    type: "api_keys",
                    attributes: {
                      name: "Updated Name",
                    },
                  },
                },
              });

              console.log(result);
            }

            run();
components:
  schemas:
    update_api_key:
      type: object
      properties:
        data:
          type: object
          properties:
            id:
              type: string
              format: (?-mix:^[a-zA-Z]+_[a-zA-Z0-9]+$)
            type:
              type: string
              enum:
                - api_keys
            attributes:
              type: object
              properties:
                name:
                  type: string
                  description: Name of the API Key
                read_only:
                  type: boolean
                  description: >-
                    Whether the API Key is read-only. Read-only keys can only
                    perform GET requests.
                allowed_ips:
                  type: array
                  items:
                    type: string
                  description: >-
                    List of allowed IP addresses or CIDR ranges (e.g.,
                    "192.168.1.100", "10.0.0.0/24")
          required:
            - type
    api_key:
      type: object
      properties:
        id:
          type: string
          format: (?-mix:^[a-zA-Z]+_[a-zA-Z0-9]+$)
        type:
          type: string
          enum:
            - api_keys
        attributes:
          type: object
          properties:
            name:
              type: string
              description: Name of the API Key
            api_version:
              type: string
              description: The API version associated with this API Key
            token:
              type: string
              description: The full token (only returned on create or rotate)
            token_last_slice:
              type: string
              description: The last 5 characters of the token created for this API Key
            read_only:
              type: boolean
              nullable: true
              description: Whether this API Key is read-only
            allowed_ips:
              type: array
              nullable: true
              items:
                type: string
              description: List of allowed IP addresses for this API Key
            last_used_at:
              type: string
              nullable: true
              format: date-time
              description: The last time a request was made to the API using this API Key
            user:
              type: object
              description: The owner of the API Key
              properties:
                id:
                  type: string
                  format: (?-mix:^[a-zA-Z]+_[a-zA-Z0-9]+$)
                email:
                  type: string
                  format: email
            created_at:
              type: string
              format: date-time
              description: The time when the API Key was created
            updated_at:
              type: string
              format: date-time
              description: The time when the API Key was updated
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header

````