> ## 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 Shared Step

> Create a new shared step collection.

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

Create a new shared step collection in your project. Once created, the
collection can be referenced from any verification test by adding a
`{ "type": "collection", "collection_id": "..." }` item.

## Request Body

<ParamField body="shared_step" type="object" required>
  Shared step definition

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

    <ParamField body="shared_step.name" type="string" required>
      Collection name
    </ParamField>

    <ParamField body="shared_step.steps_by_key" type="object" required>
      Map of step key → step body. Same shape as in test cases. Use
      `expected_results` for the step's checks (a string, a list of strings, or
      a list of `{ "expected": "..." }` objects); the legacy single-string
      `finish_condition` is still accepted and ignored when `expected_results`
      is present.
    </ParamField>

    <ParamField body="shared_step.step_order" type="string[]" required>
      Ordered list of step keys
    </ParamField>
  </Expandable>
</ParamField>

## Response

Returns the newly created shared step with status `201`. Same shape as
[Get Shared Step](/api-reference/shared-steps/get-shared-step).

<RequestExample>
  ```bash cURL theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  curl -X POST "https://nunu.ai/api/v1/project/your-project-id/shared-steps" \
    -H "X-Api-Key: YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "shared_step": {
        "name": "Login Flow",
        "steps_by_key": {
          "1": {
            "goal": "Open login screen",
            "expected_results": [
              { "expected": "login fields are visible" }
            ],
            "screenshots": 1,
            "pause_game": false,
            "performance_monitoring": false,
            "hint_manual": []
          }
        },
        "step_order": ["1"]
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  {
    "id": "ssc_abc123",
    "project_id": "test",
    "name": "Login Flow",
    "version": 0,
    "is_shared": true,
    "created_at": null,
    "created_by": null,
    "steps_by_key": { "1": { "...": "..." } },
    "step_order": ["1"]
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /project/{projectId}/shared-steps
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}/shared-steps:
    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:
        - Shared Steps
      summary: Create Shared Step
      description: Create a new shared step collection.
      operationId: createSharedStep
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSharedStepRequest'
      responses:
        '201':
          description: Shared step created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SharedStep'
        '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:
    CreateSharedStepRequest:
      type: object
      required:
        - shared_step
      properties:
        shared_step:
          type: object
          required:
            - name
            - steps_by_key
            - step_order
          properties:
            id:
              type: string
              description: Optional - generated if omitted
            name:
              type: string
            steps_by_key:
              type: object
              additionalProperties: true
            step_order:
              type: array
              items:
                type: string
    SharedStep:
      type: object
      properties:
        id:
          type: string
        project_id:
          type: string
        name:
          type: string
        version:
          type: integer
        is_shared:
          type: boolean
        created_at:
          type: string
          format: date-time
          nullable: true
        created_by:
          type: string
          nullable: true
        steps_by_key:
          type: object
          additionalProperties: true
        step_order:
          type: array
          items:
            type: string
    Error:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
        details:
          type: object
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: API key for authentication

````