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

# Create Test Plan

> Create a new test plan for the authenticated project.

<Info>
  **Permission Required**: `project:edit-tests`
</Info>

Create a new test plan for your project. A test plan is an ordered list of
test items that can be executed together with
[Start Test Plan Run](/api-reference/test-plans/start-test-plan-run).

<Note>
  Cross-platform deployment slots (`slots`, `default_slot_name`) are read-only
  via the API and cannot be supplied here or via
  [Update Test Plan](/api-reference/test-plans/update-test-plan); manage them
  in the test plan editor. Unknown fields are rejected with a `400` error.
</Note>

## Request Body

<ParamField body="test_plan" type="object" required>
  Test plan definition

  <Expandable title="test_plan properties">
    <ParamField body="test_plan.id" type="string">
      Optional UUID. If omitted, one is generated.
    </ParamField>

    <ParamField body="test_plan.name" type="string" required>
      Test plan name
    </ParamField>

    <ParamField body="test_plan.test_items" type="TestPlanTestItem[]" required>
      Ordered list of tests in this plan

      <Expandable title="test_item properties">
        <ParamField body="multiplayer_test_id" type="string" required>
          Test UUID to include in the plan
        </ParamField>

        <ParamField body="retries" type="integer" default="0">
          Per-item retry count (0 or higher)
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## Response

Returns the newly created test plan with status `201`. The shape matches
[Get Test Plan](/api-reference/test-plans/get-test-plan).

<RequestExample>
  ```bash cURL theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  curl -X POST "https://nunu.ai/api/v1/project/your-project-id/test-plans" \
    -H "X-Api-Key: YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "test_plan": {
        "name": "Nightly Smoke",
        "test_items": [
          { "multiplayer_test_id": "a5060a07-d386-4269-98ce-b33fb894201e", "retries": 1 },
          { "multiplayer_test_id": "b1234567-89ab-cdef-0123-456789abcdef" }
        ]
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  {
    "id": "b3f1a2c4-5d6e-7f8a-9b0c-1d2e3f4a5b6c",
    "project_id": "test",
    "name": "Nightly Smoke",
    "created_at": null,
    "created_by": null,
    "modified_at": null,
    "modified_by": null,
    "test_items": [
      { "multiplayer_test_id": "a5060a07-d386-4269-98ce-b33fb894201e", "retries": 1 },
      { "multiplayer_test_id": "b1234567-89ab-cdef-0123-456789abcdef", "retries": 0 }
    ]
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /project/{projectId}/test-plans
openapi: 3.1.0
info:
  title: nunu.ai API
  description: >-
    The nunu.ai Public API allows you to programmatically interact with your
    projects, manage test runs, and upload builds.
  version: 1.0.0
servers:
  - url: https://nunu.ai/api/v1
security:
  - apiKeyAuth: []
paths:
  /project/{projectId}/test-plans:
    parameters:
      - name: projectId
        in: path
        required: true
        schema:
          type: string
        description: >-
          The project ID. You can copy it from the project settings page or the
          project URL in the dashboard.
    post:
      tags:
        - Test Plans
      summary: Create Test Plan
      description: Create a new test plan for the authenticated project.
      operationId: createTestPlan
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTestPlanRequest'
      responses:
        '201':
          description: Test plan created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestPlan'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden - missing project:edit-tests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreateTestPlanRequest:
      type: object
      required:
        - test_plan
      properties:
        test_plan:
          type: object
          required:
            - name
            - test_items
          properties:
            id:
              type: string
              format: uuid
              description: Optional - generated if omitted
            name:
              type: string
            test_items:
              type: array
              items:
                $ref: '#/components/schemas/TestPlanTestItem'
    TestPlan:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the test plan
        project_id:
          type: string
          format: uuid
          description: Project the test plan belongs to
        name:
          type: string
          description: Test plan name
        created_at:
          type: string
          format: date-time
          nullable: true
        created_by:
          type: string
          nullable: true
        modified_at:
          type: string
          format: date-time
          nullable: true
        modified_by:
          type: string
          nullable: true
        slots:
          type: array
          items:
            $ref: '#/components/schemas/TestPlanSlot'
          description: >-
            Extra deployment slots of a cross-platform test plan (read-only via
            the API; managed in the test plan editor). Their indices key
            `slot_deployment_configs` when starting the plan; slot 1 is the
            implicit default slot.
        default_slot_name:
          type: string
          nullable: true
          description: >-
            Optional display name of the implicit default slot (slot 1).
            Read-only via the API.
        test_items:
          type: array
          items:
            $ref: '#/components/schemas/TestPlanTestItem'
          description: Ordered list of tests in this plan
    Error:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
        details:
          type: object
    TestPlanTestItem:
      type: object
      properties:
        multiplayer_test_id:
          type: string
          format: uuid
          description: ID of the test to include in the plan
        retries:
          type: integer
          minimum: 0
          default: 0
          description: Number of retries for this test item
      required:
        - multiplayer_test_id
    TestPlanSlot:
      type: object
      properties:
        index:
          type: integer
          description: >-
            Slot index (2 or higher; slot 1 is the implicit default slot and is
            not listed)
        name:
          type: string
          nullable: true
          description: >-
            Optional display name. Names are labels only; slots are addressed by
            index
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: API key for authentication

````