Metadata
Attach your own key-value data to Paycose objects — where metadata is stored, how updates replace it, and the keys to avoid.
metadata is a JSON object of your own key-value pairs, such as your order
number or your internal customer id. You set it when you create an object, and
it comes back on the object and in its webhook events, so you can tie Paycose
objects to your records without keeping a separate mapping.
curl "$WALLET/customers" \
-H "Authorization: Bearer ${SECRET_KEY}" \
-H "X-Country: TH" \
-H "Content-Type: application/json" \
-d '{
"name": "Somchai Jaidee",
"email": "somchai@example.com",
"capabilities": { "charge": true },
"metadata": { "crm_id": "C-20931", "segment": "retail" }
}'Values
- Keys are strings. Values can be any JSON value; strings are the safest choice for your own code.
- Paycose sets no limit on the number of keys or the size of values, except on
connected accounts (
POST /accounts): at most 50 keys, and every value a string. - Nothing inside
metadatais ever rewritten. A timestamp or currency inside metadata comes back exactly as you sent it, not as Unix seconds or lowercase. - Lists cannot be filtered by metadata.
Don't put card numbers, passwords or other secrets in metadata. It is returned on every read of the object and sent in webhook events.
Reserved keys
On several objects Paycose drops the keys id, application_id, country and
invoice_id from the metadata you send. Don't use these names for your own keys.
Payment intents refuse the keys Paycose keeps for payment state: auth_actions,
authorize_uri, charge_status, client_secret, last_payment_error, next_action,
pi_status, requires_action and return_uri. The request fails with 400, and the
error's param names the key, for example metadata[next_action].
Where you can set it
Metadata is stored on these objects:
| Object | Set on create | Set on update |
|---|---|---|
| Customers | POST /customers | — |
| Payment intents | POST /payment_intents | PATCH /payment_intents/{id} |
| Payment methods | — | PATCH /payment_methods/{id} |
| Refunds | POST /refunds | PATCH /refunds/{id} |
| Disputes | — | PATCH /disputes/{id} |
| Invoices | POST /invoices | PATCH /invoices/{id} |
| Quotes | POST /quotes | PATCH /quotes/{id} |
| Subscriptions | POST /subscriptions | PATCH /subscriptions/{id} |
| Credit notes | POST /credit_notes | — |
| Coupons | POST /coupons | — |
| Promotion codes | POST /promotion_codes | PATCH /promotion_codes/{id} |
| Shipping rates | POST /shipping_rates | PATCH /shipping_rates/{id} |
| Meters | POST /meters | PATCH /meters/{id} |
| Tax ids | POST /customers/{customer_id}/tax_ids | — |
| Payouts | POST /payouts | — |
| Bank accounts | POST /bank_accounts | — |
| Connected accounts | POST /accounts | — |
| Application fee refunds | POST /application_fees/{id}/refunds | POST /application_fees/{id}/refunds/{refund_id} |
These endpoints accept metadata but do not store it today, so the object's
metadata stays empty or unchanged:
| Endpoint | What happens |
|---|---|
POST /products | Dropped; the new product's metadata is empty. |
POST /prices | Dropped; the new price's metadata is empty. |
PATCH /prices/{id} | Sent to the payment providers that hold a copy of the price; the price's own metadata does not change. |
POST /payment_links | Dropped. |
On payment methods, the metadata you send is also passed to the payment provider that stores the method.
Updating metadata
On payment intents, PATCH /payment_intents/{id} merges the keys you send into the
stored metadata, as Stripe does:
- A key with a value adds or replaces that key; other keys stay.
- A key set to
""ornullremoves that key. - An empty object (
{}) removes every key.
On every other object, an update replaces the whole metadata object; keys you leave
out are removed. To change one key, read the object, change the key, and send the full
object back:
curl -X PATCH "$WALLET/invoices/in_5e7a2c9d1b3f4a6e8c0d2b4f6a8c0e1d" \
-H "Authorization: Bearer ${SECRET_KEY}" \
-H "X-Country: TH" \
-H "Content-Type: application/json" \
-d '{ "metadata": { "order_id": "SO-1042", "channel": "web" } }'Leaving metadata out of an update keeps the stored metadata. What an empty
object ({}) does depends on the object:
- On payment intents, invoices, quotes, meters, promotion codes and shipping rates,
{}clears the metadata. - On payment methods, refunds, disputes and subscriptions,
{}leaves the metadata unchanged.