Working with metadata
Gain a better understanding of metadata, including its restrictions, how to manage it, and how it flows from one API object to another
Last updated
Gain a better understanding of metadata, including its restrictions, how to manage it, and how it flows from one API object to another
Last updated
You can use metadata
to store additional information, structured as key-value pairs.
In the Digital River APIs, metadata
can be added to , , , , , , , , , , , , and .
Do not save any sensitive information, such as a customer's bank account or credit card details, in metadata
.
You can also attach metadata
to each items[]
in a , , , , and .
Digital River doesn't use this data; your users will only see it if you display it.
The keys in metadata
can be assigned strings, numbers, booleans, objects, arrays, and null
.
There must be at least one valid key-value pair in metadata
.
You can add a maximum of 20 primary key-value pairs to metadata
. However, if you need additional entries, you can use nested keys.
A key's name can't contain more than 40 characters, and its assigned value can't exceed 500 characters. If you have values longer than this, store them in an external database and use a key-value pair in metadata
to reference that external object’s identifier.
In applicable create and update API operations, you can add one or more key-value pairs to metadata
.
To remove a key from metadata
, assign it an empty string value.
In some cases, however, Digital River handles this transfer. For example:
When updating certain API resources, you can replace the value of an existing key in metadata
. For example, if a shopper agrees to start receiving newsletters from your organization, you could handle that by flipping your metadata.marketingConsents.newsLetter
in the object to true
.
You can also add new key-value pairs without affecting existing data. For example, if a metadata
contains a key1
and a key2
and you add a key3
, Digital River merges the new data into the existing data.
Digital River adds an object's metadata
to related events before sending them to your . For example, when , you might decide to add a cartId
to metadata
.
After the customer provides payment and completes checkout, Digital River creates an with a of , adds that cartId
to metadata
in its , and then pushes that to any of your that have subscribed to it. Your webhook handlers can use this data in product fulfillment and other downstream processes.
Digital River doesn't always transfer metadata
from one related object to another. For example, if an order contains metadata
, and that order is refunded, then we don't add its metadata
to the . To do this, you'd need to write your own code that moves this data from one object to the other.
Checkout sessions to checkouts: When you , its metadata
is passed to the underlying .
Checkout sessions to checkout links: When you , it inherits any metadata
that exists in the .
Checkouts to orders: When a checkoutId
is passed in a , then any metadata
that exists in that is added to the .
Orders to fulfillments: When a is created, any metadata
in its upstream order is added to its orderDetails
. If you then later update the metadata
, those updates are reflected in the orderDetails
.