---
title: "Get Perforce import state"
method: GET
path: "/repos/{repo_id}/p4-import-state"
tags: ["Perforce Repository Import"]
---

# Get Perforce import state

`GET /repos/{repo_id}/p4-import-state`

## Request

- Base URL: `https://api.diversion.dev/v0`
- URL: `https://api.diversion.dev/v0/repos/{repo_id}/p4-import-state`
- Auth: OAuth 2
  - Implicit: `https://auth.diversion.dev/oauth2/authorize`
  - Scopes: `coreapi/read`
- TypeScript: <https://skmtc.dev/diversion/apis/diversion-core-api/docs/repos/:repo_id/p4-import-state/get.ts> (a function with typed inputs; its response is checked against the schema)

Retrieve the current state of the continuous Perforce import job for this repository, including the last imported changelist, error information, and running status.

## Query parameters

- `branch_ref` string
- `p4_import_path` string

## Response `200`

Import state retrieved successfully

- P4ImportState: Current state of the Perforce continuous import job
  - `last_changelist` integer, required: Last Perforce changelist number that was imported
  - `last_import_unix` integer, nullable: Unix timestamp of the last successful import
  - `running_job_id` string, nullable: ID of the currently running import job, if any
  - `error_count` integer, required: Number of consecutive errors encountered
  - `last_error` string, nullable: Last error message encountered during import
  - `last_error_unix` integer, nullable: Unix timestamp of the last error
  - `branch_ref` string, required: reference name of the branch being synced
  - `p4_import_path` string, required: Perforce depot path being imported (e.g., //depot/main/...)
  - `started_unix` integer, nullable: Unix timestamp when the current job started running

## Other responses

- `400`: The request does not meet the required conditions
- `404`: The specified resource was not found
- `default`: An error occurred

---

[API](https://skmtc.dev/diversion/apis/diversion-core-api.md) - [All operations](https://skmtc.dev/diversion/apis/diversion-core-api/llms.txt) - [OpenAPI document](https://skmtc.dev/diversion/apis/diversion-core-api/revisions/38a18aba804b?raw)
