less than a minute read • Updated 35 minutes ago
Set up gift cards for purchase via the API
How to enable a gift card for customer purchase and set up its notification email using the API.
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
{
"description": "Gift Card Template",
"subject": "You have a gift!"
}
The API returns the new template’s URL, for example https://.../email_templates/87992.
{
"gift_recipient_email_template_uri": "https://api.foxycart.com/email_templates/{{your_new_email_template_id}}"
}
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.