--- 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<`string`, `any`\\>", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ", "optional": false, "defaultValue": "", "description": "Resolves to the gift card's details.", "expandable": false, "children": [ { "name": "AdminGiftCardsRes", "type": "`object`", "description": "The gift card's details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "gift_card", "type": "[`GiftCard`](../internal/classes/internal.GiftCard-1.mdx)", "description": "A gift card's details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "balance", "type": "`number`", "description": "The remaining value on the Gift Card.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "code", "type": "`string`", "description": "The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "created_at", "type": "`Date`", "description": "The date with timezone at which the resource was created.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "deleted_at", "type": "``null`` \\| `Date`", "description": "The date with timezone at which the resource was deleted.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "ends_at", "type": "`Date`", "description": "The time at which the Gift Card can no longer be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The gift card's ID", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "is_disabled", "type": "`boolean`", "description": "Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.", "optional": false, "defaultValue": "false", "expandable": false, "children": [] }, { "name": "metadata", "type": "Record<`string`, `unknown`\\>", "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 ", "optional": false, "defaultValue": "", "description": "Resolves to the deletion operation's details.", "expandable": false, "children": [ { "name": "deleted", "type": "`boolean`", "description": "Whether the item was deleted successfully.", "optional": false, "defaultValue": "true", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The ID of the deleted item.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "object", "type": "`string`", "description": "The type of the deleted item.", "optional": false, "defaultValue": "product-collection", "expandable": false, "children": [] } ] } ]} /> ___ ### 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 ", "optional": false, "defaultValue": "", "description": "Resolves to the list of gift cards with pagination fields.", "expandable": false, "children": [ { "name": "AdminGiftCardsListRes", "type": "[`PaginatedResponse`](../internal/interfaces/internal.PaginatedResponse.mdx) & { `gift_cards`: [`GiftCard`](../internal/classes/internal.GiftCard-1.mdx)[] }", "description": "The list of gift cards with pagination fields.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "count", "type": "`number`", "description": "The total number of items available.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "limit", "type": "`number`", "description": "The maximum number of items that can be returned in the list.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "offset", "type": "`number`", "description": "The number of items skipped before the returned items in the list.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "gift_cards", "type": "[`GiftCard`](../internal/classes/internal.GiftCard-1.mdx)[]", "description": "The list of gift cards.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "balance", "type": "`number`", "description": "The remaining value on the Gift Card.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "code", "type": "`string`", "description": "The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "created_at", "type": "`Date`", "description": "The date with timezone at which the resource was created.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "deleted_at", "type": "``null`` \\| `Date`", "description": "The date with timezone at which the resource was deleted.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "ends_at", "type": "`Date`", "description": "The time at which the Gift Card can no longer be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The gift card's ID", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "is_disabled", "type": "`boolean`", "description": "Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.", "optional": false, "defaultValue": "false", "expandable": false, "children": [] }, { "name": "metadata", "type": "Record<`string`, `unknown`\\>", "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 ", "optional": false, "defaultValue": "", "description": "Resolves to the gift card's details.", "expandable": false, "children": [ { "name": "AdminGiftCardsRes", "type": "`object`", "description": "The gift card's details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "gift_card", "type": "[`GiftCard`](../internal/classes/internal.GiftCard-1.mdx)", "description": "A gift card's details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "balance", "type": "`number`", "description": "The remaining value on the Gift Card.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "code", "type": "`string`", "description": "The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "created_at", "type": "`Date`", "description": "The date with timezone at which the resource was created.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "deleted_at", "type": "``null`` \\| `Date`", "description": "The date with timezone at which the resource was deleted.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "ends_at", "type": "`Date`", "description": "The time at which the Gift Card can no longer be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The gift card's ID", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "is_disabled", "type": "`boolean`", "description": "Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.", "optional": false, "defaultValue": "false", "expandable": false, "children": [] }, { "name": "metadata", "type": "Record<`string`, `unknown`\\>", "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<`string`, `any`\\>", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ", "optional": false, "defaultValue": "", "description": "Resolves to the gift card's details.", "expandable": false, "children": [ { "name": "AdminGiftCardsRes", "type": "`object`", "description": "The gift card's details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "gift_card", "type": "[`GiftCard`](../internal/classes/internal.GiftCard-1.mdx)", "description": "A gift card's details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "balance", "type": "`number`", "description": "The remaining value on the Gift Card.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "code", "type": "`string`", "description": "The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "created_at", "type": "`Date`", "description": "The date with timezone at which the resource was created.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "deleted_at", "type": "``null`` \\| `Date`", "description": "The date with timezone at which the resource was deleted.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "ends_at", "type": "`Date`", "description": "The time at which the Gift Card can no longer be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The gift card's ID", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "is_disabled", "type": "`boolean`", "description": "Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.", "optional": false, "defaultValue": "false", "expandable": false, "children": [] }, { "name": "metadata", "type": "Record<`string`, `unknown`\\>", "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": [] } ] } ] } ] } ]} />