less than a minute read • Updated 12 days ago
Set up gift cards for purchase via the API
How to build custom gift card purchasing beyond the default form — setting up codes, balances, and provisioning rules through the API for more control over the buying experience.
You can enable a gift card for customer purchase and set up its recipient notification email entirely through the API, as an alternative to the admin UI.
Enable the gift card for purchase
When creating a gift card via the API, include a provisioning_config object to allow customers to purchase it:
{
"name": "Widgets Gift Card",
"provisioning_config": {
"allow_autoprovisioning": true,
"initial_balance_max": 100,
"initial_balance_min": 10
},
"sku": "widgets"
}
allow_autoprovisioning— set tofalseto disallow new gift cards from being purchased by customersinitial_balance_min/initial_balance_max— set the minimum and maximum balance a customer can put on the gift card when purchasing
Set up the recipient notification email
Notes
This covers the API path only. For the equivalent steps in the admin UI, see Allow customers to purchase gift cards on your store.
You’ll still need to build a storefront add-to-cart form for customers to purchase the gift card — see the same article for the required fields.