Skip to content

Command 39 — Create product ordersmulti-step

One V1 call becomes several V2 calls.

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.

CallPermission
POST /order/{orderGID}/num/0/detail/product/{productID}Stock Control - Orders → Add product
POST /order/{orderGID}/num/0/sendStock Control - Orders → Send products to clinic
POST /orderStock Control - Orders → Create
DELETE /order/{orderGID}/num/{orderGPartNum}Stock Control - Orders → Delete
POST /order/{orderGID}/cloneStock Control - Orders → Clone orders
PUT /orderStock Control - Orders → Automatic orders
GET /orderStock Control - Orders → List
GET /order/246/num/0/sendStock Control - Orders → Send orders to the centre
  • 1POST /order?clinicID={n}
    Creates the order, empty → {"OrderGID": 246}
    The one call of cmd 39
  • 2POST /order/{orderGID}/num/0/detail/product/{productID}
    Once per line, with {"OrderProductUnits": n}
    Products[]=id,units,price
  • 3POST /order/{orderGID}/num/0/send
    Sends it to the purchasing centre
    Automatic — V1 shipped it for you

The same order, call by call:

API V1 — one 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>
API V2 — 1. Create an empty order for the clinic
curl --location --request POST 'https://api.flowww.net/v2/order?clinicID=1' \
--header 'Authorization: Bearer <api_key>'
→ { "OrderGID": 246 }
2. Add one line per product
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}'
3. Send it to the purchasing centre
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.

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.

Give up on an order
curl --location --request DELETE 'https://api.flowww.net/v2/order/246/num/0?clinicID=1' --header 'Authorization: Bearer <api_key>'
AnswerMeaning
404 (errorCode 241)No order with that id and part number.
API V1API V2Notes
ClinicID?clinicID= on POST /orderThe ordering clinic. It must have a purchasing centre assigned.
Products[] 1st element (product id){productID} in the pathThe product of the clinic’s tariff; it is matched to the purchasing centre’s tariff.
Products[] 2nd element (units)OrderProductUnitsSend 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>OrderGIDPart number 0 until the order is split.
TopicAPI V1API V2
ShipmentAutomatic, from the purchasing centre (see above).Separate calls.
AtomicityAn 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 twiceTwo 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.
ProvidersLines of products supplied by an external provider went to their own order part, and the provider was emailed.Same, when the order is shipped.
StepAnswerMeaningWhat to do
1400 242The 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.
3400 238Order or product not found, or the product is not in the purchasing centre’s tariff.Check the product.
3400 520More units than the product allows per order.Split the order.
3400Comments longer than 150 characters.Shorten them.
any400 (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.