LogoLogo
System Status
Digital River API reference
Digital River API reference
  • Digital River API reference
  • Digital River API Reference Guide
    • API structure
    • Best practices
    • Supported languages
    • Working with metadata
    • Rate limiting
    • Versioning
    • Glossary
Powered by GitBook
On this page
  • Supported data types
  • Restrictions
  • Add metadata
  • Update metadata
  • Delete metadata
  • Metadata in events
  • Copying metadata
  1. Digital River API Reference Guide

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

PreviousSupported languagesNextRate limiting

Last updated 4 months ago

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.

Supported data types

The keys in metadata can be assigned strings, numbers, booleans, objects, arrays, and null.

Customer
{
    "id": "674583010336",
    ...
    "metadata": {
        "adminName": "John Doe",
        "adminId": 5827134,
        "rewardProgram": false,
        "marketingConsents": {
            "email": true,
            "SMS": false,
            "newsLetter": true
        },
        "previousAddresses": [
            {
                "line1": "Rudi-Dutschke-Straße 26",
                "city": "Berlin",
                "postalCode": "10176",
                "jurisdiction": null,
                "country": "DE"
            },
            {
                "line1": "21 Delaware",
                "city": "Saint Paul",
                "postalCode": "55017",
                "jurisdiction": "MN",
                "country": "US"
            }
        ]
    },
    ...
}

Restrictions

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.

Add metadata

In applicable create and update API operations, you can add one or more key-value pairs to metadata.

curl --location 'https://api.digitalriver.com/customers' \
--header 'Authorization: Bearer <API key>' \
--data '{
    "metadata": {
        "adminName": "John Doe",
        "adminId": 5827134
    }
}'
Customer
{
    "id": "674582640336",
    "createdTime": "2024-07-11T15:22:25Z",
    "enabled": true,
    "requestToBeForgotten": false,
    "metadata": {
        "adminName": "John Doe",
        "adminId": 5827134
    },
    "locale": "en_US",
    "type": "individual",
    "liveMode": false
}

Update metadata

Customer
{
    "id": "674545580336",
    ...
    "metadata": {
        "marketingConsents": {
            "email": true,
            "SMS": false,
            "newsLetter": false
        }
    },
    ...
}
Update customer
curl --location 'https://api.digitalriver.com/customers/674545590336' \
--header 'Authorization: Bearer <API key>' \
--data '{
    "metadata": {
        "marketingConsents": {
            "newsLetter": true
        }
    }
}'
Customer
{
    "id": "674545590336",
    ...
    "metadata": {
        "marketingConsents": {
            "email": true,
            "SMS": false,
            "newsLetter": true
        }
    },
    ...
}
Checkout
{
    "id": "e68062ca-b705-40c9-b491-29b6110c62a8",
    ...
    "metadata": {
        "key1": "value",
        "key2": "value"
    },
    ...
}
curl --location 'https://api.digitalriver.com/checkouts/e68062ca-b705-40c9-b491-29b6110c62a8' \
--header 'Authorization: Bearer <API key>' \
    "metadata": {
        "key3": "value"
    }
}'
Checkout
{
    "id": "e68062ca-b705-40c9-b491-29b6110c62a8",
    ...
    "metadata": {
        "key1": "value",
        "key2": "value",
        "key3": "value"
    },
    ...
}

Delete metadata

To remove a key from metadata, assign it an empty string value.

Customer
{
    "id": "674545630336",
    ...
    "metadata": {
        "key1": "value",
        "key2": "value"
    },
    ...
}
Update customer
curl --location 'https://api.digitalriver.com/customers/674545630336' \
--header 'Authorization: Bearer <API key>' \
--data '{
    "metadata": {
        "key1": ""
    }
}'
Customer
{
    "id": "674545630336",
    ...
    "metadata": {
        "key2": "value"
    },
    ...
}

Metadata in events

curl --location 'https://api.digitalriver.com/drop-in/checkout-sessions' \
--header 'Authorization: Bearer <API key>' \
--data-raw '{
    ...
    "metadata": {
        "cartId": "efv4334t6"
    },
    ...
}'
Event
{
    "id": "e7fab7e3-d4ad-4c21-b29d-abe589ec7017",
    "type": "checkout_session.order.created",
    "data": {
        "object": {
            ...
            "metadata": {
                "cartId": "efv4334t6"
            },
            ...
        }
    },
    "liveMode": false,
    "createdTime": "2024-07-11T17:09:47.559906Z[UTC]"
}

Copying metadata

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 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 contains metadata, and that 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 is added to its orderDetails. If you then later update the metadata, those updates are reflected in the orderDetails.

events
order
order
order
SKUs
checkouts
checkout sessions
invoices
orders
customers
fulfillments
returns
refunds
plans
subscriptions
fees
fulfillment orders
checkout
checkout session
invoice
order
fulfillment order
customer
checkout's
webhooks
creating a checkout-session
refund
create a checkout session
checkout
create a checkout link
checkout-session
create order request
checkout
order
fulfillment
order's
fulfillment's
event
type
checkout_session.order.created
data.object
event
webhooks