PGP Key API Code Samples
Selection of code samples that demonstrate the use of the PGP Key API. Copy and edit these code samples to suit your needs.
When using the code samples, remember to replace:
- {vanity_name} with your tenant name
- {api_key} with your API key
- {security_token} with a valid security token
These code samples may not include all available parameters and request body fields for each endpoint. For the endpoint's full request schema, see "PGP Key" in API Reference.
Download a public encryption key
Use this sample request to generate a PGP key pair and retrieve the public encryption key. You can optionally use an empty request body of {} to generate a key with a default validity of 2 years from the time of creation.
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/api/pgpkey' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-d '{
"expirationDate": "2026-12-12"
}'
The response returns the key pair ID, details about the key pair, and the public key that you can use to encrypt your files.
{
"keyID": "9c84ec719fb0c0a9",
"dateGenerated": "1728595073157",
"expiryDate": "1797033600000",
"recipient": "WFF_j1r_1728595073157",
"publicKey": "qGypENL8OC..."
}
Retrieve a PGP public key using the key ID
Use this sample request to retrieve a specific public key using its associated key ID.
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/api/pgpkey/9c84ec719fb0c0a9' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'
The response returns the key pair ID, details about the key pair, and the public key that you can use to encrypt your files.
{
"keyID": "9c84ec719fb0c0a9",
"dateGenerated": "1728595073157",
"expiryDate": "1797033600000",
"recipient": "WFF_j1r_1728595073157",
"publicKey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: BCPG v@RELEASE_NAME@\n\De6TTBDOOpT6Cbsa...\n-----END PGP PUBLIC KEY BLOCK-----\n"
}
Retrieve all PGP public keys
Use this sample request to retrieve all the PGP public keys in your tenant.
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/api/pgpkey' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'
The response returns the details about each key pair in your tenant.
{
"keys": [
{
"keyID": "9c84ec719fb0c0a9",
"dateGenerated": "1728595073157",
"expiryDate": "1797033600000",
"recipient": "WFF_j1r_1728595073157",
"publicKey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: BCPG v@RELEASE_NAME@\n\De6TTBDOOpT6Cbsa...\n-----END PGP PUBLIC KEY BLOCK-----\n"
},
{
"keyID": "0d95fd820gc1d1b0",
"dateGenerated": "1729796973157",
"expiryDate": "1728033600000",
"recipient": "WFF_j1r_2839606184268",
"publicKey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: BCPG v@RELEASE_NAME@\n\mQGNBGcITUYBDADz...\n-----END PGP PUBLIC KEY BLOCK-----\n"
}
]
}
Delete a PGP key pair
Use this sample request to delete a specific PGP key pair.
curl -X DELETE --url 'https://{vanity_name}.api.visier.io/v1/api/pgpkey/9c84ec719fb0c0a9' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'
The response returns the ID of the key pair that was deleted.
{
"keyID": "9c84ec719fb0c0a9"
}