Loading
Salesforce now sends email only from verified domains. Read More

Create Orders on behalf of customer via OCAPI in B2C Commerce

Publish Date: Feb 27, 2026
Description

The information provided in this article outline how an OCAPI implementation can create an order using OCAPI. The steps describe an order creation which places an order in CREATED state but please note that the payment authorization step after this is not included.  This should be used as a reference where OCAPI implementations need to create an order on behalf of the customer. The postman collection is attached.

 

Example scenarios
- Automatic recurring orders
- Customer service center

 

Pre-requisites:

  • Add customerNo to assign the order to a registered customer 
  • Since SSO is enabled, BM User password will be Access Key (Use Type: Agent User Login and OCAPI for Access key)

Endpoints/Request Calls flow:

  1. /dw/oauth2/access_token - get agent access token // Authentication: Business Manager user grant
  2. /dw/shop/v23_1/baskets - Create a basket and all the necessary info
  3. /dw/shop/v23_1/orders - Create order

Business Manager User functional permission: Create_Order_On_Behalf_Of

Example Variables:
SandboxURL: xxxx-xxx.dx.commercecloud.salesforce.com
siteID: RefArch
bmUsername: bmUsername@bmUsername.com
bmUserAccessKey: xxxx
ocapiClientID: Account_Manager_ClientID
ocapiClientPassword: Account_Manager_ClientPwd
customerEmail: x@gmail.com
customerNo: 000000001
product_id: productID to be added to cart and submitted for order.
 
Resolution

Example cURLS for 3 endpoints:

curl --location --request POST 'https://{{SandboxURL}}/dw/oauth2/access_token?client_id={{ocapiClientID}}&grant_type=urn%3Ademandware%3Aparams%3Aoauth%3Agrant-type%3Aclient-id%3Adwsid%3Adwsecuretoken' \
--header 'Authorization: Basic {{BASE64(bmUsername:bmUserAccessKey:ocapiClientPassword)}}' \
--header 'Content-Type: application/x-www-form-urlencoded'

 

curl --location 'https://{{SandboxURL}}/s/{{siteID}}/dw/shop/v23_1/baskets' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "customer_info": {
    "email": "{{customerEmail}}",
    "customer_no": "{{customerNo}}"}//other basket data
}'

curl --location 'https://{{SandboxURL}}/s/{{siteID}}/dw/shop/v23_1/orders' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
    "basket_id": "{{basket_id}}"
}'

Knowledge Article Number

000395402

Attachments

OCAPI- Agent Create Order.postman_collection.json

4 KB

OCAPI- Agent Create Order - Empty.postman_environment.json

1 KB

 
Loading
Salesforce Help | Article