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

# Import or generate keypair

> To generate a keypair do not use the `public_key` parameter in the request body



## OpenAPI

````yaml /api-reference/services_documented/cloud_api.yaml post /cloud/v1/keypairs/{project_id}/{region_id}
openapi: 3.1.0
info:
  title: Gcore OpenAPI – Cloud API
  description: >-
    This OpenAPI is an aggregated OpenAPI specification that unifies all Gcore
    products into a single file. It covers Cloud, CDN, DNS, WAAP, DDoS
    Protection, Object Storage, Streaming, and FastEdge services.
  version: '2026-05-15T06:37:28.230198+00:00'
servers:
  - url: https://api.gcore.com
security:
  - APIKey: []
tags:
  - name: Bare Metal
    x-displayName: Bare Metal
  - name: Container as a Service
    x-displayName: Container as a Service
  - name: Cost Reports
    x-displayName: Cost Reports
  - name: DDoS Protection
    x-displayName: DDoS Protection
  - name: Everywhere Inference
    x-displayName: Everywhere Inference
  - name: Everywhere Inference Apps
    x-displayName: Everywhere Inference Apps
  - name: File Shares
    x-displayName: File Shares
  - name: Floating IPs
    x-displayName: Floating IPs
  - name: Function as a Service
    x-displayName: Function as a Service
  - name: GPU Bare Metal
    x-displayName: GPU Bare Metal
  - name: GPU Virtual
    x-displayName: GPU Virtual
  - name: IP Ranges
    x-displayName: IP Ranges
  - name: Images
    x-displayName: Images
  - name: Instances
    x-displayName: Instances
  - name: Load Balancers
    x-displayName: Load Balancers
  - name: Logging
    x-displayName: Logging
  - name: Managed Kubernetes
    x-displayName: Managed Kubernetes
  - name: Managed PostgreSQL
    x-displayName: Managed PostgreSQL
  - name: Networks
    x-displayName: Networks
  - name: Placement Groups
    x-displayName: Placement Groups
  - name: Projects
    x-displayName: Projects
  - name: Quotas
    x-displayName: Quotas
  - name: Regions
    x-displayName: Regions
  - name: Registry
    x-displayName: Registry
  - name: Reservations
    x-displayName: Reservations
  - name: Reserved IPs
    x-displayName: Reserved IPs
  - name: Routers
    x-displayName: Routers
  - name: SSH Keys
    x-displayName: SSH Keys
  - name: Secrets
    x-displayName: Secrets
  - name: Security Groups
    x-displayName: Security Groups
  - name: Snapshot Schedules
    x-displayName: Snapshot Schedules
  - name: Snapshots
    x-displayName: Snapshots
  - name: Tasks
    x-displayName: Tasks
  - name: User Actions
    x-displayName: User Actions
  - name: User Role Assignments
    x-displayName: User Role Assignments
  - name: Volumes
    x-displayName: Volumes
paths:
  /cloud/v1/keypairs/{project_id}/{region_id}:
    post:
      tags:
        - SSH Keys
      summary: Import or generate keypair
      description: >-
        To generate a keypair do not use the `public_key` parameter in the
        request body
      operationId: KeypairViewSet.post
      parameters:
        - in: path
          name: project_id
          required: true
          description: Project ID
          schema:
            description: Project ID
            example: 123
            examples:
              - 123
            title: Project Id
            type: integer
        - in: path
          name: region_id
          required: true
          description: Region ID
          schema:
            description: Region ID
            example: 7
            examples:
              - 7
            title: Region Id
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateKeypairSerializer'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeypairSerializer'
      deprecated: true
