How to Create Guest Carts (V1/guest-carts) token by REST API Magento 2?

Create a Guest Customer cart token by API V1/guest-carts in Magento to create an empty cart token.

Action: POST

URL: <WEBSITE_URL>/rest/<STORE_CODE>/V1/guest-carts  (Example, https://magento.test/rest/default/V1/guest-carts)

Payload: Empty

Response: fQtl1bxLdxud1fFEP68znOAPnAFFpjVh

The API’s response will be a random string called masked_id and you can see this masked_id value from the quote_id_mask table in the database.

You may also be interested in Guest Place Order Flow REST API Magento 2.

How to redirect to third party URL from the REST API Response Magento 2?

You can redirect to a third-party URL from the response of the rest API operation in Magento with some simple code snippets.

We can redirect to a third-party URL with a PHP method header(“Location: URL”) in the REST API but this is the not standard way to redirect using the header method in Magento. Continue reading “How to redirect to third party URL from the REST API Response Magento 2?”

How to delete customer group id by REST Web API Magento 2?

Customer is assigned to customer group id in Magento. By default when you create a customer, it has assigned to Default (General) Customer group id.

If you want to delete a customer group id without going to the admin panel, you need to help of REST web API to delete it.

Magento REST Web API provides the Out of the box feature to delete customer group id by its Id.

You have to pass Header as Admin Token to delete customer group id in Magento.

INTERESTING FACTS:
You can’t delete customer group id with 0 (NOT LOGGED IN) and 1 (DEFAULT(GENERAL)).

EndPoint URL: <HOST_URL>/rest/V1/customerGroups/:id
(http://127.0.0.1/magento243/rest//V1/customerGroups/5 Where 5 is the customer group id to delete.)

Action: DELETE

Header: Authorization Bearer <Admin_TOKEN>

Payload Body: None

Response: True/False.

Once you delete the customer group id, the customer has been assigned automatically to the Default(General).