Command 39 — Create product ordersmulti-step
One V1 call becomes several V2 calls.
Permissions
Section titled “Permissions”V2 checks an app permission on every call — V1 checked none — and a call whose permission is missing answers 400 with errorCode 15, the same status as an invalid payload (see 4.4). Grant these to the API user before porting the command; the names are the ones of the permission tree in flowww.
| Call | Permission |
|---|---|
POST /order/{orderGID}/num/0/detail/product/{productID} | Stock Control - Orders → Add product |
POST /order/{orderGID}/num/0/send | Stock Control - Orders → Send products to clinic |
POST /order | Stock Control - Orders → Create |
DELETE /order/{orderGID}/num/{orderGPartNum} | Stock Control - Orders → Delete |
POST /order/{orderGID}/clone | Stock Control - Orders → Clone orders |
PUT /order | Stock Control - Orders → Automatic orders |
GET /order | Stock Control - Orders → List |
GET /order/246/num/0/send | Stock Control - Orders → Send orders to the centre |
The flow
Section titled “The flow”- 1
POST /order?clinicID={n}
Creates the order, empty →{"OrderGID": 246}
The one call of cmd 39 - 2
POST /order/{orderGID}/num/0/detail/product/{productID}
Once per line, with{"OrderProductUnits": n}
Products[]=id,units,price - 3
POST /order/{orderGID}/num/0/send
Sends it to the purchasing centre
Automatic — V1 shipped it for you
The same order, call by call:
curl --location 'https://euapi.flowww.net/v1/fwa_external_get.asp?cmd=39&doctor=USER_LOGIN&pass=USER_PASS&country=ES&key=SYSTEM_KEY&ClinicID=1' \ --data-urlencode 'Products[]=178,3,29.99' \ --data-urlencode 'Products[]=589,2'
<Cmd39><Result>1</Result> <Order><Id>246</Id></Order></Cmd39>curl --location --request POST 'https://api.flowww.net/v2/order?clinicID=1' \ --header 'Authorization: Bearer <api_key>'
→ { "OrderGID": 246 }curl --location 'https://api.flowww.net/v2/order/246/num/0/detail/product/178?clinicID=1' \ --header 'Authorization: Bearer <api_key>' \ --header 'Content-Type: application/json' \ --data '{"OrderProductUnits": 3}'
curl --location 'https://api.flowww.net/v2/order/246/num/0/detail/product/589?clinicID=1' \ --header 'Authorization: Bearer <api_key>' \ --header 'Content-Type: application/json' \ --data '{"OrderProductUnits": 2}'curl --location 'https://api.flowww.net/v2/order/246/num/0/send?clinicID=1' \ --header 'Authorization: Bearer <api_key>'To reproduce what V1 did, the purchasing centre then accepts it and ships it: see command 102 and command 103.
Cleaning up after a failure
Section titled “Cleaning up after a failure”Like a sale, an order is built in several calls, and a failure half-way leaves it behind: created and, depending on where you failed, with some of its lines and never sent. Keep the OrderGID that step 1 returns before you carry on: it is what lets you come back to it, to finish it or to delete it.
DELETE /order/{orderGID}/num/{orderGPartNum} removes it, lines included: it deletes the detail and the header in one go, and unlike the invoice’s delete it does not need the order to be empty first.
curl --location --request DELETE 'https://api.flowww.net/v2/order/246/num/0?clinicID=1' --header 'Authorization: Bearer <api_key>'| Answer | Meaning |
|---|---|
404 (errorCode 241) | No order with that id and part number. |
Field mapping
Section titled “Field mapping”| API V1 | API V2 | Notes |
|---|---|---|
ClinicID | ?clinicID= on POST /order | The ordering clinic. It must have a purchasing centre assigned. |
Products[] 1st element (product id) | {productID} in the path | The product of the clinic’s tariff; it is matched to the purchasing centre’s tariff. |
Products[] 2nd element (units) | OrderProductUnits | Send a whole number greater than 0: a missing or invalid value is changed to 1 without error (V1 rejected it). |
Products[] 3rd element (cost price) | — | Gap: not accepted. The cost price comes from the clinic’s setting origin of the purchase price (purchasing centre’s price, weighted average or the clinic’s own cost). |
<Order><Id> | OrderGID | Part number 0 until the order is split. |
What changes compared with V1
Section titled “What changes compared with V1”| Topic | API V1 | API V2 |
|---|---|---|
| Shipment | Automatic, from the purchasing centre (see above). | Separate calls. |
| Atomicity | An unknown product cancelled the whole order. | Each line is saved on its own: an unknown product fails that line only, and the order stays with the others. |
| Same product twice | Two lines. | The units are added to the existing line when the product and its cost are the same. |
| Lines on an order already sent | — | Accepted: V2 does not check the state of the order. Add lines only to pending orders. |
| Providers | Lines of products supplied by an external provider went to their own order part, and the provider was emailed. | Same, when the order is shipped. |
Errors
Section titled “Errors”| Step | Answer | Meaning | What to do |
|---|---|---|---|
1 | 400 242 | The clinic of the clinicID you sent has no purchasing centre. | Assign one in the application, or call from a clinic that has one. Nothing was created. |
3 | 400 238 | Order or product not found, or the product is not in the purchasing centre’s tariff. | Check the product. |
3 | 400 520 | More units than the product allows per order. | Split the order. |
3 | 400 | Comments longer than 150 characters. | Shorten them. |
| any | 400 (errorCode 15) | The API user lacks Stock control → Orders permissions. | Grant them. |
If the flow fails half-way, delete the incomplete order with DELETE /order/{orderGID}/num/{orderGPartNum}, or complete it on retry — do not create a new one.
New in V2 and worth knowing: POST /order/{orderGID}/clone replicates an order into other clinics, and PUT /order generates automatic orders.