---
schema_version: "1"
id: 1cdc1bd163106dbdf45c844af659be37df68fa6720cf60b9e800a670644f7f90
title: package version retrieve
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfclireference/guides/package/cli_reference_package_version_retrieve.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_package_version_retrieve.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: ac32cea121d90b5531d8a6b3b366e9d31d4d8f35b379427588db3dfd032f4bde
products:
  - Salesforce CLI Command Reference
  - salesforcedx
---
<!-- prettier-ignore-start -->

# package version retrieve

Retrieve package metadata for a specified package version. Package metadata can be retrieved for only second-generation managed package versions or unlocked packages.

## Description for package version retrieve

Retrieving a package version downloads the metadata into the directory you specify.

When you run this command, specify the subscriber package version ID (starts with 04t) and the path to an empty directory.

By default, the package version retrieve command is available to 2GP managed packages that were converted from 1GP. To use this command with a managed package created using 2GP (not converted from 1GP) or with an unlocked package, specify IsDevUsePkgZipRequested = true in the Package2VersionCreateRequest Tooling API object. If you run this command and the zip folder with the package version’s source files is missing, confirm that IsDevUsePkgZipRequested is set to true.

## Flags

| Flag Name (Long) | Flag Name (Short) | Description |
|------------------|-------------------|-------------|
| <code>&#8209;&#8209;api&#8209;version</code> | N/A | **Type:** Value<br><br>Override the api version used for api requests made by this command |
| <code>&#8209;&#8209;flags&#8209;dir</code> | N/A | **Type:** Value<br><br>Import flag values from a directory. |
| <code>&#8209;&#8209;json</code> | N/A | **Type:** Boolean<br><br>Format output as json. |
| <code>&#8209;&#8209;output&#8209;dir</code> | <code>&#8209;d</code> | **Type:** Value<br>**Default value:** `force-app`<br><br>Path within your Salesforce DX project directory in which to download the metadata. This directory must be empty. |
| <code>&#8209;&#8209;package</code> | <code>&#8209;p</code> | **Type:** Value<br>**Required**<br><br>Subscriber package version ID (starts with 04t). |
| <code>&#8209;&#8209;target&#8209;dev&#8209;hub</code> | <code>&#8209;v</code> | **Type:** Value<br>**Required**<br><br>Username or alias of the Dev Hub org. Not required if the `target-dev-hub` configuration variable is already set. |

## Examples for package version retrieve

Retrieve package metadata for a converted subscriber package version ID (starts with 04t) into my-directory/ within your Salesforce DX project directory:

```shell
sf package version retrieve --package 04tXXX --output-dir my-directory/ --target-dev-hub devhub@example.com
```
<!-- prettier-ignore-end -->
