Storing Metadata
Keygen supports adding arbitrary metadata to most resources, such as the user resource. Metadata is for your use only and is not explicitly shown to customers unless you display it (though note that it is included in API responses e.g. when you request a user resource).
With metadata, you can associate other information, such as the user's
customer_id
within your payment system, the user's shipping address,
etc. Any metadata you include will be viewable within your dashboard
(e.g. when looking at an individual resource).
metadata
attribute is simply a key-value
store (object), all write operations will overwrite the entire object,
so be sure to merge existing data on your end when performing
partial updates.
The response of this request will either be an error, or the full license resource including your license's updated metadata.
curl -X PATCH https://api.keygen.sh/v1/accounts/<account>/licenses/a5a154d2-f026-40fa-bc8d-a7e3ca415298 \ -H 'Content-Type: application/vnd.api+json' \ -H 'Accept: application/vnd.api+json' \ -H 'Authorization: Bearer <token>' \ -d '{ "data": { "type": "licenses", "attributes": { "metadata": { "customerEmail": "[email protected]", "customerId": "cust_a7e3ca415298f0", "isPro": true } } } }'
metadata
(via a POST
request), a user or license token
may be used. However, updating metadata
requires an admin, environment or product token.
Next steps
Congrats! You've stored metadata on one of your users using Keygen. Next up, explore the different licensing models we offer, or review the API.