components:
  schemas:
    CreateKeypairSerializer:
      properties:
        public_key:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Public part of the key. To generate public and private keys in the
            platform, do not specify the parameter in the request body.
          examples:
            - >-
              ssh-rsa
              AAAAB3NzaC1yc2EAAAADAQABAAABAQDFHrnwGVBZs6q6vmTBzQFfzdRLQW8N6Rd0ogGe3h8tm83ZJLTTsF+1H4JcOvwI5ETkHMaFIWd2U15nHU5M7plE6UPRKfzy4rq6yI6cE4tojd3A9attMpbEEX7EbGKrbrb4AsjzxHKAVaREAb31ZplJkUlsiees25hTQXBcWQnOESlc9RCxZ/QQgNUUgqm7QGg7CNkL8Mpq9V4YaOhcFGWj0jXP1CL3g6Xe3xJo1CmUbkIOGUyAmrSfLEiy2O91iOUhbmYQyXksznNrT9O6uLkijf6syLZOdyAuUd/Z86eYXej4/YsvIA5eIFU4B6y9zOXEO2A81txPYMRAytYt7+e7
              alice@alice
          title: Public Key
        shared_in_project:
          anyOf:
            - type: boolean
            - type: 'null'
          default: true
          description: Keypair is shared for all users in the project. Default True
          examples:
            - true
            - false
          title: Shared In Project
        sshkey_name:
          description: Keypair name
          example: alice
          examples:
            - alice
          maxLength: 255
          minLength: 1
          pattern: ^[a-zA-Z0-9][a-zA-Z 0-9._\-]{1,61}[a-zA-Z0-9._]$
          title: Sshkey Name
          type: string
      required:
        - sshkey_name
      title: Create Keypair schema
      type: object
    KeypairSerializer:
      additionalProperties: false
      properties:
        created_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          default: null
          description: Keypair creation datetime
          examples:
            - '2022-06-16T17:05:50'
          title: Created At
        fingerprint:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Key fingerprint
          examples:
            - 86:75:ce:e7:e9:1e:f0:79:ec:6f:d8:92:9b:43:fc:4d
          title: Fingerprint
        id:
          description: Key ID, equal to `sshkey_name`
          example: 36a7a97a-0672-4911-8f2b-92cd4e5b0d91
          examples:
            - 36a7a97a-0672-4911-8f2b-92cd4e5b0d91
          title: Id
          type: string
        name:
          description: Keypair name
          example: alice
          examples:
            - alice
          maxLength: 255
          minLength: 1
          pattern: ^[a-zA-Z0-9][a-zA-Z 0-9._\-]{1,61}[a-zA-Z0-9._]$
          title: Name
          type: string
        private_key:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Private part of the key
          examples:
            - <private_key>
          title: Private Key
        project_id:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: Project ID
          examples:
            - 1
          title: Project Id
        public_key:
          description: >-
            Public part of the key. To generate public and private keys in the
            platform, do not specify the parameter in the request body.
          example: >-
            ssh-rsa
            AAAAB3NzaC1yc2EAAAADAQABAAABAQDFHrnwGVBZs6q6vmTBzQFfzdRLQW8N6Rd0ogGe3h8tm83ZJLTTsF+1H4JcOvwI5ETkHMaFIWd2U15nHU5M7plE6UPRKfzy4rq6yI6cE4tojd3A9attMpbEEX7EbGKrbrb4AsjzxHKAVaREAb31ZplJkUlsiees25hTQXBcWQnOESlc9RCxZ/QQgNUUgqm7QGg7CNkL8Mpq9V4YaOhcFGWj0jXP1CL3g6Xe3xJo1CmUbkIOGUyAmrSfLEiy2O91iOUhbmYQyXksznNrT9O6uLkijf6syLZOdyAuUd/Z86eYXej4/YsvIA5eIFU4B6y9zOXEO2A81txPYMRAytYt7+e7
            alice@alice
          examples:
            - >-
              ssh-rsa
              AAAAB3NzaC1yc2EAAAADAQABAAABAQDFHrnwGVBZs6q6vmTBzQFfzdRLQW8N6Rd0ogGe3h8tm83ZJLTTsF+1H4JcOvwI5ETkHMaFIWd2U15nHU5M7plE6UPRKfzy4rq6yI6cE4tojd3A9attMpbEEX7EbGKrbrb4AsjzxHKAVaREAb31ZplJkUlsiees25hTQXBcWQnOESlc9RCxZ/QQgNUUgqm7QGg7CNkL8Mpq9V4YaOhcFGWj0jXP1CL3g6Xe3xJo1CmUbkIOGUyAmrSfLEiy2O91iOUhbmYQyXksznNrT9O6uLkijf6syLZOdyAuUd/Z86eYXej4/YsvIA5eIFU4B6y9zOXEO2A81txPYMRAytYt7+e7
              alice@alice
          title: Public Key
          type: string
        shared_in_project:
          description: Keypair is shared for all users in the project
          example: true
          examples:
            - true
          title: Shared In Project
          type: boolean
        state:
          $ref: '#/components/schemas/KeypairState'
          description: Keypair state
          examples:
            - ACTIVE
            - DELETING
      required:
        - id
        - public_key
        - name
        - state
        - shared_in_project
      title: Keypair response object
      type: object
    KeypairState:
      enum:
        - ACTIVE
        - DELETING
      title: KeypairState
      type: string
  securitySchemes:
    APIKey:
      description: >-
        API key for authentication. Make sure to include the word `apikey`,
        followed by a single space and then your token.

        Example: `apikey 1234$abcdef`
      type: apiKey
      in: header
      name: Authorization

````