Introduction
Metadata lets you store your own key-value data on Dodo Payments objects, such as an order ID from your system or a CRM reference. You can attach metadata to most objects, including payments, subscriptions, customers, and products. See Supported Objects for the full list.Overview
Metadata follows these rules:- Metadata keys can be up to 40 characters long (up to 100 characters for usage events ingested through
POST /events/ingest). - Metadata values can be a string, integer, number, or boolean. String values can be up to 500 characters long.
- Objects, arrays, and
nullare not accepted as metadata values. - You can add up to 50 metadata key-value pairs per object. A request with more returns the
MAXIMUM_KEYS_REACHEDerror code. - The API can’t search or filter by metadata, but it returns metadata in API responses and webhooks.
Use Cases
Use metadata to:- Store external IDs or references.
- Add internal notes.
- Link Dodo Payments objects to records in your system.
- Categorize transactions.
- Add custom attributes for reporting.
Adding Metadata
Add metadata when you create or update an object through the API. For products, you can also add metadata in the dashboard.Via API
Pass ametadata object in the request body. The examples below use the TypeScript SDK and assume an initialized client:
Via Dashboard UI (Products Only)
To add metadata to a product without writing code, open the product in Products and add key-value pairs in the metadata section. You can do this when you create or edit the product.
Retrieving Metadata
API responses include metadata when you retrieve an object:Retrieving a checkout session (
GET /checkouts/{id}) doesn’t return metadata. The session status response contains only id, created_at, payment_id, payment_status, customer_email, and customer_name. To read the metadata you attached when you created the session, retrieve the resulting payment with the returned payment_id.Searching and Filtering
The API can’t search by metadata. To find an object by a metadata value:- Store your important identifiers in metadata.
- List or retrieve objects through the API.
- Filter the results in your application code.
Best Practices
Follow these guidelines to keep metadata useful.Do:
- Use consistent naming conventions for metadata keys.
- Document your metadata schema internally.
- Keep values short and meaningful.
- Use metadata for static data only.
- Consider prefixes that name the source system, for example
crm_idorinventory_sku.
Don’t:
- Store sensitive data in metadata.
- Use metadata for values that change often.
- Rely on metadata for critical business logic.
- Duplicate information that the object already contains.
- Use special characters in metadata keys.