»Transit Secrets Engine (API)
This is the API documentation for the Vault Transit secrets engine. For general information about the usage and operation of the Transit secrets engine, please see the transit documentation.
This documentation assumes the transit secrets engine is enabled at the
/transit
path in Vault. Since it is possible to enable secrets engines at any
location, please update your API calls accordingly.
»Create Key
This endpoint creates a new named encryption key of the specified type. The values set here cannot be changed after key creation.
Method | Path |
---|---|
POST | /transit/keys/:name |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key to create. This is specified as part of the URL.convergent_encryption
(bool: false)
– If enabled, the key will support convergent encryption, where the same plaintext creates the same ciphertext. This requires derived to be set totrue
. When enabled, each encryption(/decryption/rewrap/datakey) operation will derive anonce
value rather than randomly generate it.derived
(bool: false)
– Specifies if key derivation is to be used. If enabled, all encrypt/decrypt requests to this named key must provide a context which is used for key derivation.exportable
(bool: false)
- Enables keys to be exportable. This allows for all the valid keys in the key ring to be exported. Once set, this cannot be disabled.allow_plaintext_backup
(bool: false)
- If set, enables taking backup of named key in the plaintext format. Once set, this cannot be disabled.type
(string: "aes256-gcm96")
– Specifies the type of key to create. The currently-supported types are:aes128-gcm96
– AES-128 wrapped with GCM using a 96-bit nonce size AEAD (symmetric, supports derivation and convergent encryption)aes256-gcm96
– AES-256 wrapped with GCM using a 96-bit nonce size AEAD (symmetric, supports derivation and convergent encryption, default)chacha20-poly1305
– ChaCha20-Poly1305 AEAD (symmetric, supports derivation and convergent encryption)ed25519
– ED25519 (asymmetric, supports derivation). When using derivation, a sign operation with the same context will derive the same key and signature; this is a signing analogue toconvergent_encryption
.ecdsa-p256
– ECDSA using the P-256 elliptic curve (asymmetric)ecdsa-p384
– ECDSA using the P-384 elliptic curve (asymmetric)ecdsa-p521
– ECDSA using the P-521 elliptic curve (asymmetric)rsa-2048
- RSA with bit size of 2048 (asymmetric)rsa-3072
- RSA with bit size of 3072 (asymmetric)rsa-4096
- RSA with bit size of 4096 (asymmetric)
»Sample Payload
»Sample Request
»Read Key
This endpoint returns information about a named encryption key. The keys
object shows the creation time of each key version; the values are not the keys
themselves. Depending on the type of key, different information may be returned,
e.g. an asymmetric key will return its public key in a standard format for the
type.
Method | Path |
---|---|
GET | /transit/keys/:name |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key to read. This is specified as part of the URL.
»Sample Request
»Sample Response
The keys
attribute lists each version of the key, and the time that key was created as seconds since the Unix epoch.
The sample response shows a key that was created on September 22, 2015 7:50:12 PM GMT, and has not been rotated.
The fields supports_encryption
, supports_decryption
, supports_derivation
and supports_signing
are
derived from the type of the key, and indicate which operations may be performed with it.
»List Keys
This endpoint returns a list of keys. Only the key names are returned (not the actual keys themselves).
Method | Path |
---|---|
LIST | /transit/keys |
»Sample Request
»Sample Response
»Delete Key
This endpoint deletes a named encryption key. It will no longer be possible to
decrypt any data encrypted with the named key. Because this is a potentially
catastrophic operation, the deletion_allowed
tunable must be set in the key's
/config
endpoint.
Method | Path |
---|---|
DELETE | /transit/keys/:name |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key to delete. This is specified as part of the URL.
»Sample Request
»Update Key Configuration
This endpoint allows tuning configuration values for a given key. (These values are returned during a read operation on the named key.)
Method | Path |
---|---|
POST | /transit/keys/:name/config |
»Parameters
min_decryption_version
(int: 0)
– Specifies the minimum version of ciphertext allowed to be decrypted. Adjusting this as part of a key rotation policy can prevent old copies of ciphertext from being decrypted, should they fall into the wrong hands. For signatures, this value controls the minimum version of signature that can be verified against. For HMACs, this controls the minimum version of a key allowed to be used as the key for verification.min_encryption_version
(int: 0)
– Specifies the minimum version of the key that can be used to encrypt plaintext, sign payloads, or generate HMACs. Must be0
(which will use the latest version) or a value greater or equal tomin_decryption_version
.deletion_allowed
(bool: false)
- Specifies if the key is allowed to be deleted.exportable
(bool: false)
- Enables keys to be exportable. This allows for all the valid keys in the key ring to be exported. Once set, this cannot be disabled.allow_plaintext_backup
(bool: false)
- If set, enables taking backup of named key in the plaintext format. Once set, this cannot be disabled.
»Sample Payload
»Sample Request
»Rotate Key
This endpoint rotates the version of the named key. After rotation, new
plaintext requests will be encrypted with the new version of the key. To upgrade
ciphertext to be encrypted with the latest version of the key, use the rewrap
endpoint. This is only supported with keys that support encryption and
decryption operations.
Method | Path |
---|---|
POST | /transit/keys/:name/rotate |
»Sample Request
»Export Key
This endpoint returns the named key. The keys
object shows the value of the
key for each version. If version
is specified, the specific version will be
returned. If latest
is provided as the version, the current key will be
provided. Depending on the type of key, different information may be returned.
The key must be exportable to support this operation and the version must still
be valid.
Method | Path |
---|---|
GET | /transit/export/:key_type/:name(/:version) |
»Parameters
key_type
(string: <required>)
– Specifies the type of the key to export. This is specified as part of the URL. Valid values are:name
(string: <required>)
– Specifies the name of the key to read information about. This is specified as part of the URL.version
(string: "")
– Specifies the version of the key to read. If omitted, all versions of the key will be returned. This is specified as part of the URL. If the version is set tolatest
, the current key will be returned.
»Sample Request
»Sample Response
»Encrypt Data
This endpoint encrypts the provided plaintext using the named key. This path
supports the create
and update
policy capabilities as follows: if the user
has the create
capability for this endpoint in their policies, and the key
does not exist, it will be upserted with default values (whether the key
requires derivation depends on whether the context parameter is empty or not).
If the user only has update
capability and the key does not exist, an error
will be returned.
Method | Path |
---|---|
POST | /transit/encrypt/:name |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key to encrypt against. This is specified as part of the URL.plaintext
(string: <required>)
– Specifies base64 encoded plaintext to be encoded.context
(string: "")
– Specifies the base64 encoded context for key derivation. This is required if key derivation is enabled for this key.key_version
(int: 0)
– Specifies the version of the key to use for encryption. If not set, uses the latest version. Must be greater than or equal to the key'smin_encryption_version
, if set.nonce
(string: "")
– Specifies the base64 encoded nonce value. This must be provided if convergent encryption is enabled for this key and the key was generated with Vault 0.6.1. Not required for keys created in 0.6.2+. The value must be exactly 96 bits (12 bytes) long and the user must ensure that for any given context (and thus, any given encryption key) this nonce value is never reused.batch_input
(array<object>: nil)
– Specifies a list of items to be encrypted in a single batch. When this parameter is set, if the parameters 'plaintext', 'context' and 'nonce' are also set, they will be ignored. The format for the input is:type
(string: "aes256-gcm96")
–This parameter is required when encryption key is expected to be created. When performing an upsert operation, the type of key to create.convergent_encryption
(string: "")
– This parameter will only be used when a key is expected to be created. Whether to support convergent encryption. This is only supported when using a key with key derivation enabled and will require all requests to carry both a context and 96-bit (12-byte) nonce. The given nonce will be used in place of a randomly generated nonce. As a result, when the same context and nonce are supplied, the same ciphertext is generated. It is very important when using this mode that you ensure that all nonces are unique for a given context. Failing to do so will severely impact the ciphertext's security.
NOTE: All plaintext data must be base64-encoded. The reason for this requirement is that Vault does not require that the plaintext is "text". It could be a binary file such as a PDF or image. The easiest safe transport mechanism for this data as part of a JSON payload is to base64-encode it.
»Sample Payload
Fist, encode the plaintext with base64:
Use the base64-encoded plaintext in the payload:
Vault HTTP API imposes a maximum request size of 32MB to prevent a denial of service attack. This can be tuned per listener
block in the Vault server configuration.
»Sample Request
»Sample Response
»Decrypt Data
This endpoint decrypts the provided ciphertext using the named key.
Method | Path |
---|---|
POST | /transit/decrypt/:name |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key to decrypt against. This is specified as part of the URL.ciphertext
(string: <required>)
– Specifies the ciphertext to decrypt.context
(string: "")
– Specifies the base64 encoded context for key derivation. This is required if key derivation is enabled.nonce
(string: "")
– Specifies a base64 encoded nonce value used during encryption. Must be provided if convergent encryption is enabled for this key and the key was generated with Vault 0.6.1. Not required for keys created in 0.6.2+.batch_input
(array<object>: nil)
– Specifies a list of items to be decrypted in a single batch. When this parameter is set, if the parameters 'ciphertext', 'context' and 'nonce' are also set, they will be ignored. Format for the input goes like this:
»Sample Payload
»Sample Request
»Sample Response
»Rewrap Data
This endpoint rewraps the provided ciphertext using the latest version of the named key. Because this never returns plaintext, it is possible to delegate this functionality to untrusted users or scripts.
Method | Path |
---|---|
POST | /transit/rewrap/:name |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key to re-encrypt against. This is specified as part of the URL.ciphertext
(string: <required>)
– Specifies the ciphertext to re-encrypt.context
(string: "")
– Specifies the base64 encoded context for key derivation. This is required if key derivation is enabled.key_version
(int: 0)
– Specifies the version of the key to use for the operation. If not set, uses the latest version. Must be greater than or equal to the key'smin_encryption_version
, if set.nonce
(string: "")
– Specifies a base64 encoded nonce value used during encryption. Must be provided if convergent encryption is enabled for this key and the key was generated with Vault 0.6.1. Not required for keys created in 0.6.2+.batch_input
(array<object>: nil)
– Specifies a list of items to be decrypted in a single batch. When this parameter is set, if the parameters 'ciphertext', 'context' and 'nonce' are also set, they will be ignored. Format for the input goes like this:
»Sample Payload
»Sample Request
»Sample Response
»Generate Data Key
This endpoint generates a new high-entropy key and the value encrypted with the named key. Optionally return the plaintext of the key as well. Whether plaintext is returned depends on the path; as a result, you can use Vault ACL policies to control whether a user is allowed to retrieve the plaintext value of a key. This is useful if you want an untrusted user or operation to generate keys that are then made available to trusted users.
Method | Path |
---|---|
POST | /transit/datakey/:type/:name |
»Parameters
type
(string: <required>)
– Specifies the type of key to generate. Ifplaintext
, the plaintext key will be returned along with the ciphertext. Ifwrapped
, only the ciphertext value will be returned. This is specified as part of the URL.name
(string: <required>)
– Specifies the name of the encryption key to use to encrypt the datakey. This is specified as part of the URL.context
(string: "")
– Specifies the key derivation context, provided as a base64-encoded string. This must be provided if derivation is enabled.nonce
(string: "")
– Specifies a nonce value, provided as base64 encoded. Must be provided if convergent encryption is enabled for this key and the key was generated with Vault 0.6.1. Not required for keys created in 0.6.2+. The value must be exactly 96 bits (12 bytes) long and the user must ensure that for any given context (and thus, any given encryption key) this nonce value is never reused.bits
(int: 256)
– Specifies the number of bits in the desired key. Can be 128, 256, or 512.
»Sample Payload
»Sample Request
»Sample Response
»Generate Random Bytes
This endpoint returns high-quality random bytes of the specified length.
Method | Path |
---|---|
POST | /transit/random(/:bytes) |
»Parameters
bytes
(int: 32)
– Specifies the number of bytes to return. This value can be specified either in the request body, or as a part of the URL.format
(string: "base64")
– Specifies the output encoding. Valid options arehex
orbase64
.
»Sample Payload
»Sample Request
»Sample Response
»Hash Data
This endpoint returns the cryptographic hash of given data using the specified algorithm.
Method | Path |
---|---|
POST | /transit/hash(/:algorithm) |
»Parameters
algorithm
(string: "sha2-256")
– Specifies the hash algorithm to use. This can also be specified as part of the URL. Currently-supported algorithms are:input
(string: <required>)
– Specifies the base64 encoded input data.format
(string: "hex")
– Specifies the output encoding. This can be eitherhex
orbase64
.
»Sample Payload
»Sample Request
»Sample Response
»Generate HMAC
This endpoint returns the digest of given data using the specified hash
algorithm and the named key. The key can be of any type supported by transit
;
the raw key will be marshaled into bytes to be used for the HMAC function. If
the key is of a type that supports rotation, the latest (current) version will
be used.
Method | Path |
---|---|
POST | /transit/hmac/:name(/:algorithm) |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key to generate hmac against. This is specified as part of the URL.key_version
(int: 0)
– Specifies the version of the key to use for the operation. If not set, uses the latest version. Must be greater than or equal to the key'smin_encryption_version
, if set.algorithm
(string: "sha2-256")
– Specifies the hash algorithm to use. This can also be specified as part of the URL. Currently-supported algorithms are:input
(string: "")
– Specifies the base64 encoded input data. One ofinput
orbatch_input
must be supplied.batch_input
(array<object>: nil)
– Specifies a list of items for processing. When this parameter is set, if the parameter 'input' is also set, it will be ignored. Responses are returned in the 'batch_results' array component of the 'data' element of the response. If the input data value of an item is invalid, the corresponding item in the 'batch_results' will have the key 'error' with a value describing the error. The format for batch_input is:
»Sample Request
»Sample Payload
»Sample Response
»Sample Payload with batch_input
»Sample Response for batch_input
»Sign Data
This endpoint returns the cryptographic signature of the given data using the named key and the specified hash algorithm. The key must be of a type that supports signing.
Method | Path |
---|---|
POST | /transit/sign/:name(/:hash_algorithm) |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key to use for signing. This is specified as part of the URL.key_version
(int: 0)
– Specifies the version of the key to use for signing. If not set, uses the latest version. Must be greater than or equal to the key'smin_encryption_version
, if set.hash_algorithm
(string: "sha2-256")
– Specifies the hash algorithm to use for supporting key types (notably, not includinged25519
which specifies its own hash algorithm). This can also be specified as part of the URL. Currently-supported algorithms are:Warning:
sha1
should be considered a compromised algorithm and used only for legacy applications. Signing using SHA-1 can be blocked by operators by assigning the following policy corresponding to a named key:input
(string: "")
– Specifies the base64 encoded input data. One ofinput
orbatch_input
must be supplied.batch_input
(array<object>: nil)
– Specifies a list of items for processing. When this parameter is set, any supplied 'input' or 'context' parameters will be ignored. Responses are returned in the 'batch_results' array component of the 'data' element of the response. If the input data value of an item is invalid, the corresponding item in the 'batch_results' will have the key 'error' with a value describing the error. The format for batch_input is:context
(string: "")
- Base64 encoded context for key derivation. Required if key derivation is enabled; currently only available with ed25519 keys.prehashed
(bool: false)
- Set totrue
when the input is already hashed. If the key type isrsa-2048
,rsa-3072
orrsa-4096
, then the algorithm used to hash the input should be indicated by thehash_algorithm
parameter. Just as the value to sign should be the base64-encoded representation of the exact binary data you want signed, when set,input
is expected to be base64-encoded binary hashed data, not hex-formatted. (As an example, on the command line, you could generate a suitable input viaopenssl dgst -sha256 -binary | base64
.)signature_algorithm
(string: "pss")
– When using a RSA key, specifies the RSA signature algorithm to use for signing. Supported signature types are:marshaling_algorithm
(string: "asn1")
– Specifies the way in which the signature should be marshaled. This currently only applies to ECDSA keys. Supported types are:
»Sample Request
»Sample Payload
»Sample Response
»Sample Payload with batch_input
Given an ed25519 key with derived keys set, the context parameter is expected for each batch_input item, and the response will include the derived public key for each item.
»Sample Response for batch_input
»Verify Signed Data
This endpoint returns whether the provided signature is valid for the given data.
Method | Path |
---|---|
POST | /transit/verify/:name(/:hash_algorithm) |
»Parameters
name
(string: <required>)
– Specifies the name of the encryption key that was used to generate the signature or HMAC.hash_algorithm
(string: "sha2-256")
– Specifies the hash algorithm to use. This can also be specified as part of the URL. Currently-supported algorithms are:Warning:
sha1
should be considered a compromised algorithm. Signatures verified using the algorithm could be forgeries. Verification using SHA-1 can be blocked by operators by assigning the following policy corresponding to a named key:input
(string: "")
– Specifies the base64 encoded input data. One ofinput
orbatch_input
must be supplied.signature
(string: "")
– Specifies the signature output from the/transit/sign
function. Either this must be supplied orhmac
must be supplied.hmac
(string: "")
– Specifies the signature output from the/transit/hmac
function. Either this must be supplied orsignature
must be supplied.batch_input
(array<object>: nil)
– Specifies a list of items for processing. When this parameter is set, any supplied 'input', 'hmac' or 'signature' parameters will be ignored. 'batch_input' items should contain an 'input' parameter and either an 'hmac' or 'signature' parameter. All items in the batch must consistently supply either 'hmac' or 'signature' parameters. It is an error for some items to supply 'hmac' while others supply 'signature'. Responses are returned in the 'batch_results' array component of the 'data' element of the response. If the input data value of an item is invalid, the corresponding item in the 'batch_results' will have the key 'error' with a value describing the error. The format for batch_input is:context
(string: "")
- Base64 encoded context for key derivation. Required if key derivation is enabled; currently only available with ed25519 keys.prehashed
(bool: false)
- Set totrue
when the input is already hashed. If the key type isrsa-2048
,rsa-3072
orrsa-4096
, then the algorithm used to hash the input should be indicated by thehash_algorithm
parameter.signature_algorithm
(string: "pss")
– When using a RSA key, specifies the RSA signature algorithm to use for signature verification. Supported signature types are:marshaling_algorithm
(string: "asn1")
– Specifies the way in which the signature was originally marshaled. This currently only applies to ECDSA keys. Supported types are:
»Sample Request
»Sample Payload
»Sample Response
»Sample Payload with batch_input
»Sample Response for batch_input
»Backup Key
This endpoint returns a plaintext backup of a named key. The backup contains all
the configuration data and keys of all the versions along with the HMAC key.
The response from this endpoint can be used with the /restore
endpoint to
restore the key.
Method | Path |
---|---|
GET | /transit/backup/:name |
»Parameters
name
(string: <required>)
- Name of the key.
»Sample Request
»Sample Response
»Restore Key
This endpoint restores the backup as a named key. This will restore the key
configurations and all the versions of the named key along with HMAC keys. The
input to this endpoint should be the output of /backup
endpoint.
For safety, by default the backend will refuse to restore to an existing key. If you want to reuse a key name, it is recommended you delete the key before restoring. It is a good idea to attempt restoring to a different key name first to verify that the operation successfully completes.
Method | Path |
---|---|
POST | /transit/restore(/:name) |
»Parameters
backup
(string: <required>)
- Backed up key data to be restored. This should be the output from the/backup
endpoint.name
(string: <optional>)
- If set, this will be the name of the restored key.force
(bool: false)
- If set, force the restore to proceed even if a key by this name already exists.
»Sample Payload
»Sample Request
»Trim Key
This endpoint trims older key versions setting a minimum version for the keyring. Once trimmed, previous versions of the key cannot be recovered.
Method | Path |
---|---|
POST | /transit/keys/:name/trim |
»Parameters
min_available_version
(int: <required>)
- The minimum available version for the key ring. All versions before this version will be permanently deleted. This value can at most be equal to the lesser ofmin_decryption_version
andmin_encryption_version
. This is not allowed to be set when eithermin_encryption_version
ormin_decryption_version
is set to zero.
»Sample Payload
»Sample Request
»Configure Cache
This endpoint is used to configure the transit engine's cache. Note that configuration
changes will not be applied until the transit plugin is reloaded which can be achieved
using the /sys/plugins/reload/backend
endpoint.
Method | Path |
---|---|
POST | /transit/cache-config |
»Parameters
size
(int: 0)
- Specifies the size in terms of number of entries. A size of0
means unlimited. A Least Recently Used (LRU) caching strategy is used for a non-zero cache size. Must be 0 (default) or a value greater or equal to 10 (minimum cache size).
»Sample Payload
»Sample Request
»Read Transit Cache Configuration
This endpoint retrieves configurations for the transit engine's cache.
Method | Path |
---|---|
GET | /transit/cache-config |
»Sample Request
»Sample Response