Magento API create order

Magento 2 API Create an order

In this post, I will show you how to create an order using an offline payment method. Therefore, with this endpoint below, it only requires the payment method and billing address information. Follow our example code to create your own order.

Step 1: Generate Access Token

First, to create a customer account, admin authorization is required. Complete the following steps to authorize access to resources:

In the POST request enter your store URL along with this endpoint.

POST <host>/rest/V1/integration/customer/token

Enter your customer username and password in Body sections, then click Send

  "username": "string",
  "password": "string"

Step 2: Create an order

When you request payment details, Magento makes an order and sends a confirmation of the order to the customer.

Create a new request with this endpoint:

POST <host>/rest/V1/carts/mine/payment-information

In the Authorization section:

  • Choose Type: Bearer Token
  • Then paste your token

In Payload section:

  "paymentMethod": {
    "method": "checkmo"
  "billing_address": {
    "email": "",
    "region": "Nevada",
    "region_id": 39,
    "region_code": "NV",
    "country_id": "US",
    "street": ["3703 Wescam Court"],
    "postcode": "89406",
    "city": "Fallon",
    "telephone": "860-212-5597",
    "firstname": "Julie",
    "lastname": "Lawson"


An order ID

Create order code

When you review the order as Admin, the response contains full details about the order, such as customer information, payment details for the order and each individual item.

Step 3: Verify the order

  1. Log in to the store with the example account and check your order.
  2. Log in to your Magento Admin. Then go to Sales > Orders. Use the order Id to search for your pending order.
Verify order as admin

Above, I have just provided you with three steps on how to convert the quote to an order. I hope it would be helpful for you when creating an order using Magento API. For more information, you can refer to Magento DevDocs. If you have any questions or new ideas, feel free to leave a comment below.

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email