> ## 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.

# ポリシーを作成

> 認証済みユーザーの会社にポリシーを作成します。



## OpenAPI

````yaml /ja/api-reference/openapi.json post /policies
openapi: 3.0.0
info:
  title: Corgea API
  version: 1.0.0
  description: Corgeaのスキャン機能および脆弱性管理機能を操作するためのAPI
servers:
  - url: https://www.corgea.app/api/v1
    description: 本番サーバー
security:
  - CorgeaToken: []
  - BearerAuth: []
paths:
  /policies:
    post:
      tags:
        - ポリシー
      summary: ポリシーを作成
      description: 認証済みユーザーの会社にポリシーを作成します。
      operationId: createPolicy
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePolicyRequest'
      responses:
        '201':
          description: ポリシーを正常に作成しました
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolicyResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
components:
  schemas:
    CreatePolicyRequest:
      type: object
      required:
        - policy_type
        - description
        - name
      additionalProperties: false
      properties:
        policy_type:
          type: string
          enum:
            - BLAST
            - scan
            - false_positive
            - fix
        description:
          type: string
          minLength: 10
        name:
          type: string
          minLength: 3
        cwes:
          type: array
          nullable: true
          items:
            type: string
        excludes:
          type: array
          nullable: true
          items:
            type: string
        projects:
          type: array
          nullable: true
          items:
            oneOf:
              - type: string
              - type: integer
          description: ポリシーの適用範囲を指定するプロジェクト名またはID。空またはnullの場合は会社全体のポリシーを作成します。
        active:
          type: boolean
          default: true
        instruction_type:
          type: string
          enum:
            - overwrite
            - append
          default: overwrite
        glob_pattern:
          type: string
          nullable: true
          maxLength: 255
        guidance_text:
          type: string
          nullable: true
          maxLength: 3000
    PolicyResponse:
      type: object
      properties:
        policy:
          $ref: '#/components/schemas/Policy'
    Policy:
      type: object
      properties:
        id:
          type: integer
        policy_type:
          type: string
          enum:
            - BLAST
            - scan
            - false_positive
            - fix
        description:
          type: string
        cwes:
          type: array
          nullable: true
          items:
            type: string
        excludes:
          type: array
          nullable: true
          items:
            type: string
        projects:
          type: array
          nullable: true
          items:
            type: string
          description: ポリシーの適用範囲を指定するプロジェクト名。空またはnullの場合は会社全体が対象です。
        company:
          type: integer
        active:
          type: boolean
        approved:
          type: boolean
        approved_by:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        glob_pattern:
          type: string
          nullable: true
        source_type:
          type: string
          example: Web
        repo_policy_file:
          type: integer
          nullable: true
        name:
          type: string
        guidance_text:
          type: string
          nullable: true
        version:
          type: integer
        archived:
          type: boolean
        parent_policy:
          type: integer
          nullable: true
        instruction_type:
          type: string
          enum:
            - overwrite
            - append
        read_only:
          type: boolean
        created_by_corgea:
          type: boolean
  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キー
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Authorizationヘッダーで使用するOAuth2アクセストークン（JWT）

````