Skip to content

Testing your endpoint

Receiving orders

With curl (contract test)

bash
curl -s -X POST https://integration.example.com/aiotic/orders \
  -H "Content-Type: application/json" -H "X-API-KEY: $RECEIVE_KEY" \
  -d @erp-receive-sample.json
# → {"success":true,"order_number":"SO-2026-00981"}

# idempotency: same payload again must return the same order_number
curl -s -X POST -d @erp-receive-sample.json
# → {"success":true,"order_number":"SO-2026-00981"}

# wrong key
curl -s -o /dev/null -w "%{http_code}\n" -X POST -H "X-API-KEY: wrong" -d @erp-receive-sample.json
# → 401

The sample file is the request example from the API reference — download it as erp-receive-sample.json.

With the mock tenant (flow test)

The mock performs a real send: POST /erp/send/{id} on the mock calls your endpoint with the documented headers and interprets your answer exactly like production.

bash
aiotic mock &                                             # :8080
curl -X POST localhost:8080/_mock/config -H 'Content-Type: application/json' \
  -d '{"erp_url": "http://localhost:9000/aiotic/orders", "erp_key": "'"$RECEIVE_KEY"'"}'

echo x > PO-1234.pdf
aiotic orders upload PO-1234.pdf          # waits until PROCESSED
aiotic orders send <request_id>           # → your endpoint is called; erp_ref stored on success
aiotic orders get <request_id> | grep erp_ref

File-name tricks in the mock: …attention.pdf → an ATTENTION order with one unresolved line (tests your rejection path); …fail.pdfFAILED (tests retry handling).

In pytest

python
from aiotic.erp.memory import InMemoryErp
from aiotic.receive import ErpReceiver, InMemoryStore
from aiotic.service import default_pipeline

def test_rejects_unknown_article(sample_payload):
    erp = InMemoryErp(products={"PROD-001"})
    receiver = ErpReceiver(erp, api_key="k", pipeline=default_pipeline(erp, InMemoryStore()))
    out = receiver.handle(sample_payload, api_key_header="k")
    assert out.response.success is False
    assert "Unknown article number" in out.response.error

ErpReceiver.handle() is framework-free, so you test the contract without HTTP.

From a real tenant

Once your URL and key are configured for the tenant, a tenant admin can run Test ERP connection in the AIOTIC app. It performs a connectivity check and reports the outcome. Then send one real order from the app and check erp_ref.

What "done" looks like

ScenarioExpected
valid ordersuccess: true, order in ERP, erp_ref set in AIOTIC
replayed request_idsame order_number, one order in ERP
unknown articlesuccess: false, text mentions the article, nothing in ERP
blocked customersuccess: false, nothing in ERP
wrong key401, nothing in ERP
ERP downsuccess: false (or timeout), nothing half-written, order back in its previous status

Documentation revision 3 · Published 8 September 2026 · commit 6862d5e. Verified against AIOTIC API v1.0.0. AIOTIC is a product of DevOps Company.