Skip to Content
Paycose Docs
Setup

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 metadata is 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:

ObjectSet on createSet on update
CustomersPOST /customers—
Payment intentsPOST /payment_intentsPATCH /payment_intents/{id}
Payment methods—PATCH /payment_methods/{id}
RefundsPOST /refundsPATCH /refunds/{id}
Disputes—PATCH /disputes/{id}
InvoicesPOST /invoicesPATCH /invoices/{id}
QuotesPOST /quotesPATCH /quotes/{id}
SubscriptionsPOST /subscriptionsPATCH /subscriptions/{id}
Credit notesPOST /credit_notes—
CouponsPOST /coupons—
Promotion codesPOST /promotion_codesPATCH /promotion_codes/{id}
Shipping ratesPOST /shipping_ratesPATCH /shipping_rates/{id}
MetersPOST /metersPATCH /meters/{id}
Tax idsPOST /customers/{customer_id}/tax_ids—
PayoutsPOST /payouts—
Bank accountsPOST /bank_accounts—
Connected accountsPOST /accounts—
Application fee refundsPOST /application_fees/{id}/refundsPOST /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:

EndpointWhat happens
POST /productsDropped; the new product's metadata is empty.
POST /pricesDropped; 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_linksDropped.

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 "" or null removes 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.

What's next

On this page