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

# Create an API key.

> 
    ROLES: USER_ADMIN
    USER: true
    SERVICE ACCOUNT: true
    



## OpenAPI

````yaml post /api/v1/accounts/{userId}/keys
openapi: 3.0.0
info:
  title: RevoEngine Platform API
  description: >-
    Official documentation of RevoEngine Platform API<br>Build:
    67df453bb5b0f9b2894535729c66632b73a015a6
  version: Beta - 0.1.0
  contact:
    name: Support
    url: https://help.revong.com
    email: support@revong.com
  termsOfService: https://docs.revong.com/tos
servers:
  - url: https://api.revong.com
    description: RevoEngine Platform API - Production
  - url: https://api.test.revong.com
    description: RevoEngine Platform API - Test
security: []
tags: []
externalDocs:
  description: Documentation
  url: https://docs.revong.com
paths:
  /api/v1/accounts/{userId}/keys:
    post:
      tags:
        - Accounts
      summary: Create an API key.
      description: |2-

            ROLES: USER_ADMIN
            USER: true
            SERVICE ACCOUNT: true
            
      operationId: UsersController_createKey
      parameters:
        - name: userId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateKeyDto'
      responses:
        '201':
          description: OK.
        '400':
          description: Bad request.
        '403':
          description: Forbidden.
        '404':
          description: Not found.
      security:
        - bearer: []
components:
  schemas:
    CreateKeyDto:
      type: object
      properties:
        name:
          type: string
          description: You need to provide name of the user.
        restricted:
          type: boolean
          description: You can provide if key should be whitelisted.
        whitelist:
          description: In case when restricted, this should be filled also.
          type: array
          items:
            $ref: '#/components/schemas/UserKeyWhitelistDto'
        expireAt:
          format: date-time
          type: string
          description: Aggregation period from.
      required:
        - name
        - restricted
        - expireAt
    UserKeyWhitelistDto:
      type: object
      properties:
        name:
          type: string
          description: You need to provide name of the user.
        type:
          type: string
          description: You need to provide type of whitelist IP,IP_SUBNET,RANGE.
        value:
          type: string
          description: >-
            You need to provide IP, IP
            (10.0.8.0)/MASK(10.0.8.0/18)/RANGE(10.0.8.0-10.0.8.255).
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      description: Bearer token with Platform JWT token or API Key.
      type: http

````