Gift Card API Guide for Magento

Gift Card API

Info
We have created public API collections for Gift Card module and its Gift Card Account submodule with all available queries and sample data that you can both test via our demo endpoints and copy to run local tests in your Magento environment. More details about using public collections can be found in the following FAQ post.

1. Amasty\GiftCard\Api\ImageRepositoryInterface - class for managing gift card images: 
  1. POST /V1/amgcard/image, method="save" - save a gift card image;
  2. PUT /V1/amgcard/image/:id, method="save" - save a gift card image by ID;
  3. DELETE /V1/amgcard/image/:id, method="deleteById" - delete a gift card image by ID;
  4. GET /V1/amgcard/image/:id, method="getById" - get a gift card image by ID;
  5. GET /V1/amgcard/image/all, method="getList" - get a list of all gift card images.

2. Amasty\GiftCard\Api\CodePoolRepositoryInterface - class for managing gift card code pools:
  1. POST /V1/amgcard/code-pool, method="save" - create a code pool;
  2. PUT /V1/amgcard/code-pool/:id, method="save" - edit a specific code pool by ID; 
  3. DELETE /V1/amgcard/code-pool/:id, method="deleteById" - delete a code pool by ID;
  4. GET /V1/amgcard/code-pool/:id, method="getById" - get a code pool data by ID; 
  5. GET /V1/amgcard/code-pool/all, method="getList" - get the list of all code pools.

3. Amasty\GiftCard\Api\CodeGeneratorManagementInterface - class for gift card code generation: 
  1. PUT /V1/amgcard/code-generator/code-pool/:codePoolId/qty/:qty, method="generateCodesForCodePool" - generate gift card codes;
  2. PUT /V1/amgcard/code-generator/code-pool/:codePoolId, method="generateCodesByTemplate" - generate gift card codes by template.

4. Amasty\GiftCardAccount\Api\GiftCardAccountRepositoryInterface - class for gift account processing:
  1. POST /V1/amgcard/account,  method="save" - save a gift card account;
  2. PUT /V1/amgcard/account/, method="save" - save a gift card account by ID;
  3. DELETE /V1/amgcard/account/:id, method="deleteById" - delete a gift card account by ID;
  4. GET /V1/amgcard/account/:id, method="getById"/> - get a gift card account by ID;
  5. GET /V1/amgcard/account/code/:code, method="getByCode - get a gift card account by code;
  6. GET /V1/amgcard/account/order/:orderId, method="getByOrderId" - get a gift card account by order ID;
  7. GET /V1/amgcard/account/all, method="getList" - get all gift card accounts;
  8. POST /V1/amgcard/account/send, method="send" - send a gift card account email;
  9. DELETE /V1/guest-carts/:cartId/gift-card/:giftCardCode, method="removeGiftCardFromCart"/> - delete gift card from guest cart;
  10. PUT /V1/guest-carts/:cartId/gift-card/:giftCardCode, method="applyGiftCardToCart"/> - apply a gift card to guest cart;
  11. DELETE /V1/carts/mine/gift-card/:giftCardCode, method="removeGiftCardFromCart - delete a gift card from customer cart;
  12. PUT /V1/carts/mine/gift-card/:giftCardCode, method="applyGiftCardToCart - apply a gift card to customer cart;
  13. PUT V1/carts/mine/gift-card-account/:giftCardCode, method="applyGiftCardAccountToCart"/> - apply a gift card account to customer cart.

FAQ

Q: Can I get an example of Gift Card account creation via API? 

A: A new gift card account can be created with the following API request: /rest/V1/amgcard/account. It requires specific parameters to be passed in the request body. Please find the example of the request body below:
{
"account": {
"code_id": 1,
"image_id": 1,
"website_id": 1,
"status": 1,
"initial_value": 10,
"current_value": 6
}
}


Fill in the values in the request body with the required data. Kindly note that to create a new entity (i.e. for a request with POST type), you don't need to specify the account ID, since it is auto-incremented.



Click the Send button and check the created gift card account in Magento admin. 
      • Related Articles

      • Gift Wrap API

        We have created a public API collection for Gift Wrap module with all available queries and sample data that you can both test via our demo endpoints and copy to run local tests in your Magento environment. More details about using public collections ...
      • What Amasty extensions support API?

        Each Amasty extension that has API support, includes the etc/webapi.xml file. The webapi.xml file contains API configurations with the list of available API requests. For example, a request from the Custom Form module interface: 1 - endpoint URL; 2 - ...
      • Can I test how your modules work with API?

        Our team have created a public Postman workspace where we provide access to API collections from our modules. You can copy these API collections to test them in your own Magento installation together with our modules, and some collections can be ...
      • Gift Card | GraphQL methods

        Queries amGiftCardAccount(input: AmGiftCardAccountInput!) description: get gift card account information by code amGiftCardSetting description: get gift card module settings amGiftCardPreview(input: AmGiftCardPreviewInput) description: get rendered ...
      • Advanced Conditions API (+Reward Points, Extra Fee, Free Gift, Shipping Rules, Shipping Restrictions)

        We have created a public API collection for Advanced Conditions module with all available queries and sample data, you can copy it to run local tests in your Magento environment. More details about using public collections can be found in the ...