Skip to content

Metadata

Attach your own text to a payment, and get it back with the payment and in its events.


Metadata is an object of text that you attach to a payment. Use it for what you need to find the payment again in your own system: an order id, a customer id, a campaign.

Send metadata when you create the payment:

Terminal window
curl -X POST "https://api.baiyar.com/v1/payments" \
-H "Authorization: Bearer $BAIYAR_KEY" \
-H "Idempotency-Key: order-1001-attempt-1" \
-H "Content-Type: application/json" \
-d '{
"amount": 1000000,
"currency": "IDR",
"payment_method": "payment.qris",
"metadata": { "order_id": "1001", "customer_id": "cus_42" }
}'

It cannot be changed afterwards. Make a new payment if the data changes.

Limit
Number of keys Up to 20
Value Text, up to 500 characters

A number is sent as text ("42"), and a value is never an object or a list.

The metadata of a payment is in every answer that has the payment, and in the webhook events that carry it, such as payment.succeeded:

{
"data": {
"id": "pay_01k7q3m8x2v5t9n4b6c1d0e7fa",
"status": "paid",
"metadata": { "order_id": "1001", "customer_id": "cus_42" }
},
"meta": { "request_id": "req_Hy3k9QzT2LmN8vXa" }
}

It is {} when you set none.

  • Keep your own identifiers in it, so that a webhook can be matched to your order without another request.
  • Do not put secrets or personal data in it: metadata is returned as it is, and it appears in events sent to your endpoints.
  • To find a payment by your own reference, use merchant_reference and the filter of the same name: lists cannot be filtered by metadata. See Filter lists.