Skip to content

Mock Partner API Reference

The Mock Partner API (mock_meesho_server.py) simulates the Meesho logistics API for local development and CI. It runs at http://localhost:5000.


Endpoints

Method Path Auth Purpose
GET / none HTML dashboard — live stats and endpoint table
GET /health none Health check → {"status":"running"}
GET /stats none Detailed JSON stats
GET /awb none List all mock AWBs
POST /awb none Add or update a mock AWB
POST /api/v1/oauth/token none Issue a bearer token
POST /api/v1/sorter/awb/pull Bearer Bulk/single AWB routing data
POST /api/v1/sorter/awb/inscan Bearer InScan notification
POST /api/v1/hub/manifest/close Bearer Manifest (bag seal) notification

Quick recipes

Get a token

TOKEN=$(curl -sf -X POST http://localhost:5000/api/v1/oauth/token \
  -H "Content-Type: application/json" \
  -d '{"sorter_id":"dev-test"}' \
  | python3 -c "import json,sys; print(json.load(sys.stdin)['access_token'])")

echo $TOKEN

Look up an AWB

curl -sf -X POST http://localhost:5000/api/v1/sorter/awb/pull \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"sorter_id":"dev-test","awb":"VL111111111"}' | python3 -m json.tool

Add a custom AWB for testing

curl -X POST http://localhost:5000/awb \
  -H "Content-Type: application/json" \
  -d '{
    "awb": "VL999999999",
    "next_node": "BLR_HUB",
    "end_node": "DEL_DC",
    "movement_type": "FWD",
    "rejected": "NO"
  }'

Pre-seeded test AWBs

The seed script (scripts/seed-test-data.sh) inserts these AWBs for smoke tests:

AWB next_node end_node movement_type rejected
VL111111111 BLR_HUB DEL_DC FWD NO
VL222222222 DEL_HUB BLR_DC RTO NO
VL333333333 BOM_HUB PUN_DC FWD NO
VL444444444 HYD_HUB CHN_DC FWD NO
VL555555555 DEL_HUB BLR_DC RTO YES

Token behaviour

  • Tokens expire after 1 hour
  • The manifest/close endpoint validates token against the token store and expiry — it will return 401 with {"error_code":"TOKEN_EXPIRED"} on expired tokens
  • Re-request a token via /api/v1/oauth/token at any time

In Docker / DevContainer

Inside the Docker network the backend reaches the mock API at http://mock-api:5000 (service name), not http://localhost:5000. This is seeded automatically by the entrypoint script and post-create hook.