cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 - REST API - Create order for customer with admin token

Magento 2 - REST API - Create order for customer with admin token

Hi,

I'm working on an app for Magento store. and I want to create an order for customers with my admin token.

I found 2 ways: 

1. To get the customer credentials (user name and password) and create a queue - But I can't get all the users credentials.

2. create a guest order but I didn't find a way to add the customer’s id only email.

so the order is not linked to the customer's orders history.

 

is there a way to create an order for customer with admin token? and link to order to the customer profile?

 

Thanks!

2 REPLIES 2

Re: Magento 2 - REST API - Create order for customer with admin token

Hello @zivothergmbe01 

 

There is no such feature in rest api which can help you to create order for any customer without using customer token, you first have to create order from customer account.

 

You can customize code and create a new API which will work that way, but for now there is no default API.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Magento 2 - REST API - Create order for customer with admin token

Hi @zivothergmbe01 

You can create an order for customers with my admin token

1. Using this API https://magento.redoc.ly/2.4-admin/#operation/twoFactorAuthAdminTokenServiceV1CreateAdminAccessToken... you can get a token then pass to the API create order if your admin account has permission to do that

2. Create order API https://magento.redoc.ly/2.4-admin/tag/orders#operation/salesOrderRepositoryV1SavePost - in this one, you can use customer email (please check parameter required in the spec) => So you can link the order to the customer profile