Skip to main content
Skip to main content

GiftCardsResource

This class is used to send requests to Store Gift Card API Routes. All its method are available in the JS Client under the medusa.giftCards property.

Customers can use gift cards during checkout to deduct the gift card's balance from the checkout total. The methods in this class allow retrieving a gift card's details by its code. A gift card can be applied to a cart using CartsResource.

Related Guide: How to use gift cards in a storefront.

Methods

retrieve

Retrieve a Gift Card's details by its associated unique code.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.giftCards.retrieve(code)
.then(({ gift_card }) => {
console.log(gift_card.id);
})

Parameters

codestringRequired
The code of the gift card.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<StoreGiftCardsRes>Required
Resolves to the details of the gift card.
Was this section helpful?