Manual orders
Build an order for a customer, share a payment link, and turn it into an order.
Andrea messages you on WhatsApp from Trujillo and asks for two T-shirts. You build her order with the Admin API, send her a link, and she pays in your store.
Requirements
- An Admin token with the
draft:create,draft:read, anddraft:updatepermissions inECOMIQ_TOKEN. To record a payment, alsoorder:updateandpayment:create. See Quickstart. - The
/route in your store. Ecomiq themes already have it. In a headless store, you build it.drafts/ {shareToken} - Node.js, or Python with
requests, for the examples.
Create the draft
A manual order starts as a draft. Send the currency and the customer's details.
curl -X POST https://api.ecomiq.pe/api/v1/order-drafts \
-H "Authorization: Bearer $ECOMIQ_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"currencyCode": "PEN",
"email": "andrea.ramos@example.com",
"firstName": "Andrea",
"lastName": "Ramos",
"phone": "+51987654321",
"source": "whatsapp"
}'It returns 201 with the draft's id. The next steps reuse ADMIN,
headers, and HEADERS.
- Without
customerId, sendemail,firstName, andlastName. With it, the draft copies the customer's details and default address. - The draft starts as
draftand gets a store number:D1,D2… GET /sorts byv1/ order-drafts draftDatedescending. Change the order withsortBy(draftDate,draftNumber,total,createdOn, orupdatedOn) andsortDirection(ascordesc).
Add the products
Add a catalog variant with its quantity. discount is the discount for the
whole line, as a negative amount, or 0 for none. shipping adds up each
line's shipping and the selected shipping methods.
curl -X POST https://api.ecomiq.pe/api/v1/order-drafts/7204558912004324769/items \
-H "Authorization: Bearer $ECOMIQ_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"kind": "catalogVariant",
"variantId": "7204558912004321180",
"quantity": 2,
"discount": -20
}'{
"items": [
{
"id": "7204558912004323771",
"title": "Cotton T-shirt",
"quantity": 2,
"discount": -20.0,
"total": 158.0
}
],
"tax": 24.1,
"total": 158.0
}unitPricechanges the price in this draft only. For something outside the catalog, use"kind": "custom"withtitleandunitPrice.- Tax on catalog products is calculated for you.
- Change a line with
PATCH /. Usev1/ order-drafts/ {draftId}/ items/ {itemId} quantity: 0orDELETEto remove it.
Add the address and shipping
Send the shipping address. PATCH only changes what you send.
curl -X PATCH https://api.ecomiq.pe/api/v1/order-drafts/7204558912004324769 \
-H "Authorization: Bearer $ECOMIQ_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"shippingAddress": {
"name": "Andrea Ramos",
"address1": "Av. España 1520",
"city": "Trujillo",
"countryCode": "PE"
}
}'Then ask for the shipping options for that address.
curl https://api.ecomiq.pe/api/v1/order-drafts/7204558912004324769/shipping-options \
-H "Authorization: Bearer $ECOMIQ_TOKEN"Each option has displayName, price, shippingMethodId, target,
targetId, and rateId. Set one with those last four values; the draft ends up
with shipping: 12 and total: 170.
curl -X PUT https://api.ecomiq.pe/api/v1/order-drafts/7204558912004324769/shipping-method \
-H "Authorization: Bearer $ECOMIQ_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "shippingMethodId": "7204558912004328810", "target": "automatic" }'- Send
billingAddressthe same way: converting needs both, each withname,address1,city, andcountryCode. - If you change the shipping address or the products, set the shipping again.
DELETE /removes it.v1/ order-drafts/ {draftId}/ shipping-method - With several sellers or shipping profiles, each group needs its own shipping:
pass
sellerIdorshippingProfileId.
Share the payment link
Create the link and send it to the customer on WhatsApp. shareExpiresAt is
optional and must be in the future; without it, the link never expires.
curl -X POST https://api.ecomiq.pe/api/v1/order-drafts/7204558912004324769/share \
-H "Authorization: Bearer $ECOMIQ_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "shareExpiresAt": "2026-10-09T05:00:00Z" }'{
"shareToken": "Jm2xQ9vT4pLk8sWb1nZr6cYh0uEa3dFg",
"sharePath": "/drafts/Jm2xQ9vT4pLk8sWb1nZr6cYh0uEa3dFg"
}The link is your store's primary domain plus sharePath. See
List store domains.
- The draft moves to
sent. Each call creates a new token and the previous one stops working. - With
"allowAnonymousShareAccess": false, the customer must sign in to your store. - To send it by email, use Send draft invoice.
Collect in your store
At /, your store shows the draft with the Storefront API.
When the customer confirms, it turns the draft into an order.
The GET returns what the buyer sees: draft number and status, contact,
addresses, items with shipping, tax, and warranty, amounts, and shipping
methods with their price and delivery dates. Internal notes, tags, and metadata
aren't included.
curl https://storefront.ecomiq.pe/v1/order-drafts/share/<share-token> \
-H "x-Store-Domain: mi-tienda"
curl -X POST https://storefront.ecomiq.pe/v1/order-drafts/share/<share-token>/checkout \
-H "x-Store-Domain: mi-tienda" \
-H "Content-Type: application/json" \
-d '{ "invoiceType": "ticket" }'The checkout returns orderPaths, with / paths. Send the
customer there to pay the balance, as in
Checkout and payment.
- Opening the draft moves it to
viewed, and the checkout toconverted. Check it withGET /, or list the viewed ones withv1/ order-drafts/ {draftId} GET /.v1/ order-drafts?status=viewed - If it was already converted,
GETreturnsorderPaths: redirect the customer. - One order is created per seller and shipping profile, each with its own path.
Or collect from the admin
If the customer already paid with Yape, convert the draft yourself.
curl -X POST https://api.ecomiq.pe/api/v1/order-drafts/7204558912004324769/convert \
-H "Authorization: Bearer $ECOMIQ_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "invoiceType": "ticket" }'{
"orderIds": ["7204558912004325350"],
"order": {
"orderNumber": "ORD-2026-0001",
"status": "new",
"financialSummary": { "balanceDue": 170.0 }
}
}Then record the payment on each order in orderIds, for its balanceDue.
curl -X POST https://api.ecomiq.pe/api/v1/orders/7204558912004325350/payments \
-H "Authorization: Bearer $ECOMIQ_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "method": "yape", "currencyCode": "PEN", "amount": 170,
"reference": "Operation 845120", "idempotencyKey": "D1-yape" }'- Converting needs items, both addresses, and shipping for each group.
- If the draft was already converted, it returns
200with the same orders. - When the payment covers the total, the order moves to
confirmed.
Cancel a draft
You don't delete a draft: you cancel it.
curl -X POST https://api.ecomiq.pe/api/v1/order-drafts/7204558912004324769/cancel \
-H "Authorization: Bearer $ECOMIQ_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "reason": "The customer bought in store." }'- The draft moves to
cancelledand its link stops working. reasonis required, with a maximum of 500 characters. The admin detail stores it ascancelReason; the draft notes are preserved.- A
converteddraft can't be cancelled: cancel its order instead.
Errors
code | Status | What to do |
|---|---|---|
Common.Validation | 400 | Check errors: a field is missing or has the wrong format. |
OrderDrafts.NotFound | 404 | The draft doesn't exist in this store. |
Catalog.VariantUnavailable | 409 | The product or variant isn't for sale. |
Catalog.InsufficientStock | 400 | Not enough stock for that quantity. Lower it. |
ShippingMethods.GroupRequired | 400 | The draft has several groups. Send sellerId or shippingProfileId. |
ShippingMethods.MethodNotAvailable | 400 | The shipping no longer applies. Ask for the options again. |
OrderDrafts.ShippingAddressRequired | 400 | Add the shipping address. |
OrderDrafts.BillingAddressRequired | 400 | Add the billing address. |
OrderDrafts.ShippingMethodRequired | 400 | A group is missing its shipping. |
OrderDrafts.ShareNotFound | 404 | The token doesn't exist or was replaced. Ask for the new link. |
OrderDrafts.ShareNotAvailable | 404 | The link expired, was replaced, or the draft was cancelled. |
OrderDrafts.AuthenticationRequired | 401 | The link requires a session. Ask the customer to sign in. |
Common.Conflict | 409 | The draft is already converted or cancelled, or has no items. |
Next steps
Last updated: