# Get Latest Scans

Get the most recent successful scan for each product/subproduct of a target variant. A single product can emit multiple subproducts (e.g. SnykCode vs snykContainer), each of which is a distinct scan stream, so the result is an array with the latest succeeded scan per (product, subproduct). The optional productId and subproduct query params narrow the result to a single product and/or subproduct. Used by scanners needing previous scan context and by UIs to show latest scan status.

Endpoint: GET /sto/api/v2/scans/latest
Version: 1.0
Security: 

## Query parameters:

  - `accountId` (string, required)
    Harness Account ID
    Example: "abcdef1234567890ghijkl"

  - `targetVariantId` (string, required)
    The Target Variant ID
    Example: "abcdefghijkl1234567890"

  - `productId` (string)
    Optional Product ID (scanner) filter. When omitted, the latest scan for every product of the target variant is returned.
    Example: "abcdefghijkl1234567890"

  - `subproduct` (string)
    Optional subproduct filter to disambiguate scans within a product (e.g. SnykCode vs snykContainer). When omitted, the latest scan for every subproduct is returned.
    Example: "SnykCode"

## Header parameters:

  - `X-Api-Key` (string)
    Harness personal or service access token
    Example: "Voluptas mollitia nisi blanditiis nesciunt exercitationem."

## Response 200 fields (application/json):

  - `scans` (array, required)
    Latest succeeded scan per (product, subproduct), optionally narrowed by the productId and subproduct filters
    Example: [{"codeCoverage":65.5,"created":1651578240,"executionId":"abcdef1234567890ghijkl","gitMetadata":{"commit":"0000000000000000000000000000000000000001","detectedName":"Assumenda repellendus neque nostrum autem dolor.","detectedVariant":"Quam iure corrupti non cupiditate.","droneCorrelated":false,"provider":"Voluptatibus consequatur.","pullRequestNumber":11,"repositoryHttp":"https://github.com/harness/drone-cli.git","repositoryPath":["Earum sed in neque nihil ut incidunt.","Magnam ratione vero a."],"repositorySsh":"git@github.com:harness/drone-cli.git","sourceBranch":"feat/shiny-object","targetBranch":"develop","workspace":"/harness"},"id":"abcdef1234567890ghijkl","lastModified":1651578240,"metadata":{"baseImageDigest":"sha256:abcdef1234567890ghijkl","baseImageName":"my-image","baseImageTag":"1.0.0"},"orgId":"your_harness_org","pipelineId":"your_harness_pipeline","productId":"product111111111111111","productName":"snyk","productPrettyName":"Snyk","projectId":"your_harness_project","refinementVersion":"1.0.5","scannerDiffKey":"sast","stageId":"stage_id","status":"Succeeded","stepId":"step_id","subproduct":"owasp","targetVariantId":"variant111111111111111"},{"codeCoverage":65.5,"created":1651578240,"executionId":"abcdef1234567890ghijkl","gitMetadata":{"commit":"0000000000000000000000000000000000000001","detectedName":"Assumenda repellendus neque nostrum autem dolor.","detectedVariant":"Quam iure corrupti non cupiditate.","droneCorrelated":false,"provider":"Voluptatibus consequatur.","pullRequestNumber":11,"repositoryHttp":"https://github.com/harness/drone-cli.git","repositoryPath":["Earum sed in neque nihil ut incidunt.","Magnam ratione vero a."],"repositorySsh":"git@github.com:harness/drone-cli.git","sourceBranch":"feat/shiny-object","targetBranch":"develop","workspace":"/harness"},"id":"abcdef1234567890ghijkl","lastModified":1651578240,"metadata":{"baseImageDigest":"sha256:abcdef1234567890ghijkl","baseImageName":"my-image","baseImageTag":"1.0.0"},"orgId":"your_harness_org","pipelineId":"your_harness_pipeline","productId":"product111111111111111","productName":"snyk","productPrettyName":"Snyk","projectId":"your_harness_project","refinementVersion":"1.0.5","scannerDiffKey":"sast","stageId":"stage_id","status":"Succeeded","stepId":"step_id","subproduct":"owasp","targetVariantId":"variant111111111111111"},{"codeCoverage":65.5,"created":1651578240,"executionId":"abcdef1234567890ghijkl","gitMetadata":{"commit":"0000000000000000000000000000000000000001","detectedName":"Assumenda repellendus neque nostrum autem dolor.","detectedVariant":"Quam iure corrupti non cupiditate.","droneCorrelated":false,"provider":"Voluptatibus consequatur.","pullRequestNumber":11,"repositoryHttp":"https://github.com/harness/drone-cli.git","repositoryPath":["Earum sed in neque nihil ut incidunt.","Magnam ratione vero a."],"repositorySsh":"git@github.com:harness/drone-cli.git","sourceBranch":"feat/shiny-object","targetBranch":"develop","workspace":"/harness"},"id":"abcdef1234567890ghijkl","lastModified":1651578240,"metadata":{"baseImageDigest":"sha256:abcdef1234567890ghijkl","baseImageName":"my-image","baseImageTag":"1.0.0"},"orgId":"your_harness_org","pipelineId":"your_harness_pipeline","productId":"product111111111111111","productName":"snyk","productPrettyName":"Snyk","projectId":"your_harness_project","refinementVersion":"1.0.5","scannerDiffKey":"sast","stageId":"stage_id","status":"Succeeded","stepId":"step_id","subproduct":"owasp","targetVariantId":"variant111111111111111"}]

  - `scans.codeCoverage` (number)
    The Code Coverage value for the Scan
    Example: 65.5

  - `scans.created` (integer, required)
    Unix timestamp at which the resource was created
    Example: 1651578240

  - `scans.executionId` (string, required)
    Pipeline Execution ID associated with the Scan
    Example: "abcdef1234567890ghijkl"

  - `scans.gitMetadata` (object)
    Git Metadata associated with the Scan
    Example: {"commit":"0000000000000000000000000000000000000001","detectedName":"Fugit repellat officia ratione omnis.","detectedVariant":"Molestiae molestiae.","droneCorrelated":false,"provider":"Voluptatem qui recusandae illum molestiae.","pullRequestNumber":11,"repositoryHttp":"https://github.com/harness/drone-cli.git","repositoryPath":["Nisi et.","Autem eaque eius quia.","In sapiente placeat aliquam alias maiores.","Ex quaerat."],"repositorySsh":"git@github.com:harness/drone-cli.git","sourceBranch":"feat/shiny-object","targetBranch":"develop","workspace":"/harness"}

  - `scans.gitMetadata.commit` (string)
    Git Commit SHA scanned
    Example: "0000000000000000000000000000000000000001"

  - `scans.gitMetadata.detectedName` (string)
    Detected Name
    Example: "Fugit repellat officia ratione omnis."

  - `scans.gitMetadata.detectedVariant` (string)
    Detected Variant
    Example: "Molestiae molestiae."

  - `scans.gitMetadata.droneCorrelated` (boolean)
    Drone Correlated

  - `scans.gitMetadata.provider` (string)
    Git Provider
    Example: "Voluptatem qui recusandae illum molestiae."

  - `scans.gitMetadata.pullRequestNumber` (integer)
    Git Pull Request Number
    Example: 11

  - `scans.gitMetadata.repositoryHttp` (string)
    Git HTTP Repository
    Example: "https://github.com/harness/drone-cli.git"

  - `scans.gitMetadata.repositoryPath` (array)
    Git Repository Path
    Example: ["Nisi et.","Autem eaque eius quia.","In sapiente placeat aliquam alias maiores.","Ex quaerat."]

  - `scans.gitMetadata.repositorySsh` (string)
    Git SSH Repository
    Example: "git@github.com:harness/drone-cli.git"

  - `scans.gitMetadata.sourceBranch` (string)
    Git Source Branch
    Example: "feat/shiny-object"

  - `scans.gitMetadata.targetBranch` (string)
    Git Target Branch
    Example: "develop"

  - `scans.gitMetadata.workspace` (string)
    Git Workspace Root
    Example: "/harness"

  - `scans.id` (string, required)
    Resource identifier
    Example: "abcdef1234567890ghijkl"

  - `scans.lastModified` (integer, required)
    Unix timestamp at which the resource was most recently modified
    Example: 1651578240

  - `scans.metadata` (object)
    Metadata specific to the entity being scanned
    Example: {"baseImageDigest":"sha256:1234567890abcdefghijkl","baseImageName":"alpine","baseImageTag":"3.18","buildId":"222","deduplicatedCount":80,"executionSource":"jenkins","executionUrl":"https://qa.harness.io/ng/account/acct/ci/orgs/default/projects/STO/pipelines/p/executions/e/pipeline","honorGracePeriod":true,"imageDomain":"docker.io","imageName":"my-application","imageTag":"v1.2.3","ingestToolSeverityFlag":true,"normalizedCount":100,"polyglotScanId":"413","scanConfig":"oss","scannerConsoleUrl":"https://app.shiftleft.io/apps/myapp/summary?scan=12345"}

  - `scans.metadata.baseImageDigest` (string)
    Digest of the base image
    Example: "sha256:1234567890abcdefghijkl"

  - `scans.metadata.baseImageName` (string)
    Name of the base image
    Example: "alpine"

  - `scans.metadata.baseImageTag` (string)
    Tag of the base image
    Example: "3.18"

  - `scans.metadata.buildId` (string)
    CI build/sequence id for the run that produced this scan (Harness HARNESS_BUILD_ID / ; non-Harness BUILD_ID). Not a product/scanner build id.
    Example: "222"

  - `scans.metadata.deduplicatedCount` (integer)
    Total number of deduplicated issues found in the scan
    Example: 80

  - `scans.metadata.executionSource` (string)
    CI/CD platform that ran the scan (harness, jenkins, github_actions, gitlab_ci, ...)
    Example: "jenkins"

  - `scans.metadata.executionUrl` (string)
    URL of the CI execution that orchestrated the scan (Harness DRONE_BUILD_LINK, Jenkins/GHA BUILD_URL)
    Example: "https://qa.harness.io/ng/account/acct/ci/orgs/default/projects/STO/pipelines/p/executions/e/pipeline"

  - `scans.metadata.honorGracePeriod` (boolean)
    Honor vendor-issued grace period when bucketing issue counts (Prisma/Twistlock only)
    Example: true

  - `scans.metadata.imageDomain` (string)
    Domain of the container image registry
    Example: "docker.io"

  - `scans.metadata.imageName` (string)
    Name of the container image
    Example: "my-application"

  - `scans.metadata.imageTag` (string)
    Tag of the container image
    Example: "v1.2.3"

  - `scans.metadata.ingestToolSeverityFlag` (boolean)
    Scan ran with ingest_tool_severity enabled in the pipeline
    Example: true

  - `scans.metadata.normalizedCount` (integer)
    Total number of normalized issues found in the scan
    Example: 100

  - `scans.metadata.polyglotScanId` (string)
    ShiftLeft/Qwiet polyglot scan ID for SCA package lookups
    Example: "413"

  - `scans.metadata.scanConfig` (string)
    Scan configuration selected for this scan (e.g. default, oss, code, iac)
    Example: "oss"

  - `scans.metadata.scannerConsoleUrl` (string)
    URL to view scan results in the scanner's console
    Example: "https://app.shiftleft.io/apps/myapp/summary?scan=12345"

  - `scans.orgId` (string, required)
    Harness Organization ID
    Example: "your_harness_org"

  - `scans.pipelineId` (string, required)
    Harness Organization ID
    Example: "your_harness_pipeline"

  - `scans.productId` (string, required)
    The Scan Product used for the Scan
    Example: "product111111111111111"

  - `scans.productName` (string)
    The machine name of the Scan Product (scanner), e.g. snyk. Optional; populated by endpoints that join the product table.
    Example: "snyk"

  - `scans.productPrettyName` (string)
    The human-readable display name of the Scan Product (scanner), e.g. Snyk. Optional; populated by endpoints that join the product table.
    Example: "Snyk"

  - `scans.projectId` (string, required)
    Harness Project ID
    Example: "your_harness_project"

  - `scans.refinementVersion` (string, required)
    The Issue refinement version used for this Scan
    Example: "1.0.5"

  - `scans.scannerDiffKey` (string)
    Key used to differentiate scanner configurations for scan comparison (e.g. sast, sca, sast_sca)
    Example: "sast"

  - `scans.stageId` (string, required)
    Pipeline Stage ID associated with the Scan
    Example: "stage_id"

  - `scans.status` (string, required)
    Current status of the Scan
    Enum: "Pending", "Running", "Succeeded", "Failed"

  - `scans.stepId` (string, required)
    Pipeline Step ID associated with the Scan
    Example: "step_id"

  - `scans.subproduct` (string)
    The Scan Subproduct used for the Scan
    Example: "owasp"

  - `scans.targetVariantId` (string, required)
    The Target Variant associated with the Scan
    Example: "variant111111111111111"

## Response 400 fields (application/json):

  - `message` (string, required)
    Example: "Not Found"

  - `status` (integer)
    Example: 404


