Scope
How do I use metadata?
API does not return the metadata (JSON)
Can Metadata be retrieved in API call?
Where do I configure metadata?
How to add custom field values to coupons?
Solution
Metadata can be used to store additional information about the resources that you might need for internal reference. The Metadata can be stored only in the JSON format. You can use nested JSON objects as well.
{
“Key-1” : ”Value-1”,
“Key-2” : ”Value-2”
}
Metadata can be useful for storing resource-related information that you might want to retrieve while performing an action, such as, the stock value for different shirt sizes or features that are offered with a particular plan for a SaaS service.
Metadata can be passed during the Add/Update operations, for the following entities:
- Subscriptions
- Customers
- Plans
- Addons
- Coupons
You can add the Metadata JSON from your Chargebee account by navigating to the resource page and click on the Add link for the JSON Metadata link as in the screenshot below:
Via APIs:
You can also add/update the Metadata via the APIs by using the metaData input parameter for the required resources.
You can't filter with metadata as a criterion, or export them. However, you can retrieve metadata via API.
GET item_prices API, does not return JSON metadata configured on the top-level item level, but only metadata configured on the lower billing period dependent price level.
i.e at the item_price point level
Note:
Metadata is only for your reference and will not be visible to customers.
If you'd like to display additional fields to the customer on the hosted pages, invoices or customer portal, you can use Custom Fields.
Metadata will not be a ‘filter criteria’, or a part of the exports. For this purpose, please use Custom Fields if necessary.
Related articles and documentation:
How do I create Custom Fields in Chargebee?