Passing custom data

Lemon Squeezy supports passing custom data through the checkout. This can be useful if you have information about a customer before they enter the checkout process that you need to link with the order after the checkout has been completed. For example, if you’re building a SaaS application and need to link purchase with an existing user in your system you may want to pass the user ID to the checkout and then capture the order for that user ID in a webhook.

Passing Custom Data

Passing custom data through the checkout works in the same way as prefilling checkout fields, by adding parameters to the checkout link:

https://[STORE].lemonsqueezy.com/checkout/buy/[VARIANT_ID]?checkout[custom][user_id]=123

You can add as many fields as you like using the checkout[custom] array, although we recommend restraint and try to only pass the minimal data required through the checkout.

Listen for a Webhook

See our API documentation on setting up webhooks in your application. If you have passed some custom data, every webhook will contain a custom_data object inside the meta field:

{
  "meta": {
    "event_name": "order_created"
    "custom_data": {
      "user_id": "123"
    }
  },
  ...
}