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

# Mark P4 import as stopped

> Mark the Perforce import job as no longer running by clearing the running_job_id and started_unix timestamp. This should be called when a continuous import job completes or stops. The job will only be marked as stopped if the current running_job_id matches the one in the database to prevent race conditions.



## OpenAPI

````yaml post /repos/{repo_id}/p4-import-state/mark-stopped
openapi: 3.0.3
info:
  title: Diversion Core API
  description: >-
    Definition of the Core API used to access low-level functionality of
    Diversion
  version: 0.2.0
servers:
  - url: https://api.diversion.dev/v0
    description: Base endpoint
security: []
paths:
  /repos/{repo_id}/p4-import-state/mark-stopped:
    parameters:
      - $ref: '#/components/parameters/RepoParam'
    post:
      tags:
        - Perforce Repository Import
      summary: Mark P4 import as stopped
      description: >-
        Mark the Perforce import job as no longer running by clearing the
        running_job_id and started_unix timestamp. This should be called when a
        continuous import job completes or stops. The job will only be marked as
        stopped if the current running_job_id matches the one in the database to
        prevent race conditions.
      operationId: src.handlersv2.p4_import.mark_job_stopped
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/P4ImportJobResult'
      responses:
        '204':
          $ref: '#/components/responses/OKEmpty'
          description: Job marked as stopped successfully
        '400':
          $ref: '#/components/responses/BadRequest'
          description: Bad request - invalid `job_id`
        '404':
          $ref: '#/components/responses/NotFound'
          description: Repository not found or no import job configured
        default:
          $ref: '#/components/responses/Error'
      security:
        - OAuth2:
            - coreapi/write
components:
  parameters:
    RepoParam:
      in: path
      name: repo_id
      required: true
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      description: >-
        The repo ID of the repository. Repo _name_ can be used instead of the
        ID, but usage of ID for permanent linking and API requests is preferred.
  schemas:
    P4ImportJobResult:
      type: object
      description: Details of a Perforce continuous import job
      properties:
        last_changelist:
          type: integer
          description: Last Perforce changelist number that was imported
          minimum: 0
        last_import_unix:
          type: integer
          description: Unix timestamp of the last successful import
          nullable: true
        running_job_id:
          type: string
          description: ID of the currently running import job, if any
          nullable: true
        error_count:
          type: integer
          description: Number of consecutive errors encountered
          default: 0
        last_error:
          type: string
          description: Last error message encountered during import
          nullable: true
        last_error_unix:
          type: integer
          description: Unix timestamp of the last error
          nullable: true
    Error:
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code
        detail:
          type: string
        title:
          type: string
        type:
          type: string
      required:
        - status
        - detail
  responses:
    OKEmpty:
      description: Request completed successfully
    BadRequest:
      description: The request does not meet the required conditions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error:
      description: An error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    OAuth2:
      type: oauth2
      x-tokenInfoFunc: src.token_info.token_auth
      description: This API uses OAuth 2 with the implicit grant flow
      flows:
        implicit:
          authorizationUrl: https://auth.diversion.dev/oauth2/authorize
          scopes:
            coreapi/read: Operations with no possible side-effects
            coreapi/write: Modifying operations
            coreapi/admin: >-
              Organizational operations like adding a repo or changing repo
              properties

````