> ## 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.

# Create API key

> Create a new API Key that is tied to the current user account. The created API key is only listed ONCE upon creation. It can however be regenerated or deleted.




## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples post /auth/api_keys
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:
    post:
      tags:
        - API keys
      summary: Create API key
      description: >
        Create a new API Key that is tied to the current user account. The
        created API key is only listed ONCE upon creation. It can however be
        regenerated or deleted.
      operationId: post-api-key
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_api_key'
            examples:
              Created:
                summary: Created
                value:
                  data:
                    type: api_keys
                    attributes:
                      name: App Token
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/create_api_key'
            examples:
              Created:
                summary: Created
                value:
                  data:
                    type: api_keys
                    attributes:
                      name: App Token
        required: true
      responses:
        '201':
          description: Created
          content:
            application/vnd.api+json:
              examples:
                Created:
                  value:
                    data:
                      id: tok_ez2A3DVldnawP
                      type: api_keys
                      attributes:
                        name: App Token
                        token: 54ebfcfa2ad7f9fe0d4e081306554174d063
                        token_last_slice: 4d063
                        api_version: '2023-06-01'
                        read_only: false
                        allowed_ips: []
                        created_at: '2026-01-14T15:56:29+00:00'
                        updated_at: '2026-01-14T15:56:29+00:00'
                        last_used_at: null
                        user:
                          id: user_pVkpyK2aoVUlax6Zzx1pfrGe4wr
                          email: nathanael@bartoletti-streich.test
                    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.create(data={
                    "type": latitudesh_python_sdk.CreateAPIKeyType.API_KEYS,
                    "attributes": {
                        "name": "App Token",
                    },
                })

                # 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.Create(ctx, components.CreateAPIKey{\n        Data: &components.Data{\n            Type: components.CreateAPIKeyTypeAPIKeys,\n            Attributes: &components.CreateAPIKeyAttributes{\n                Name: latitudeshgosdk.Pointer(\"App Token\"),\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.create({
                data: {
                  type: "api_keys",
                  attributes: {
                    name: "App Token",
                  },
                },
              });

              console.log(result);
            }

            run();
components:
  schemas:
    create_api_key:
      type: object
      properties:
        data:
          type: object
          properties:
            type:
              type: string
              enum:
                - api_keys
            attributes:
              type: object
              properties:
                name:
                  type: string
                  description: Name of the API Key
                  default: 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:
                - name
          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

````