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

# Create a machine user API key

> Creates another API key for a machine user, leaving its existing keys active.



## OpenAPI

````yaml post /v1/grid/machine_users/{machine_user_id}/api_keys
openapi: 3.1.0
info:
  description: REST API for management of Baseten resources
  title: Baseten management API
  version: 1.0.0
servers:
  - url: https://api.baseten.co
security:
  - BearerAuth: []
paths:
  /v1/grid/machine_users/{machine_user_id}/api_keys:
    parameters:
      - $ref: '#/components/parameters/machine_user_id'
    post:
      summary: Creates an API key for a machine user
      description: >-
        The machine user's other API keys stay active. Requires team admin for
        the machine user's team.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateGridMachineUserAPIKeyRequestV1'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIKeyV1'
      x-codeSamples:
        - lang: bash
          source: >-
            curl --request POST \

            --url
            https://api.baseten.co/v1/grid/machine_users/{machine_user_id}/api_keys
            \

            --header "Authorization: Bearer $BASETEN_API_KEY" \

            --data '{
              "name": "production"
            }'
        - lang: python
          source: >-
            import requests

            import os

            API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")

            url =
            "https://api.baseten.co/v1/grid/machine_users/{machine_user_id}/api_keys"


            headers = {"Authorization": f"Bearer {API_KEY}"}


            response = requests.request(
                "POST",
                url,
                headers=headers,
                json={'name': 'production'}
            )


            print(response.text)
components:
  parameters:
    machine_user_id:
      schema:
        type: string
      name: machine_user_id
      in: path
      required: true
  schemas:
    CreateGridMachineUserAPIKeyRequestV1:
      additionalProperties: false
      properties:
        name:
          anyOf:
            - maxLength: 255
              minLength: 1
              type: string
            - type: 'null'
          default: null
          description: >-
            Name of the API key: lowercase letters, numbers, and hyphens, at
            most 255 characters, and unique among the machine user's active
            keys. Defaults to a name derived from the machine user's.
          examples:
            - production
          title: Name
      title: CreateGridMachineUserAPIKeyRequestV1
      type: object
    APIKeyV1:
      description: Represents an API key.
      properties:
        api_key:
          description: The API key string
          title: Api Key
          type: string
      required:
        - api_key
      title: APIKeyV1
      type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send `Authorization: Bearer <api_key>`. The legacy `Authorization:
        Api-Key <api_key>` scheme is also accepted.

````