Stock from your ERP
هذا المحتوى غير متوفر بلغتك بعد.
When your ERP keeps the company’s stock, every move starts there. The storekeeper makes a transfer journal from the warehouse to a van; you send it to SLFLO; the goods appear on the van in the rep’s app; the rep accepts or refuses it; you read the answer and post the journal, or show the refusal to the storekeeper. SLFLO never changes the quantities you sent: the rep accepts the load as it is or refuses it with a reason.
Before the first load
Section titled “Before the first load”- An administrator turns on Stock is managed in your ERP in Settings › Integrations (it needs
an active integration with
stock:write— yours).GET /meanswers it asdata.company.stock_managed_by_erp; check it when your job starts. While it isfalseevery send, cancel and unload is refused with409 ERP_STOCK_NOT_ENABLED— hold your sends until it is on. What the switch locks in the console and on the phone is on the help page Stock managed in your ERP and in ERP mode. - Your client needs
stock:writeto send and cancel, andstock:readto read the answers. - Places are named by their SLFLO location code (
VAN-03,WH-MAIN): give each van and warehouse in your ERP a SLFLO reference, or name them alike. Check a van before you send to it withGET /lookup?entity=van&external_ref=VAN-03— the answer addsvan.rep(whose van it is) andvan.held_back_code(VAN-03-Q). - Push the products and their units first (master data).
A product SLFLO tracks by lot needs a
loton its lines; one it doesn’t track must have none. Ask withGET /lookup?entity=product&external_ref=ITEM-1001:product.trackingisBATCH(send alot),NONEorSERIAL.
The flow
Section titled “The flow”- The storekeeper saves the journal and sends it:
PUT /stock/loads/{ref}, whererefis your journal id. Store the answer’sid(SLFLO’s load id) andnumber(LD-000231). - The goods are on the van at once, waiting. The rep can’t sell from the van until the load is accepted.
- The rep accepts or refuses on the phone. Read
GET /stock/loads?filter[version_after]=…. - Accepted: post the journal. Refused: show
refusal.reasonandrefusal.noteto the storekeeper — SLFLO already took the goods off the van. - The storekeeper fixes the journal and sends it again with the same ref: a new load with a
new
LD-number,resent_frompointing at the refused one. Or deletes it:DELETE /stock/loads/{ref}. - At the end of the day the rep taps End day; the storekeeper counts the van and posts the
unload journal; you send it once:
PUT /stock/unloads/{ref}. A shortage in the count is the rep’s, on the office’s end of day.
Karim’s day
Section titled “Karim’s day”Karim Adel (rep R012) drives VAN-03 out of WH-MAIN. Cola (ITEM-1001, SLFLO code
SKU-COLA) is tracked by lot and comes in cases of 24. Every call below is on this page.
| Time | In your ERP | Your call | In SLFLO |
|---|---|---|---|
| 05:00 | Journal TJ-000812 saved: 10 cases of Cola, lot L2410, WH-MAIN → VAN-03 |
PUT /stock/loads/TJ-JNL-0812, key load-TJ-JNL-0812-1 |
created, LD-000231 WAITING: 240 pieces on SLFLO’s van |
| 06:40 | — | GET /stock/loads?filter[version_after]=… |
LD-000231 REFUSED, DAMAGED, “Two cases crushed at the bottom of the pallet.” The 240 are back in WH-MAIN |
| 07:05 | The storekeeper changes the journal to 8 cases | the same PUT, a new key load-TJ-JNL-0812-2 |
created, LD-000232, resent_from = LD-000231’s id: 192 pieces on the van |
| 07:20 | Post TJ-000812: your van +192 | the feed | LD-000232 ACCEPTED; Karim can sell from the van |
| day | Book SLFLO’s invoices from VAN-03, each line’s lots from lots (which batch): your van −168 |
GET /invoices?filter[seq_after]=… |
168 pieces sold |
| 15:40 | A shop’s 3 crushed pieces come back on a return line with held_back: true |
GET /returns?… |
3 pieces in VAN-03-Q, the van’s held-back place |
| 17:50 | The storekeeper counts 22 and posts TJ-000815, VAN-03 → WH-MAIN |
PUT /stock/unloads/TJ-JNL-0815 |
409 VAN_DAY_NOT_ENDED, retryable: true: Karim hasn’t tapped End day. Keep it queued |
| 18:05 | — | the same PUT on the next run |
created, UL-000044: held 24, counted 22, shortages 2 pieces, 200.00 |
| 18:10 | Post TJ-000816, the held-back journal, VAN-03-Q → WH-MAIN-Q |
PUT /stock/unloads/TJ-JNL-0816 with held_back: true |
created; VAN-03-Q holds nothing |
At the end, SLFLO’s VAN-03 holds nothing and your van holds the 2 short pieces
(192 − 168 − 22): your ERP’s van = SLFLO’s van + that van’s shortages not yet cleared. The office
sorts the shortage out on its end of day; your accountant clears the 2 pieces with a journal of
your own. The sections below take each step in turn.
Send a load
Section titled “Send a load”PUT /stock/loads/TJ-JNL-0812
curl -X PUT 'https://api.slflo.com/api/integration/v1/stock/loads/TJ-JNL-0812' \ -H 'Authorization: Bearer $SLFLO_TOKEN' \ -H 'Idempotency-Key: load-TJ-JNL-0812-1' \ -H 'Content-Type: application/json' \ -d '{"van":"VAN-03","from":"WH-MAIN","number":"TJ-000812","note":"Two cases are for Al Amal Market.","lines":[{"product":"ITEM-1001","unit":"cs","quantity":"10","lot":"L2410","expires_on":"2027-03-31"}],"source_version":"5637145326"}'Response
HTTP 200
{ "data": { "entity": "van_load", "id": "op_01J9L", "number": "LD-000231", "external_ref": "TJ-JNL-0812", "kind": "LOAD", "state": "WAITING", "result": "created", "replaced_id": null }}| Field | Required | Meaning |
|---|---|---|
van |
yes | The receiving van’s SLFLO location code |
from |
yes | The warehouse it comes from, as a SLFLO location code — or the giving van’s code for a van to van |
number |
no | Your journal number for people (≤ 40 characters), shown as “From Dynamics 365 · TJ-000812” |
note |
no | For the rep (≤ 500 characters) |
lines |
yes | 1 to 500 lines. Lines of one product and lot are added together |
lines[].product |
yes | Your item key (else SLFLO’s product code) |
lines[].unit |
no | Your unit key (else SLFLO’s unit code); absent = the product’s base unit |
lines[].quantity |
yes | A decimal string above 0, at most 3 decimals, in that unit |
lines[].lot |
lot-tracked products | The lot code; a lot new to SLFLO is made — your ERP vouches for it |
lines[].expires_on |
no | The lot’s expiry, used only when the lot is new |
source_version |
no | Your change counter or modified time; an older one than SLFLO has is stale |
SLFLO doesn’t check the source warehouse’s stock: your ERP owns it and vouches for it, so the console shows those warehouses as “In Dynamics 365”. The van side stays exact.
What a send does
Section titled “What a send does”One journal can carry several loads over time. The ref’s latest load decides:
| The ref’s latest load | You send | result |
Stock |
|---|---|---|---|
| none, or cancelled | anything | created — a new LD- |
from → van |
| waiting | the same goods, number and note | unchanged |
none |
| waiting | the same goods, a new number or note | updated — in place |
none |
| waiting | other goods | replaced — a new LD-; replaced_id is the old load |
the old load back, the new one out |
| refused | anything | created — a re-send, a new LD- |
from → van |
| accepted | the same goods | unchanged |
none |
| accepted | other goods | 409 LOAD_ALREADY_CHECKED |
none |
| any | an older source_version |
stale |
none |
“The same goods” means the same van, warehouse, products, lots and quantities in base units. So a
waiting load sent again for another van (or from another warehouse) is replaced: the goods
come back off the first van to the warehouse they came from, and go out to the new van from the
warehouse you name now. The new van’s rep answers the load; the first van’s rep is told it was
withdrawn (LOAD_WITHDRAWN). A load turned into a van to van (a van as the new
from) is replaced the same way: its goods go back to the warehouse, and the giving van gives them.
Use a new Idempotency-Key for each send — each first send, each replace, each re-send and
each cancel — and reuse it only to retry that same send. A key is answered with its first answer
for 7 days, so re-sending an unchanged journal after a refusal under the old key would replay the
old created and make no new load. See idempotency.
Cancel a load
Section titled “Cancel a load”DELETE /stock/loads/TJ-JNL-0812
curl -X DELETE 'https://api.slflo.com/api/integration/v1/stock/loads/TJ-JNL-0812' \ -H 'Authorization: Bearer $SLFLO_TOKEN' \ -H 'Idempotency-Key: cancel-TJ-JNL-0812-1'Response
HTTP 200
{ "data": { "entity": "van_load", "id": "op_01J9L", "number": "LD-000231", "external_ref": "TJ-JNL-0812", "kind": "LOAD", "state": "CANCELLED", "result": "cancelled", "replaced_id": null }}A waiting load’s goods go back to the warehouse; a refused load’s already went back. Cancelling
again answers unchanged. Once the rep accepted it, a cancel is 409 LOAD_ALREADY_CHECKED:
record the change as a new journal. A ref that never reached SLFLO is 404 NOT_FOUND.
Read the answers
Section titled “Read the answers”GET /stock/loads lists every load your ERP sent, oldest change first, by version — the same
keyset paging as the other feeds. An accept, a refusal, a replace
and a cancel each move the load past your cursor.
GET /stock/loads?filter[version_after]=9310
curl -X GET 'https://api.slflo.com/api/integration/v1/stock/loads?filter[version_after]=9310' \ -H 'Authorization: Bearer $SLFLO_TOKEN'Response
HTTP 200
{ "data": [ { "id": "op_01J9L", "number": "LD-000231", "external_ref": "TJ-JNL-0812", "external_number": "TJ-000812", "kind": "LOAD", "van": { "id": "loc_van03", "code": "VAN-03", "name": { "en": "Van 3" } }, "from": { "id": "loc_wh", "code": "WH-MAIN", "name": { "en": "Main warehouse" } }, "rep": { "id": "rep_12", "code": "R012", "name": { "en": "Karim Adel" } }, "state": "REFUSED", "lines": [ { "product": { "id": "P0000001", "code": "SKU-COLA", "external_ref": "ITEM-1001" }, "unit": { "id": "PCS", "code": "PCS", "external_ref": "pcs" }, "quantity": "240", "lot": "L2410", "expires_on": "2027-03-31" } ], "note": null, "loaded_at": "2026-10-09T05:02:11Z", "answered_at": "2026-10-09T06:40:03Z", "answered_by": { "id": "u_karim", "code": "karim", "name": { "en": "Karim Adel" } }, "refusal": { "reason": "DAMAGED", "note": "Two cases crushed at the bottom of the pallet." }, "replaced_by": null, "resent_as": null, "resent_from": null, "version": 9311, "updated_at": "2026-10-09T06:40:03Z" } ], "meta": { "per_page": 100, "has_more": false, "next_version_after": 9311, "high_water": 9311 }}- Act on a row only when its
idis your journal’s current SLFLO load. A ref has several loads over time:REPLACEDandCANCELLEDrows, and aREFUSEDrow that comes back withresent_asset, are history, not new answers. stateisWAITING,ACCEPTED,REFUSED,REPLACEDorCANCELLED.refusal.reasonisQUANTITIES_DONT_MATCH,WRONG_PRODUCTS,DAMAGEDorSOMETHING_ELSE— an open list: show an unknown value as “Other”.refusal.noteis the rep’s words, always present on a refusal.linesare what went onto the van, in each product’s base unit (10 cases of 24 read240pieces).kindisLOAD(from a warehouse) orVAN_TRANSFER(from another van, van to van).- Filters:
filter[state](a comma list),filter[kind](LOAD,VAN_TRANSFER),filter[external_ref](every load one journal ever had),filter[id].filter[updated_after]starts a first read.
Re-check one journal
Section titled “Re-check one journal”GET /stock/loads/{ref} answers the ref’s latest load, whatever became of it — a cancelled one
included. Use it for a load that has waited longer than you expect, or when your job stopped
between SLFLO taking a send and you storing the answer: the feed’s row may already be behind
your cursor. 404 NOT_FOUND means the ref never reached SLFLO: send it again.
Van to van
Section titled “Van to van”A journal from one van to another — Sara’s VAN-05 hands 5 cases to Karim’s VAN-03 — is a load
whose from is the giving van. The same PUT /stock/loads/{ref}, the same re-send table, the
same answers feed; the load’s kind is VAN_TRANSFER.
PUT /stock/loads/TJ-JNL-0820
curl -X PUT 'https://api.slflo.com/api/integration/v1/stock/loads/TJ-JNL-0820' \ -H 'Authorization: Bearer $SLFLO_TOKEN' \ -H 'Idempotency-Key: load-TJ-JNL-0820-1' \ -H 'Content-Type: application/json' \ -d '{"van":"VAN-03","from":"VAN-05","number":"TJ-000820","lines":[{"product":"ITEM-1001","unit":"cs","quantity":"5","lot":"L2410"}]}'Response
HTTP 200
{ "data": { "entity": "van_load", "id": "op_01J9T", "number": "LD-000240", "external_ref": "TJ-JNL-0820", "kind": "VAN_TRANSFER", "state": "WAITING", "result": "created", "replaced_id": null }}- The giving van is checked. Unlike your warehouse, both vans are SLFLO’s to keep exact: the
giving van must hold every line (product and lot, in base units) when the journal arrives. If
it doesn’t — its rep sold some since the journal was made — the send is
422 INSUFFICIENT_VAN_STOCKand nothing moves; the message names each short line (“SKU-COLA lot L2410 at VAN-05: 96 there, 120 sent”). Fix the journal and send it again with a new key. - Only the van’s sellable stock gives. A van’s held-back place (
VAN-05-Q) is never afrom:422 NOT_A_WAREHOUSE. - The goods leave the giving van as soon as the journal arrives and wait on the receiving van. Sara’s phone shows them gone from her van after its next sync.
- Only the receiving van’s rep answers. Karim accepts or refuses on his phone, as for any
load; Sara can’t. Post the journal when the feed says
ACCEPTED. - A refusal, a replace or a cancel while it waits puts the goods back on the giving van — not in
a warehouse. A replace or cancel is
409 LOAD_PARTLY_SOLDif Karim has already sold some of it (he can’t before he accepts). - On the feed,
fromis the giving van ({code: "VAN-05", …}) andrepthe receiving van’s rep. Read only van to van answers withfilter[kind]=VAN_TRANSFER.
Unloads
Section titled “Unloads”At the end of the day the storekeeper counts what comes off the van in your ERP and posts a
transfer journal back to the warehouse — the held-back goods (returns that can’t be sold again)
in a journal of their own, from the van’s held-back place (VAN-03-Q) to the warehouse’s
(WH-MAIN-Q). Send each posted journal once: PUT /stock/unloads/{ref}, where ref is the
journal id. One journal empties one place in SLFLO: the van, or with held_back: true the
van’s held-back place.
PUT /stock/unloads/TJ-JNL-0815
curl -X PUT 'https://api.slflo.com/api/integration/v1/stock/unloads/TJ-JNL-0815' \ -H 'Authorization: Bearer $SLFLO_TOKEN' \ -H 'Idempotency-Key: unload-TJ-JNL-0815' \ -H 'Content-Type: application/json' \ -d '{"van":"VAN-03","to":"WH-MAIN","held_back":false,"counted_at":"2026-10-09T15:10:00Z","number":"TJ-000815","lines":[{"product":"ITEM-1001","quantity":"22","lot":"L2410"}],"source_version":"5637145390"}'Response
HTTP 200
{ "data": { "entity": "van_unload", "id": "op_01J9U", "number": "UL-000044", "external_ref": "TJ-JNL-0815", "external_number": "TJ-000815", "van": { "id": "loc_van03", "code": "VAN-03", "name": { "en": "Van 3" } }, "from": { "id": "loc_van03", "code": "VAN-03", "name": { "en": "Van 3" } }, "to": { "id": "loc_wh", "code": "WH-MAIN", "name": { "en": "Main warehouse" } }, "held_back": false, "rep": { "id": "rep_12", "code": "R012", "name": { "en": "Karim Adel" } }, "business_day": "2026-10-09", "counted_at": "2026-10-09T15:10:00Z", "lines": [ { "product": { "id": "P0000001", "code": "SKU-COLA", "external_ref": "ITEM-1001" }, "unit": { "id": "PCS", "code": "PCS", "external_ref": "pcs" }, "lot": "L2410", "held": "24", "counted": "22", "shortage": "2", "overage": "0" } ], "shortages": [ { "id": "vs_01J9V", "product": { "id": "P0000001", "code": "SKU-COLA", "external_ref": "ITEM-1001" }, "lot": "L2410", "quantity": "2", "unit_price": "100.00", "value": "200.00", "currency": "EGP" } ], "result": "created", "version": 9420 }}| Field | Required | Meaning |
|---|---|---|
van |
yes | The van’s SLFLO location code |
held_back |
no (false) |
true: this journal empties the van’s held-back place, not the van |
to |
yes | Good stock: a warehouse code. Held back: a warehouse’s held-back place (WH-MAIN-Q), or the warehouse itself (its held-back place is used) |
counted_at |
yes | When the storekeeper counted (the journal’s posting time). Its date in the company’s time zone is the rep’s day the shortage belongs to |
number |
no | Your journal number for people (≤ 40 characters) |
lines |
yes | What was counted, 0 to 500 lines; an empty list means nothing came back. Lines of one product and lot are added together |
lines[].product |
yes | Your item key (else SLFLO’s product code) |
lines[].unit |
no | Your unit key (else SLFLO’s unit code); absent = the base unit |
lines[].quantity |
yes | Counted, a decimal string of 0 or more, at most 3 decimals |
lines[].lot |
lot-tracked products | The lot code; a lot SLFLO has never seen is an overage of that lot |
source_version |
no | Your change counter or modified time |
What SLFLO does with the count
Section titled “What SLFLO does with the count”For each product and lot, SLFLO sets what the place held against what was counted:
| Counted against held | In SLFLO |
|---|---|
| equal | everything moves to to |
| less — a shortage | the counted part moves; the rest is written off the van and recorded as the rep’s shortage (in shortages) |
| more — an overage | the extra is counted in first, then the whole count moves |
| held, but not in your journal | counted 0: all of it is short |
After an unload the place holds nothing in SLFLO, and the rep’s phone shows an empty van after its
next sync. Each line in the answer says held, counted, shortage and overage in the base
unit. A shortage is valued at the base unit’s list price (unit_price, value) when the product
has one; otherwise both are null and it still counts, in quantity. The shortage is the rep’s to
explain on the end of day.
Recorded once
Section titled “Recorded once”| Your send | result |
|---|---|
| a new ref | created — a new UL- number |
the same journal again (the same van, place, to, counted_at and lines) |
unchanged — nothing moves again; a changed number alone is still unchanged |
other content, with an older source_version |
stale |
| other content | 409 UNLOAD_ALREADY_RECORDED — the stock already moved |
a new ref whose counted_at is on a day the company has closed in its books |
created — kept, never refused: the unload keeps the counted_at you sent, and its entry in the books is dated the day it arrives |
A posted journal is never deleted and there is no DELETE. A correction found later is a new
journal with a new ref: goods found are an overage, goods missing a shortage.
GET /stock/unloads/{ref} reads a recorded unload back (result is null); 404 NOT_FOUND
means the ref never reached SLFLO.
When SLFLO asks you to wait
Section titled “When SLFLO asks you to wait”Two refusals are 409 with retryable: true: nothing is wrong with the journal, SLFLO is not
ready for it yet. Keep it and send it again later — the same body, under the same key or a new one.
LOAD_STILL_WAITING(good stock only): a load still waits on the van for the rep’s answer. Its goods are on SLFLO’s van but not yet on your ERP’s, so the count wouldn’t match.VAN_DAY_NOT_ENDED: the van’s rep has started today’s work day on the phone and not ended it. An offline phone may still send sales from the van. Once the rep taps End day it goes through.
SLFLO compares your count with what the place holds when the unload arrives, and checks the
rep’s day at that moment — not at counted_at. A journal counted in the evening but posted
the next morning, after the rep has started the next day, waits for that day’s End day and is
compared with the van after it. Post unload journals before the rep starts the next day.
Shortages after the unload
Section titled “Shortages after the unload”Each shortages[] line becomes the rep’s van shortage on the office’s End of day page, on the
day of counted_at. A day the supervisor already signed off is reopened to To sort out when a
shortage reaches it. The office then sorts each line out as Charged to the rep, Written
off or Found, with a note. That is the office’s word only: SLFLO moves no stock, opens no
debt for the rep, and sends nothing back to your ERP — there is no feed of sorted shortages. Clear
the shortage in your ERP with your own journal (see below).
Lots and held-back goods on documents
Section titled “Lots and held-back goods on documents”The documents your other jobs already read carry what the stock journals need:
- Invoices list, per line, the lots its goods left from in
lines[].lots(lot,expires_on,quantityin the line’s unit,base_quantity), earliest expiry first — the van’s lots for a van sale. Register them against your batches when you post the invoice (which batch). A product SLFLO doesn’t track by lot has"lots": []. - Returns say per line which lot came back (
lines[].lot) and whether the goods were held back (lines[].held_back: true— they went to the van’s held-back place, not back on sale). The held-back ones leave the van in the held-back unload journal. - Products:
GET /lookup?entity=product&external_ref=…answersproduct.tracking(BATCH,NONE,SERIAL), so both sides agree on which lines carry a lot.
Idempotency and retries
Section titled “Idempotency and retries”| Call | Idempotency-Key |
Retry the same key when |
|---|---|---|
PUT /stock/loads/{ref} |
a new one for each send: first send, replace, re-send after a refusal | the call timed out or failed with 429/5xx |
DELETE /stock/loads/{ref} |
a new one for each cancel | the same |
PUT /stock/unloads/{ref} |
one per journal is enough | the same, and after LOAD_STILL_WAITING or VAN_DAY_NOT_ENDED |
A key answers its first answer for 7 days (Idempotent-Replayed: true); the same key with another
body is 422 IDEMPOTENCY_KEY_REUSED. Three 409s carry retryable: true: REQUEST_IN_PROGRESS
(the first call with this key is still running — retry shortly) and the unload’s two waits,
LOAD_STILL_WAITING and VAN_DAY_NOT_ENDED (retry on a later run, minutes not seconds; the wait
frees the key, so the same key or a new one both work). Every other 409 and every 422 needs a
person or a fixed journal; a refused call wrote nothing. See idempotency
and retries.
Stock on both sides
Section titled “Stock on both sides”- SLFLO moves the goods onto the van when the load arrives, before the rep answers; your ERP posts the journal only when the rep accepts. While a load waits the two van figures differ by that load — and the rep can’t sell it.
- A refusal takes the goods straight back to the warehouse in SLFLO — to the giving van, for a van to van; nothing to post in your ERP.
- A replace or cancel is refused with
409 LOAD_PARTLY_SOLDif any of the load has already left the van (it can’t, while selling waits for the accept — but an office load from before the switch can). - An unload’s shortage is written off SLFLO’s van, so the phone can’t sell goods that aren’t there, but it stays on the van in your ERP until your accountant clears it with a journal of their own. So your ERP’s van = SLFLO’s van + that van’s shortages not yet cleared. Marking a shortage sorted in SLFLO sends nothing to your ERP.
Errors
Section titled “Errors”| Case | Status | code |
|---|---|---|
| The company keeps its stock in SLFLO | 409 | ERP_STOCK_NOT_ENABLED |
No Idempotency-Key / the same key with another body |
400 / 422 | IDEMPOTENCY_KEY_REQUIRED / IDEMPOTENCY_KEY_REUSED |
A field missing, no lines or more than 500, a bad quantity or date, a ref over 64 characters |
400 | INVALID_REQUEST — details names each field |
| A van, warehouse, product or unit SLFLO doesn’t know | 422 | UNKNOWN_REFERENCE — details[{field, value}], all at once |
van is not a van |
422 | NOT_A_VAN |
from is neither a warehouse nor a van (a held-back place) |
422 | NOT_A_WAREHOUSE |
from is the van |
422 | SAME_LOCATION |
| Van to van: the giving van doesn’t hold every line | 422 | INSUFFICIENT_VAN_STOCK — the message names each short line |
| A unit that isn’t one of the product’s | 422 | UNIT_NOT_OF_PRODUCT |
| A lot missing, a lot on an untracked product, a serial-tracked product | 422 | BATCH_REQUIRED, NOT_TRACKED, SERIAL_TRACKED |
| Other goods, or a cancel, after the rep accepted | 409 | LOAD_ALREADY_CHECKED |
| A replace or cancel after part of the load left the van | 409 | LOAD_PARTLY_SOLD |
DELETE or GET of a ref with no load |
404 | NOT_FOUND |
| An unload’s good stock to a place that isn’t a warehouse | 422 | NOT_A_WAREHOUSE |
| Held-back goods to a van’s place | 422 | NOT_QUARANTINE |
The van, or the warehouse in to, has no held-back place |
422 | NO_QUARANTINE |
| An unload while a load waits on the van (good stock only) | 409, retryable | LOAD_STILL_WAITING |
| An unload while the rep’s day is under way | 409, retryable | VAN_DAY_NOT_ENDED |
| An unload’s ref again with other content | 409 | UNLOAD_ALREADY_RECORDED |
GET of an unload ref never recorded |
404 | NOT_FOUND |
Only LOAD_STILL_WAITING and VAN_DAY_NOT_ENDED are retryable — send the same journal again
later. For every other refusal fix the journal or the master data and send again with a new key.
A refused call writes nothing.
Try it
Section titled “Try it”Ask us for the stock sandbox (sandbox): the
same Nile Fresh day, then its stock handed to the ERP, one load journal TJ-NF-0001 sent and
accepted by Omar, and the van’s counted unload TJ-NF-0002.
auth=(-H "Authorization: Bearer $SLFLO_TOKEN")curl -s "${auth[@]}" "$SLFLO_BASE/me" | jq .data.company.stock_managed_by_erp# truecurl -s "${auth[@]}" "$SLFLO_BASE/lookup?entity=van&external_ref=VAN-03" | jq -c '.data | {exists, rep: .van.rep.code}'# {"exists":true,"rep":"REP-03"}curl -s "${auth[@]}" "$SLFLO_BASE/stock/loads/TJ-NF-0001" | jq -c '.data | {number, state, answered_by: .answered_by.code}'# {"number":"LD-…","state":"ACCEPTED","answered_by":"omar"}curl -s "${auth[@]}" "$SLFLO_BASE/stock/unloads/TJ-NF-0002" | jq -c '.data | {number, shortages: (.shortages | length)}'# {"number":"UL-…","shortages":0}Then send a load journal of your own, read it back, and cancel it:
ref="TJ-TRY-$(date +%s)"curl -s -X PUT "${auth[@]}" "$SLFLO_BASE/stock/loads/$ref" -H "Idempotency-Key: send-$ref" \ -H 'Content-Type: application/json' \ -d '{"van":"VAN-03","from":"MAIN","number":"'"$ref"'","lines":[{"product":"JUICE-1L","unit":"CTN","quantity":"1"}]}' \ | jq -c '.data | {number, state, result}'# {"number":"LD-…","state":"WAITING","result":"created"}curl -s "${auth[@]}" "$SLFLO_BASE/stock/loads/$ref" | jq -c '.data | {state, lines: [.lines[] | {product: .product.code, quantity}]}'# {"state":"WAITING","lines":[{"product":"JUICE-1L","quantity":"12"}]} — a carton is 12 piecescurl -s -X DELETE "${auth[@]}" "$SLFLO_BASE/stock/loads/$ref" -H "Idempotency-Key: cancel-$ref" | jq -c '.data.result'# "cancelled"Nobody answers your loads on the sandbox: they wait until you cancel them, and while one waits, a
good-stock unload of VAN-03 answers 409 LOAD_STILL_WAITING — for every developer sharing the
company. So cancel what you send. On the plain sandbox (stock_managed_by_erp is false) the
send answers 409 ERP_STOCK_NOT_ENABLED, the check every send, cancel and unload meets first.
Try a van to van
Section titled “Try a van to van”The stock sandbox has one van, VAN-03; a van to van needs a second one, so ask us to add a van
seller to your stock sandbox (say VAN-04). A new van holds nothing, so the first send is refused
at the giving van’s check; a load onto it first gives it something to hand over:
v2v="TJ-V2V-$(date +%s)"send() { curl -s -X PUT "${auth[@]}" "$SLFLO_BASE/stock/loads/$1" -H "Idempotency-Key: $2" \ -H 'Content-Type: application/json' -d "$3"; }send "$v2v" "v2v-1-$v2v" '{"van":"VAN-03","from":"VAN-04","lines":[{"product":"JUICE-1L","quantity":"12"}]}' \ | jq -c '.error | {code, message}'# {"code":"INSUFFICIENT_VAN_STOCK","message":"Not enough on the giving van: JUICE-1L at VAN-04: 0 there, 12 sent …"}send "fill-$v2v" "fill-$v2v" '{"van":"VAN-04","from":"MAIN","lines":[{"product":"JUICE-1L","quantity":"12"}]}' \ | jq -c '.data.kind'# "LOAD"send "$v2v" "v2v-2-$v2v" '{"van":"VAN-03","from":"VAN-04","lines":[{"product":"JUICE-1L","quantity":"12"}]}' \ | jq -c '.data | {kind, state, result}'# {"kind":"VAN_TRANSFER","state":"WAITING","result":"created"}curl -s -X DELETE "${auth[@]}" "$SLFLO_BASE/stock/loads/$v2v" -H "Idempotency-Key: cancel-$v2v" | jq -c '.data.result'# "cancelled" — the 12 are back on VAN-04curl -s -X DELETE "${auth[@]}" "$SLFLO_BASE/stock/loads/fill-$v2v" -H "Idempotency-Key: cancel-fill-$v2v" | jq -c '.data.result'# "cancelled"
