---
title: "Create an AI custom ruleset"
method: POST
path: "/api/v2/static-analysis/ai/rulesets"
tags: ["Static Analysis"]
---

# Create an AI custom ruleset

`POST /api/v2/static-analysis/ai/rulesets`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/static-analysis/ai/rulesets`
- Auth: API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`

Create a new AI custom ruleset for the authenticated organization.

## Request body

- AiCustomRulesetRequest: Request body for creating an AI custom ruleset.
  - `data` AiCustomRulesetRequestData: Request data for creating an AI custom ruleset.
    - `attributes` AiCustomRulesetRequestAttributes: Attributes for creating an AI custom ruleset.
      - `description` string, required: Base64-encoded full description of the ruleset.
      - `name` string, required: The ruleset name.
      - `short_description` string, required: Base64-encoded short description of the ruleset.
    - `id` string: The ruleset identifier, which must match the name.
    - `type` 'ai_ruleset': AI custom ruleset resource type.

## Response `200`

Successfully created

- AiCustomRulesetResponse: Response containing a single AI custom ruleset.
  - `data` AiCustomRulesetResponseData, required: Response data for an AI custom ruleset.
    - `attributes` AiCustomRulesetResponseAttributes, required: Response attributes of an AI custom ruleset.
      - `created_at` string, date-time, required: The creation timestamp.
      - `created_by` string, required: The identifier of the user who created the ruleset.
      - `description` string, required: Base64-encoded full description of the ruleset.
      - `name` string, required: The ruleset name.
      - `rules` AiCustomRuleItem[], nullable, required: The rules contained in the ruleset.
        - `created_at` string, date-time, required: The creation timestamp.
        - `created_by` string, required: The identifier of the user who created the rule.
        - `last_revision` AiCustomRuleRevisionResponseAttributes, required: Response attributes of an AI custom rule revision.
          - `category` 'SECURITY' | 'BEST_PRACTICES' | 'CODE_STYLE' | 'ERROR_PRONE' | 'PERFORMANCE', required: Rule category
          - `checksum` string, required: Checksum of the revision content.
          - `content` string, required: Base64-encoded AI model content for this revision.
          - `created_at` string, date-time, required: The creation timestamp.
          - `created_by` string, required: The identifier of the user who created the revision.
          - `cwe` string, nullable, required: The associated CWE identifier.
          - `description` string, required: Base64-encoded full description.
          - `directories` string[], required: Directory patterns this rule applies to.
          - `execution_mode` 'auto' | 'manual' | 'always', required: The execution mode for an AI rule revision.
          - `globs` string[], required: File glob patterns this rule applies to.
          - `is_default` boolean, required: Whether this is a default Datadog rule.
          - `is_published` boolean, required: Whether this revision is published.
          - `is_testing` boolean, required: Whether this revision is for testing only.
          - `severity` 'ERROR' | 'WARNING' | 'NOTICE', required: Rule severity
          - `short_description` string, required: Base64-encoded short description.
          - `version_id` integer, required: The version identifier for this revision.
        - `name` string, required: The rule name.
      - `short_description` string, required: Base64-encoded short description of the ruleset.
    - `id` string, required: The ruleset identifier.
    - `type` 'ai_ruleset', required: AI custom ruleset resource type.

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `409`: Conflict - ruleset already exists
- `412`: Precondition Failed - validation error
- `429`: Too many requests
- `500`: Internal Server Error

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/da68bf029e4c?raw)
