Update a token
Learn how to update a token in Piiano Vault
Tokens include metadata that defines tags, used to classify tokens, and an expiry date. These metadata values can be updated, this guide explains how.
Change token tags
Overview
You use tags to classify tokens. However, from time to time you may wish to update the tags you use, for example, to make them more meaningful.
To update the tags you:
-
Determine how to identify the tokens with the tags you want to update.
noteThe tokens to update are matched using the query parameters described in Retrieve a token.
-
Use the CLI update tokens command setting the
--new-tag
flag or the REST API update token operation setting thetags
property to a comma-separated list of the new tag values you want on the tokens.
Step-by-step
Your system is tagging tokens added to a paymentinfo
collection with the document name they originated from. However, you find one document has been adding the less than meaningful tag of a
. Also, you know that all tokens originating from this document were made by the same operator and you want to include their name as a tag too.
You update the tag values using the CLI like this:
pvault token update \
--tag a \
--new-tags document1,operator1337 \
--collection paymentinfo
Or using the REST API like this:
curl -s -X PATCH \
--url 'http://localhost:8123/api/pvlt/1.0/data/collections/paymentinfo/tokens?tags=a&reason=AppFunctionality' \
-H 'Authorization: Bearer pvaultauth' \
-H 'Content-Type: application/json' \
-d '{ "tags": [ "document1" , "operator1337" ] }'
If the tags update, you get a 200 response only.
Reset token expiration
Overview
When you create a token, it is set an expiration period. If you want to reset a token's expiration, you can:
- set the token to never expire.
- set a new expiration period in seconds.
- archive the token immediately by setting the expiration period in seconds to
0
.
To reset the expiration of tokens you:
-
Determine how to identify the tokens whose expiration you want to reset.
noteThe tokens to reset are matched using the query parameters described in Retrieve a token.
-
Use the:
- CLI update tokens command, set the:
--no-expiration
flag if you don't want the token to ever expire.--expiration-secs
flag to the number of seconds you want the token to remain active.
- REST API update tokens operation, set the
expiration-secs
query parameter to:null
if you don't want the token to ever expire.- the number of seconds you want the token to remain active.
Step-by-step
You reset the expiration of tokens using the CLI like this:
pvault token update \
--tag operator1337 \
--expiration-secs 604800 \
--collection paymentinfo
Or using the REST API like this:
curl -s -X PATCH \
--url 'http://localhost:8123/api/pvlt/1.0/data/collections/paymentinfo/tokens?tags=operator1337&expiration_secs=604800&reason=AppFunctionality' \
-H 'Authorization: Bearer pvaultauth' \
-H 'Content-Type: application/json' \
-d '{}'
If the expiry date updates, you get a 200 response only.