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

# Create an API key

> Creates a personal API key that authenticates as the calling user against the standard REST API.

The returned `accessToken` is shown ONCE — store it securely.

Workspace scope and expiry follow the same rules as MCP personal access tokens.



## OpenAPI

````yaml post /api-key
openapi: 3.1.0
info:
  title: HERO API
  version: current
  description: |-
    The HERO REST API.

    See https://developers.myhero.so for the rendered docs.
servers:
  - url: https://app.myhero.so
security: []
paths:
  /api-key:
    post:
      tags:
        - API Keys
      summary: Create an API key
      description: >-
        Creates a personal API key that authenticates as the calling user
        against the standard REST API.


        The returned `accessToken` is shown ONCE — store it securely.


        Workspace scope and expiry follow the same rules as MCP personal access
        tokens.
      operationId: createApiKey
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                workspace_scope:
                  type: string
                  enum:
                    - all
                    - specific
                workspace_ids:
                  type: array
                  items:
                    type: string
                    minLength: 1
                expires_in_days:
                  anyOf:
                    - type: integer
                      exclusiveMinimum: 0
                    - type: 'null'
              required:
                - name
                - workspace_scope
      responses:
        '201':
          description: 201 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      accessToken:
                        type: string
                        description: |-
                          The full `hero_ak_*` API key.

                          Shown once; store it securely.
                      tokenId:
                        type: string
                      expiresAt:
                        type: number
                    required:
                      - accessToken
                      - tokenId
                      - expiresAt
                required:
                  - data
        '400':
          description: 400 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: |-
                      Error class name (e.g.

                      ValidationError, NotFound)
                  message:
                    type: string
                    description: Human-readable error message
                  details:
                    type: array
                    items: {}
                required:
                  - error
                  - message
        '403':
          description: 403 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: |-
                      Error class name (e.g.

                      ValidationError, NotFound)
                  message:
                    type: string
                    description: Human-readable error message
                  details:
                    type: array
                    items: {}
                required:
                  - error
                  - message
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: HERO personal access token

````