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

# Stop Runs

> Stop one or more running tests. Only jobs belonging to your project will be stopped.

<Info>
  **Permission Required**: `project:operate-runs`
</Info>

Stop one or more running tests. Only jobs belonging to your project will be stopped.

## Request Body

<ParamField body="job_ids" type="string[]" required>
  Array of job IDs to stop (minimum 1). Job IDs are returned when you [start a run](/api-reference/runs/start-run).
</ParamField>

## Response

<ResponseField name="ok" type="boolean" required>
  `true` if all jobs stopped successfully
</ResponseField>

<ResponseField name="message" type="string" required>
  Human-readable summary (e.g., "Successfully stopped 2 job(s)")
</ResponseField>

<ResponseField name="received_count" type="integer" required>
  Number of job IDs provided in the request
</ResponseField>

<ResponseField name="stopped_count" type="integer" required>
  Number of jobs actually stopped
</ResponseField>

<ResponseField name="results" type="Result[]" required>
  Per-job results

  <Expandable title="result properties">
    <ResponseField name="job_id" type="string" required>
      The job ID
    </ResponseField>

    <ResponseField name="ok" type="boolean" required>
      Whether this job was stopped successfully
    </ResponseField>

    <ResponseField name="status" type="integer" required>
      HTTP status code for this operation
    </ResponseField>

    <ResponseField name="message" type="string">
      Success message (when `ok: true`)
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message (when `ok: false`)
    </ResponseField>
  </Expandable>
</ResponseField>

<Warning>
  Stopping a run will terminate it immediately. Any in-progress test steps will be marked as incomplete.
</Warning>

<RequestExample>
  ```bash cURL theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  curl -X POST "https://nunu.ai/api/v1/project/your-project-id/runs/stop" \
    -H "X-Api-Key: YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "job_ids": ["f80f6230-3a4f-431a-9d55-d11b867fed4e"]
    }'
  ```

  ```typescript JavaScript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  const response = await fetch("https://nunu.ai/api/v1/project/your-project-id/runs/stop", {
    method: "POST",
    headers: {
      "X-Api-Key": process.env.NUNU_API_TOKEN,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      job_ids: ["f80f6230-3a4f-431a-9d55-d11b867fed4e"],
    }),
  });
  const data = await response.json();
  ```

  ```python Python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  import requests
  import os

  response = requests.post(
      "https://nunu.ai/api/v1/project/your-project-id/runs/stop",
      headers={
          "X-Api-Key": os.environ["NUNU_API_TOKEN"],
          "Content-Type": "application/json"
      },
      json={
          "job_ids": ["f80f6230-3a4f-431a-9d55-d11b867fed4e"]
      }
  )
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  {
    "ok": true,
    "message": "Successfully stopped 2 job(s)",
    "received_count": 2,
    "stopped_count": 2,
    "results": [
      {
        "job_id": "f80f6230-3a4f-431a-9d55-d11b867fed4e",
        "ok": true,
        "status": 200,
        "message": "Job stopped"
      },
      {
        "job_id": "0a9f9c52-8917-4f47-bb72-b0093c200bed",
        "ok": true,
        "status": 200,
        "message": "Job stopped"
      }
    ]
  }
  ```

  ```json 207 Partial Success theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  {
    "ok": false,
    "message": "Stopped 1/2 job(s)",
    "received_count": 2,
    "stopped_count": 1,
    "results": [
      {
        "job_id": "f80f6230-3a4f-431a-9d55-d11b867fed4e",
        "ok": true,
        "status": 200,
        "message": "Job stopped"
      },
      {
        "job_id": "0a9f9c52-8917-4f47-bb72-b0093c200bed",
        "ok": false,
        "status": 500,
        "error": "Job already completed"
      }
    ]
  }
  ```

  ```json 404 Not Found theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  {
    "error": "no jobs found in your project matching the provided IDs"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /project/{projectId}/runs/stop
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}/runs/stop:
    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:
        - Runs
      summary: Stop Runs
      description: >-
        Stop one or more running tests. Only jobs belonging to your project will
        be stopped.
      operationId: stopRuns
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StopRunsRequest'
      responses:
        '200':
          description: All jobs stopped successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StopRunsResponse'
        '207':
          description: Partial success - some jobs failed to stop
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StopRunsResponse'
        '404':
          description: No jobs found matching the provided IDs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    StopRunsRequest:
      type: object
      properties:
        job_ids:
          type: array
          items:
            type: string
          minItems: 1
          description: Array of job IDs to stop
      required:
        - job_ids
    StopRunsResponse:
      type: object
      properties:
        ok:
          type: boolean
        message:
          type: string
        received_count:
          type: integer
        stopped_count:
          type: integer
        results:
          type: array
          items:
            type: object
            properties:
              job_id:
                type: string
              ok:
                type: boolean
              status:
                type: integer
              message:
                type: string
              error:
                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

````