---
title: "Sync Project to SCM"
method: POST
path: "/api/agent/deployments/{deploymentId}/repos/{repoId}/_sync"
tags: ["ProjectsService"]
---

# Sync Project to SCM

`POST /api/agent/deployments/{deploymentId}/repos/{repoId}/_sync`

Schedules a job to sync a project with its SCM.

## Path parameters

- `deploymentId` string, required
- `repoId` string, required

## Request body

- ProtosProjectsV1SyncRepoRequest
  - `deploymentId` string
  - `repoId` string

## Response `202`

Accepted

- ProtosProjectsV1SyncRepoResponse
  - `repo` ProtosProjectsV1Repository
    - `id` string — The unique identifier for the repository in the database
    - `name` string — The name of this repository in Semgrep
    - `tags` string[] — The tags that have been applied to this repository
    - `provisionedAt` string, date-time — When this repository was first set up
    - `latestScan` ProtosScanV1ScanSummary
      - `id` string — ID of the scan
      - `startedAt` string, date-time — when the scan was started
      - `completedAt` string, date-time — when the scan was completed
      - `exitCode` string — scan exit code, can be negative
      - `hasLogs` boolean — if the scan has logs that are stored by Semgrep (SMS only)
      - `status` 'SCAN_STATUS_RUNNING' | 'SCAN_STATUS_COMPLETED' | 'SCAN_STATUS_PENDING' | 'SCAN_STATUS_CANCELLED' | 'SCAN_STATUS_ERROR' | 'SCAN_STATUS_NEVER_FINISHED', enum — scan status | value | description | |-------|---------------| | SCAN_STATUS_RUNNING | The scan is currently running | | SCAN_STATUS_COMPLETED | The scan has completed successfully (0 or 1 exit code) | | SCAN_STATUS_PENDING | The scan is queued and waiting to start | | SCAN_STATUS_CANCELLED | The scan was cancelled before completion | | SCAN_STATUS_ERROR | The scan has exited with a failure (exit code not 0 or 1) | | SCAN_STATUS_NEVER_FINISHED | The scan did not report an error or success after over an hour |
      - `isManagedScanPlaceholder` boolean — True when this summary was synthesized from a ManagedScan row because no backing Scan row exists yet (managed scan failed before the CLI ran). Mirrors `Scan.is_managed_scan_placeholder`. When true, `id == 0`.
      - `aiFailureReason` 'AI_SCAN_JOB_FAILURE_REASON_GIT_BRANCH_NOT_FOUND' | 'AI_SCAN_JOB_FAILURE_REASON_GIT_UNAUTHORIZED' | 'AI_SCAN_JOB_FAILURE_REASON_TIMED_OUT' | 'AI_SCAN_JOB_FAILURE_REASON_INTERNAL_ERROR' | 'AI_SCAN_JOB_FAILURE_REASON_GIT_TRANSIENT_ERROR' | 'AI_SCAN_JOB_FAILURE_REASON_GIT_UPSTREAM_UNAVAILABLE' | 'AI_SCAN_JOB_FAILURE_REASON_BUDGET_EXCEEDED', enum — The reason an AI scan job failed, when the scan was stopped by the AI scanning pipeline (e.g. the free-tier AI scan budget was exceeded). | value | description | |-------|---------------| | AI_SCAN_JOB_FAILURE_REASON_GIT_BRANCH_NOT_FOUND | | | AI_SCAN_JOB_FAILURE_REASON_GIT_UNAUTHORIZED | | | AI_SCAN_JOB_FAILURE_REASON_TIMED_OUT | | | AI_SCAN_JOB_FAILURE_REASON_INTERNAL_ERROR | | | AI_SCAN_JOB_FAILURE_REASON_GIT_TRANSIENT_ERROR | | | AI_SCAN_JOB_FAILURE_REASON_GIT_UPSTREAM_UNAVAILABLE | | | AI_SCAN_JOB_FAILURE_REASON_BUDGET_EXCEEDED | |
    - `deploymentId` string — The deployment_id that owns this repository and its scans
    - `url` string — The URL for this repository (in an SCM like GitHub)
    - `ignoredFiles` string[] — The list of files NOT to scan in this repository, if not the default
    - `productIgnoredFiles` ProtosProjectsV1ProductIgnoredFilesMap
      - `sast` string[]
      - `sca` string[]
      - `secrets` string[]
    - `firstScanId` string — The unique identifier of the first scan of this repository, if it exists
    - `isArchived` boolean — Deprecated: use is_scm_archived instead.
    - `isDisconnected` boolean — Whether or not this repository has been disconnected from the SCM
    - `hasCodeAccess` boolean — Whether or not code access has been granted for this repository
    - `managedScans` ProtosProjectsV1ManagedScanSettings
      - `diffScan` boolean
      - `numConfigs` integer
      - `fullScan` boolean
    - `isSetup` boolean — Whether or not the repository seems set up for Semgrep scanning of some kind
    - `scmLastSyncedAt` number, float — Deprecated: no longer populated
    - `authorizedScopes` string[] — For users with RBAC, the permissions available to this user on this repo | value | description | |-------|---------------| | REPO_SCOPE_READ_FINDING | Can read findings from the repo | | REPO_SCOPE_TRIAGE_FINDING | Can triage findings from the repo | | REPO_SCOPE_MANAGE_PROJECT_SETTINGS | Can view and modify project settings | | REPO_SCOPE_AUTOINSTALL | Can tell semgrep to 'provision' the repo by committing a CI config file | | REPO_SCOPE_DELETE_PROJECT | Indicates that the user can delete the repo | | REPO_SCOPE_ASSIGN_TEAM | Indicates that the user can assign the project to an RBAC team |
    - `provider` 'PROVIDER_GITHUB', enum — The SCM for this user (TODO: there must be a better version of this supporting more than GitHub) | value | description | |-------|---------------| | PROVIDER_GITHUB | |
    - `defaultBranch` string — The name of the default branch (Deprecated: this has been replaced with default_ref_info)
    - `refs` ProtosProjectsV1RepositoryRefItem[] — All of the scanned refs for this project
      - `repoRefId` string
      - `ref` string
      - `isDefault` boolean
      - `isPrimary` boolean
    - `primaryRef` ProtosProjectsV1PrimaryRefItem — TODO: reuse RepositoryRefItem for this
      - `id` string
      - `ref` string
      - `isOverride` boolean
    - `defaultRef` ProtosProjectsV1SimpleRefItem — TODO: reuse RepositoryRefItem for this
      - `id` string
      - `ref` string
    - `lastScannedRef` ProtosProjectsV1SimpleRefItem — TODO: reuse RepositoryRefItem for this
      - `id` string
      - `ref` string
    - `latestFullScaScanParserErrors` ProtosScaV1DependencyParserErrors
      - `errors` ProtosScaV1DependencyParserError[]
        - `location` ProtosScaV1CodeLocation — Specific location in a file.
          - `path` string — Path to a file.
          - `startLine` string — Starting line number (1 indexed).
          - `startCol` string — Starting column number (1 indexed).
          - `endLine` string — Ending line number (1 indexed).
          - `endCol` string — Ending column number (1 indexed).
          - `url` string — URL to code location if available, otherwise empty.
          - `committedAt` string, date-time — Timestamp when code file was last modified, if available.
        - `reason` string
        - `parser` string
        - `text` string
    - `latestFullScaScanAt` string, date-time — when the last full SCA scan was completed
    - `scaInfo` ProtosProjectsV1ScaInfo
      - `dependencyCounts` object — a map from file name to the number of dependencies
    - `linkedRepos` string[] — ids of possible duplicate repos, if is is requested
    - `scmType` 'SCM_TYPE_GITHUB' | 'SCM_TYPE_GITHUB_ENTERPRISE' | 'SCM_TYPE_GITLAB' | 'SCM_TYPE_GITLAB_SELFMANAGED' | 'SCM_TYPE_BITBUCKET' | 'SCM_TYPE_BITBUCKET_DATACENTER' | 'SCM_TYPE_AZURE_DEVOPS' | 'SCM_TYPE_UNKNOWN' | 'SCM_TYPE_HARNESS', enum — The SCM type | value | description | |-------|---------------| | SCM_TYPE_GITHUB | GitHub Cloud | | SCM_TYPE_GITHUB_ENTERPRISE | GitHub Enterprise | | SCM_TYPE_GITLAB | GitLab Cloud | | SCM_TYPE_GITLAB_SELFMANAGED | GitLab Self-Managed | | SCM_TYPE_BITBUCKET | Bitbucket Cloud | | SCM_TYPE_BITBUCKET_DATACENTER | Bitbucket Data Center | | SCM_TYPE_AZURE_DEVOPS | Azure DevOps | | SCM_TYPE_UNKNOWN | | | SCM_TYPE_HARNESS | Harness |
    - `repositoryScmLinkId` string — The unique id of the SCM repository in Semgrep
    - `tokenScopes` ProtosScmV1ScmTokenScopes
      - `readMetadata` boolean
      - `readPullRequest` boolean
      - `writePullRequestComment` boolean
      - `readContents` boolean
      - `readMembers` boolean
      - `manageWebhooks` boolean
      - `writeContents` boolean
      - `writePullRequest` boolean
    - `cloudContext` ProtosCloudContextV1CloudContext
      - `id` string
      - `cnappInstallationId` string
      - `cnappInstallationBaseUrl` string
      - `source` 'CLOUD_CONTEXT_SOURCE_MANUAL' | 'CLOUD_CONTEXT_SOURCE_PALO_ALTO_NETWORKS' | 'CLOUD_CONTEXT_SOURCE_SYSDIG', enum — | value | description | |-------|---------------| | CLOUD_CONTEXT_SOURCE_MANUAL | | | CLOUD_CONTEXT_SOURCE_PALO_ALTO_NETWORKS | | | CLOUD_CONTEXT_SOURCE_SYSDIG | |
      - `isDeployed` boolean
      - `publicExposure` boolean
      - `lastSuccessfulIngestionCompletedAt` string, date-time
    - `aiScans` ProtosProjectsV1AiScanSettings
      - `fullScan` boolean
    - `isScmArchived` boolean — Whether or not this repository has been archived in the SCM
    - `isSemgrepArchived` boolean — Whether or not this repository has been archived in Semgrep
    - `archivedAt` string, date-time — When this repository was archived in Semgrep

---

[API](https://skmtc.net/semgrep/apis/semgrep-web-app.md) · [All operations](https://skmtc.net/semgrep/apis/semgrep-web-app/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/semgrep/semgrep-web-app/versions/6483eeecd582/schema)
