
1Password CLI
Load secrets into environment variables, configuration files, and scripts.
1Password SDKs
Programmatically access your secrets with Go, JavaScript, and Python.
Secrets Automation
Use secret references to secure your secrets management workflows.
VS Code
Create, preview, and read secret references in your code.
1Password integrations
Securely access your secrets in Kubernetes, CircleCI, GitHub Actions, Jenkins, Terraform, Pulumi, Postman, and more.
Get secret references
With the 1Password desktop app
To see the option to copy secret references in the 1Password desktop app, first turn on the integration with 1Password CLI. Then:
- Open the item where the secret you want to reference is stored.
- Select next to the field that contains the secret you want to reference, then select Copy Secret Reference.

With 1Password for VS Code
You can use 1Password for VS Code to insert secret references from 1Password as you edit your code. First, install the extension. Then:- Open the Command Palette .
- Enter
1Password: Get from 1Password. - Enter the item name or ID.
- Select the field to use.
With 1Password CLI
To get a secret reference with 1Password CLI, runop item get with the --format json flag and include the --fields flag to specify a field label. Then use jq to retrieve the secret reference from the JSON output. For example:
To get secret references for every field on an item, use op item get with the --format json flag without specifying a field.
Example JSON output
Example JSON output
reference key that contains its secret reference. For the example GitHub item, the output looks like this:Syntax rules
Supported characters
Secret references are case-insensitive and support the following characters:- alphanumeric characters (
a-z,A-Z,0-9) -,_,.and the whitespace character
op item get with the output set to JSON. For example, to get the ID for a custom text field named test/:
File attachments
To reference a file attachment, use the file name in place of a field name:Externally-set variables
If you use different sets of secrets in different environments, you can include variables within secret references and then set the variable to switch between secrets. For example, theAPP_ENV variable in the example below can be set to dev to load development credentials or prod to load production credentials, assuming the credentials are stored in 1Password vaults named dev and prod.
app.env
Field and file metadata attributes
You can use secret references with query parameters to get more information about an item.Attribute parameter
To get information about item fields and file attachments, use theattribute (or attr) query parameter.
Fields
File attachments
Field attributes:
| Attribute | Definition |
|---|---|
type | The field’s type |
value | The field’s content |
id | The field’s unique identifier |
purpose | The designation of a built-in field (can be “username”, “password”, or “notes”) |
otp | Use with one-time password fields to generate a one-time password code |
File attachment attributes:
| Attribute | Definition |
|---|---|
type | The field’s type |
content | The file attachment’s content |
size | The size of the file attachment |
id | The file attachment’s unique identifier |
name | The name of the file attachment |
SSH format parameter
To get an SSH private key in the OpenSSH format, include thessh-format query parameter with the value openssh on a secret reference for the SSH key’s private key field.
Secret reference examples
A field inside a section
To create a secret reference that refers to the PagerDuty email field, which is within the Admin section, use:Managementrefers to the vault where the item is savedPagerDutyrefers to the itemAdminrefers to the section where the field is a part ofemailrefers to the field where the secret you want to reference is located

A field without a section
To create a secret reference for the Stripe publishable-key field, which is not part of a section, use:devrefers to the vault where the item is savedStriperefers to the itempublishable-keyrefers to the field where the secret you want to reference is located
