Skip to main content
Metadata lets you carry context from your application through a Kelviq checkout. Add an object when you create the session, and Kelviq returns the same object in the checkout.completed webhook. A common example is an order reference:
Use metadata for values that help your backend connect a completed checkout to its own records, such as an internal order ID, workspace ID, campaign, or signup source.
Do not put API keys, passwords, card details, or other sensitive information in metadata. Metadata is returned in webhook payloads and may appear in operational logs.

Before you start

You need:
  • a server API key from Settings → API Keys;
  • a plan identifier and supported charge period;
  • a backend endpoint that creates checkout sessions.
A webhook endpoint is optional. Subscribe it to checkout.completed if you want to receive the metadata when checkout finishes. Keep the server API key in your backend. Never expose it in browser or mobile code.

Add metadata when creating the session

Pass metadata at the top level of the Checkout API request body. Kelviq preserves the keys exactly as supplied, so order_ref and orderRef are different keys.
The response contains the hosted checkout URL and the Kelviq session ID:
Redirect the customer to checkoutUrl. The create response does not echo the metadata, so save checkoutSessionId alongside your internal record if you also need to look up the Kelviq session later.
This guide uses the sandbox host and a sandbox server API key. Switch both to production together when you are ready to accept live payments.

Read metadata after checkout

When payment succeeds, the checkout.completed event includes the metadata at data.object.metadata:
Verify the webhook signature before reading or acting on the payload. After verification, you can use the metadata to find the matching record in your system:
Use the webhook event id, not a metadata value, as your idempotency key. Kelviq can deliver the same event more than once during automatic retries or a manual resend. Learn how to register an endpoint and verify signatures →

Choose useful metadata

Keep the object small and focused on correlation. A stable naming convention makes webhook handlers easier to maintain. Metadata is helpful context, but it is not proof of payment or authorization. Confirm event.type, verify the signature, and use Kelviq’s resource IDs when calling Kelviq APIs.

Checkout metadata and customer metadata are different

Checkout metadata describes one checkout session. Customer metadata describes the customer record and can be managed through the Customers API. Adding metadata to a checkout session does not replace or update customer metadata.

Test the complete flow

  1. Create a session with a sandbox server API key and recognizable test metadata.
  2. Open the returned checkoutUrl and complete a sandbox payment.
  3. Open Settings → Webhooks, then inspect the checkout.completed delivery.
  4. Confirm that data.object.metadata contains the same keys and values.
  5. Resend the delivery and confirm that your idempotency check prevents duplicate work.

Troubleshooting