--- displayed_sidebar: jsClientSidebar slug: /references/js-client/AdminGiftCardsResource --- import ParameterTypes from "@site/src/components/ParameterTypes" # AdminGiftCardsResource This class is used to send requests to [Admin Gift Card API Routes](https://docs.medusajs.com/api/admin#gift-cards). All its method are available in the JS Client under the `medusa.admin.giftCards` property. All methods in this class require [user authentication](AdminAuthResource.mdx#createsession). Admins can create gift cards and send them directly to customers, specifying options like their balance, region, and more. These gift cards are different than the saleable gift cards in a store, which are created and managed through [AdminProductsResource](AdminProductsResource.mdx). Related Guide: [How to manage gift cards](https://docs.medusajs.com/modules/gift-cards/admin/manage-gift-cards#manage-custom-gift-cards). ## Methods ### create Create a gift card that can redeemed by its unique code. The Gift Card is only valid within `1` region. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.giftCards .create({ region_id, }) .then(({ gift_card }) => { console.log(gift_card.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs to hold additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the Region in which the Gift Card can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "value", "type": "`number`", "description": "The value (excluding VAT) that the Gift Card should represent.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "order", "type": "[Order](../internal/classes/internal.Order.mdx)", "description": "The details of the order that the gift card was purchased in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "order_id", "type": "`string`", "description": "The ID of the order that the gift card was purchased in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this gift card is available in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this gift card is available in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "tax_rate", "type": "``null`` \\| `number`", "description": "The gift card's tax rate that will be applied on calculating totals", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "value", "type": "`number`", "description": "The value that the Gift Card represents.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### delete Delete a gift card. Once deleted, it can't be used by customers. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.giftCards.delete(giftCardId).then(({ id, object, deleted }) => { console.log(id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ___ ### list Retrieve a list of gift cards. The gift cards can be filtered by fields such as `q` passed in the `query` parameter. The gift cards can also paginated. #### Example To list gift cards: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.giftCards.list().then(({ gift_cards, limit, offset, count }) => { console.log(gift_cards.length) }) ``` By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.giftCards .list({ limit, offset, }) .then(({ gift_cards, limit, offset, count }) => { console.log(gift_cards.length) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "order", "type": "[Order](../internal/classes/internal.Order.mdx)", "description": "The details of the order that the gift card was purchased in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "order_id", "type": "`string`", "description": "The ID of the order that the gift card was purchased in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this gift card is available in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this gift card is available in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "tax_rate", "type": "``null`` \\| `number`", "description": "The gift card's tax rate that will be applied on calculating totals", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "value", "type": "`number`", "description": "The value that the Gift Card represents.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### retrieve Retrieve a gift card's details. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.giftCards.retrieve(giftCardId).then(({ gift_card }) => { console.log(gift_card.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "order", "type": "[Order](../internal/classes/internal.Order.mdx)", "description": "The details of the order that the gift card was purchased in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "order_id", "type": "`string`", "description": "The ID of the order that the gift card was purchased in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this gift card is available in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this gift card is available in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "tax_rate", "type": "``null`` \\| `number`", "description": "The gift card's tax rate that will be applied on calculating totals", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "value", "type": "`number`", "description": "The value that the Gift Card represents.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### update Update a gift card's details. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.giftCards .update(giftCardId, { region_id, }) .then(({ gift_card }) => { console.log(gift_card.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs to hold additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the Region in which the Gift Card can be used.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "order", "type": "[Order](../internal/classes/internal.Order.mdx)", "description": "The details of the order that the gift card was purchased in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "order_id", "type": "`string`", "description": "The ID of the order that the gift card was purchased in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this gift card is available in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this gift card is available in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "tax_rate", "type": "``null`` \\| `number`", "description": "The gift card's tax rate that will be applied on calculating totals", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "value", "type": "`number`", "description": "The value that the Gift Card represents.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} />