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

# ユーザーを作成

> 会社の有効なユーザーを作成し、ログイン用の案内メールを送信します。`auth.add_user` と利用可能なユーザー枠が必要です。role_id または role_name のいずれか一方を任意で指定できます。ロールの割り当てには対応プランが必要です。Admin は割り当てられず、呼び出し元は選択したロールの全権限を持つ必要があります。メールアドレスの重複やユーザー数の上限では409を返します。



## OpenAPI

````yaml /ja/api-reference/openapi.json post /users
openapi: 3.0.0
info:
  title: Corgea API
  version: 1.0.0
  description: Corgeaのスキャン機能および脆弱性管理機能を操作するためのAPI
servers:
  - url: https://www.corgea.app/api/v1
    description: 本番サーバー
  - url: https://eu.corgea.app/api/v1
    description: EU本番サーバー
security:
  - CorgeaToken: []
  - BearerAuth: []
paths:
  /users:
    post:
      tags:
        - Users
      summary: ユーザーを作成
      description: >-
        会社の有効なユーザーを作成し、ログイン用の案内メールを送信します。`auth.add_user`
        と利用可能なユーザー枠が必要です。role_id または role_name
        のいずれか一方を任意で指定できます。ロールの割り当てには対応プランが必要です。Admin
        は割り当てられず、呼び出し元は選択したロールの全権限を持つ必要があります。メールアドレスの重複やユーザー数の上限では409を返します。
      operationId: createUser
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
      responses:
        '201':
          description: リクエストが成功しました
          content:
            application/json:
              schema:
                type: object
                properties:
                  user:
                    $ref: '#/components/schemas/CompanyUser'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
components:
  schemas:
    CreateUserRequest:
      type: object
      properties:
        email:
          type: string
          format: email
        first_name:
          type: string
          minLength: 1
          maxLength: 150
        last_name:
          type: string
          minLength: 1
          maxLength: 150
        role_id:
          type: integer
        role_name:
          type: string
      required:
        - email
        - first_name
        - last_name
      additionalProperties: false
    CompanyUser:
      type: object
      properties:
        id:
          type: integer
        email:
          type: string
          format: email
        first_name:
          type: string
        last_name:
          type: string
        active:
          type: boolean
        roles:
          type: array
          items:
            $ref: '#/components/schemas/UserRole'
        created_at:
          type: string
          format: date-time
    UserRole:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
  responses:
    BadRequest:
      description: リクエストが無効です
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Invalid JSON body
    Unauthorized:
      description: トークンが無効か、指定されていません
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Missing or invalid authorization header
    Forbidden:
      description: 権限がないか、機能を利用できません
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Permission denied
    Conflict:
      description: リクエストが既存のリソースと競合しています
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: A policy with this name already exists
  securitySchemes:
    CorgeaToken:
      type: apiKey
      in: header
      name: CORGEA-TOKEN
      description: 認証用のAPIキー 無効なユーザーのAPIトークンは拒否されます。
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Authorizationヘッダーで使用するOAuth2アクセストークン（JWT）

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.