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

# Create an SSH key

> Create an SSH public key for the current authenticated user.



## OpenAPI

````yaml /api-spec/ias-public-api.yaml post /me/ssh-keys
openapi: 3.0.3
info:
  title: IAM Service API
  description: APIs for IAM Service.
  version: 2.4.0
servers:
  - url: https://console.gmicloud.ai/api/v1
    description: IAM Service API
security: []
paths:
  /me/ssh-keys:
    post:
      tags:
        - me
      summary: Create an SSH key
      description: Create an SSH public key for the current authenticated user.
      operationId: createSSHKey
      requestBody:
        description: The request body for SSH key creation.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createSSHKeyRequest'
      responses:
        '201':
          description: Successfully created an SSH key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/createSSHKeyResponse'
        '400':
          description: |
            - [group:**request**, code:**0**]: Invalid field in the request.
            - [group:**request**, code:**1**]: The request body is required.
            - [group:**ssh-key**, code:**0**]: Invalid SSH key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                Invalid field in the request:
                  summary: Invalid field in the request.
                  value:
                    group: request
                    code: 0
                    validationDetail:
                      - field: sshKey
                        expression: required
                        originalValue: ''
                        reason: This field is required.
        '403':
          description: >
            - [group:**ssh-key**, code:**500**]: The maximum number of SSH keys
            per user has been reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                The maximum number of SSH keys per user has been reached:
                  summary: The maximum number of SSH keys per user has been reached.
                  value:
                    group: ssh-key
                    code: 500
                    message: The maximum number of SSH keys per user has been reached.
        '500':
          description: >
            - [group:**ssh-key**, code:**1000**]: Create SSH key encountered DB
            error.

            - [group:**ssh-key**, code:**1200**]: Get SSH key count encountered
            DB error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                Create SSH key encountered DB error:
                  summary: Create SSH key encountered DB error.
                  value:
                    group: ssh-key
                    code: 1000
                    message: Create SSH key encountered DB error.
                    traces:
                      - DB error occurred.
      security:
        - bearerAuth: []
components:
  schemas:
    createSSHKeyRequest:
      type: object
      x-go-name: createSSHKeyRequest
      properties:
        sshKey:
          type: string
          description: >
            The full SSH public key supported by OpenSSH (e.g., ssh-rsa,
            ssh-ed25519, ecdsa-sha2-nistp256).
          example: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn... user@host
          x-oapi-codegen-extra-tags:
            binding: required
        name:
          type: string
          description: Human-readable name for the SSH key.
          example: My SSH key
          x-oapi-codegen-extra-tags:
            binding: required
      required:
        - sshKey
        - name
    createSSHKeyResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          x-go-type: uuid.UUID
          description: The unique identifier (UUID) of the newly created SSH key.
          example: 550e8400-e29b-41d4-a716-446655440000
          x-go-type-skip-optional-pointer: true
    ErrStatusMsg:
      type: object
      properties:
        group:
          type: string
          description: >-
            API function group\n -Will be "request" if there are invalid request
            parameters.
          x-oapi-codegen-extra-tags:
            binding: required
        code:
          type: integer
          description: The substatus error code for the API response.
          x-oapi-codegen-extra-tags:
            binding: required
        message:
          type: string
          description: The substatus error Message for API response.
          x-go-type-skip-optional-pointer: true
        traces:
          type: array
          items:
            type: string
          description: The original error messages.
          x-go-type-skip-optional-pointer: true
        validationDetail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationDetail'
          description: >-
            Returned when there are invalid request
            paremeters(group="request")\n List of invalid fields and the reason
            of error.
          x-go-type-skip-optional-pointer: true
      example:
        group: request
        code: 0
        validationDetail:
          - field: email
            expression: required
            originalValue: ''
            reason: This field is required.
      required:
        - group
        - code
    ValidationDetail:
      type: object
      properties:
        field:
          type: string
          description: The field of the request data.
          x-go-type-skip-optional-pointer: true
        expression:
          type: string
          description: The form of violation.
          x-go-type-skip-optional-pointer: true
        argument:
          type: string
          description: The number or data to support the expression.
          x-go-type-skip-optional-pointer: true
        originalValue:
          description: The original value from the request.
          x-go-type-skip-optional-pointer: true
        reason:
          type: string
          description: The reason for the validation error.
          x-go-type-skip-optional-pointer: true
      example:
        - field: fieldXXX
          expression: required
          originalValue: ''
          reason: This field is required.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        An access token used to authenticate a user and grant access to
        restricted APIs. It is issued by session APIs.

        For status codes related to this header, refer to the 

        [Common Headers
        Documentation](https://gmicloud.atlassian.net/wiki/spaces/CE/pages/47199534/Common+Headers#Authorization).

````