Skip to main content

Create Order

The POST endpoint creates a new order with the specified details.

Endpoint

  • URL: /orders
  • Method: POST

Authentication

  • Header: accessToken
  • Type: Bearer Token
  • Value: <ACCESS-TOKEN>

Request Headers

HeaderTypeDescription
Content-TypestringMust be application/json.
accessTokenstringAccess token for authentication. (required)

Request Body

The request body must include details of the order to be created. Below are the fields required:

FieldTypeRequirements/Notes
customerjoiIdRequired - Unique identifier for the customer.
paymentStatusenumRequired - Valid values: "unpaid", "authorized", "declined", .., "refunded".
orderStatusenumRequired - Valid values: "fulfilled", "pending", ..., "cancelled".
fulfilledItemsarray of objectsItems defined in Fulfilled Items.
taxAmountnumberTotal tax amount for the order.
billingAddressjoiIdIdentifier for the existing billing address.
newBillingAddressobjectDefined in New Billing Address.
paymentTermjoiIdId of payment term assigned for that company
shippingAddressIdjoiIdIdentifier for the existing shipping address.
newShippingAddressobjectDefined in New Shipping Address.
orderedAtstringDate and time when the order was placed.
refundedAmountnumberTotal refunded amount.
shippingCostnumberCost of shipping, must be positive or zero.
shippingLabelstringLabel for the shipping, allows empty or null.
currencyobjectProperties: currency (2-char string), symbol (2-char string).
lineItemsarray of objectsRequired - Items defined in Line Items.
metaFieldsarray of objectsCollection of metaField objects.

Fulfilled Items

FieldTypeRequirements/Notes
itemsarray of objectsItems defined in Fulfilled Item.
carrierstringCarrier used for shipping.
trackingNumberstringTracking number for the shipment.
trackingUrlstringURL for tracking the shipment.
fulfilledAtstringDate and time when the order was fulfilled.

Fulfilled Item

FieldTypeRequirements/Notes
lineItemIdstringIdentifier for the line item.
quantitynumberRequired - Must be positive or zero.
metaFieldobjectProperties: code (string), value (string).
skustringStock Keeping Unit.
optionsarray of objectsProperties: name (string), value (string).

Product Options

FieldTypeRequirements/Notes
optionNamestringNon-empty string for option name.
optionValueLabelstringNon-empty string for option value label.
optionValuestringNon-empty string for the option value.

Product Discount

FieldTypeRequirements/Notes
idjoiIdUnique identifier for the discount.
namestringName of the discount.
discountedAmountnumberRequired - The amount of the discount.

Line Items

FieldTypeRequirements/Notes
productIdjoiIdIdentifier for the product.
variantIdjoiIdIdentifier for the product variant.
quantitynumberRequired - Must be positive or zero.
discountsarray of objectsDiscounts applied, defined in Product Discount.
discountAmountnumberTotal discount amount.
pricenumberRequired - Price of the line item.
fulfilledQuantitynumberMust be positive or zero.
returnedbooleanIndicates if the item was returned.

New Shipping Address

FieldTypeRequirements/Notes
companyNamestringCompany name of this contact (Optional).
companyEmailstringCompany email of the contact (Optional).
firstNamestringMin Length: 1
lastNamestringMin Length: 1, Allows empty string ("").
address1stringMin Length: 1, Max Length: 100
address2stringMin Length: 1, Max Length: 100
phoneNumberstringMin Length: 1, Max Length: 100
citystringMin Length: 1, Max Length: 100
statestringMin Length: 1, Max Length: 100
countrystringMin Length: 1, Max Length: 100
zipcodestringMin Length: 1, Max Length: 100

New Billing Address

FieldTypeRequirements/Notes
companyNamestringCompany name of this contact (Optional).
companyEmailstringCompany email of the contact (Optional).
firstNamestringMin Length: 3, Max Length: 20
lastNamestringMin Length: 3, Max Length: 20, Allows empty string ("").
address1stringMin Length: 1, Max Length: 100
address2stringMin Length: 1, Max Length: 100
phoneNumberstringMin Length: 1, Max Length: 100
citystringMin Length: 1, Max Length: 100
statestringMin Length: 1, Max Length: 100
countrystringMin Length: 1, Max Length: 100
zipcodestringMin Length: 1, Max Length: 100

Notes

  • The orderSchema requires either shippingAddressId or newShippingAddress, and either billingAddress or newBillingAddress to be present.

Sample Request Body

{
"customer": "6328113ba105cf37af7f623b",
"paymentStatus": "paid",
"orderStatus": "fulfilled",
"taxAmount": 0,
"billingAddress": "63356b3b3a6353a69043680b",
"shippingAddressId": "63356b3b3a6353a69043680c",
"newShippingAddress": {
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "65161861",
"address1": "12/4, test st",
"address2": "",
"city": "Elizabeth",
"state": "NJ",
"country": "US",
"zipcode": "07202"
},
"refundedAmount": 0,
"shippingCost": 0,
"shippingLabel": "UPS",
"shipmentDetails": {
"trackingNumber": "8498461648",
"carrier": "something",
"fulfilledAt": "2022-10-18",
"timeEstimate": "2 days"
},
"currency": {
"currency": "USD",
"symbol": "$"
},
"metaFields": [
{
"label": "orderId",
"value": "#123445363",
"displayStorefront": true
}
],
"lineItems": [
{
"productId": "636d07be0438c42bc4d455e3",
"variantId": "636d07be0438c42bc4d455f2",
"quantity": 10,
"price": 31.84
}
],
"fulfilledItems": [
{
"items": [
{
"lineItemId": "",
"quantity": ""
}
],
"carrier": "something",
"trackingNumber": "8498461648",
"fulfilledAt": "2022-10-20"
}
]
}

Response

  • Status Code: 200 Created

Success Response Body

{
"success": true,
"message": "Order created successfully",
"data": {
"id": "<Order ID>"
//...
}
}

Success Response Structure

FieldTypeDescription
successbooleanIndicates whether the request was successful.
messagestringProvides a descriptive message about the outcome.
dataobjectContains the details of the newly created order. Defines in Order Object.

Error Responses

Status CodeDescription
400Bad Request: Invalid input data.
401Unauthorized: Access token is invalid or missing.
500Internal Server Error: An error occurred on the server.

Notes

  • Ensure all required fields are provided in the request body.
  • Provide a valid and active access token in the request header to authenticate your request.
  • The response body will include details about the created order, such as the order ID and other order information.