Authentication
iMile Express uses Bearer token auth. Every key is bound to a single environment — sandbox or live — and the prefix tells you which.
Key formats
| Prefix | Environment | Sample | Hits live systems |
|---|---|---|---|
| mk_test_ | Sandbox | mk_test_rh9ABekJfP31cN7sQ8jKvLwY | no |
| mk_live_ | Live | mk_live_8ZqAvR2nLkPyWxV4DfHcM6tB | yes |
| whsec_ | Webhook signing | whsec_aB3kPq9XmZ2nY7tR1cV8sFhJ | — |
Scopes & envs
Each key is issued against an account with a scope set. Default: shipments:read shipments:write tracking:read webhooks:*. Narrower scopes available on request. The pickup endpoints use the scopes pickups:read, pickups:write and pickups:cancel; see the Pickups guide.
curl https://imileexpress.com/api/v1/shipments \ -H "Authorization: Bearer mk_test_rh9ABekJfP31cN7sQ8jKvLwY" # 401 example: HTTP/1.1 401 Unauthorized { "status": 401, "sysCode": "9900001", "message": "Unauthorized" }
Sandbox IOSS registration
Test keys use a separate sandbox IOSS registry. A number in live OMS Settings, the live registry or the live account default does not automatically qualify as an explicit sandbox override. An override that is not registered in sandbox returns 400 IOSS_NOT_OWNED, even if it matches the live account default.
- First call POST /v1/ioss with an mk_test_* key for the same account and an Idempotency-Key; shipments:write is required. Confirm the successful response has livemode false and filing.status simulated.
- Then use a test key for that account to send the registered ioss_number explicitly to POST /v1/rates for a quote.
- Finally send the same ioss_number and quote inputs to POST /v1/shipments to create the test shipment.
Sandbox registration never files with the carrier, changes live registrations or the live account default, or authorizes live overrides. Omitting ioss_number keeps the existing account-default fallback behavior. The registration example below uses synthetic details; provide your own test key through the MERDI_TEST_API_KEY environment variable.
curl https://imileexpress.com/api/v1/ioss \ -X POST \ -H "Authorization: Bearer $MERDI_TEST_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: sandbox-ioss-example-001" \ -d '{ "ioss_number": "IM1234567890", "label": "Own IOSS", "type": "own", "registration": { "company": "Example Trading Ltd", "country_code": "DE", "street": "Example Street 1", "city": "Berlin", "postal_code": "10115", "email": "customs@example.com" } }'
Reading IOSS filing results
HTTP 200 only confirms the registration was saved. filing.status and filing.filed describe the last confirmed carrier result; only approved means approval. The separate filing.last_attempt_status describes the latest attempt: in_progress, succeeded or failed, and may be null or absent on legacy or simulated records. succeeded does not itself mean approval. GET reads recorded results without a fresh carrier query.
For example, if a previously approved number fails on retry, filing.status remains approved and filing.filed remains true, while filing.last_attempt_status is failed and filing.error_code is IOSS_FILING_FAILED. That is a failed latest attempt, not a revocation of the earlier approval. filing.status is failed only when no confirmed filing is available.
Failure diagnostics add the optional filing.carrier_error_code and filing.carrier_error_message. Codes are numeric strings with leading zeroes preserved: known code 02039207 means the YunExpress IOSS agreement has not been accepted, and 02039188 means the registration country is not an EU member. Messages use fixed safe text; unknown codes or transport failures receive a generic explanation, never the original provider response. Diagnostics are null without a current failure; clients must also accept absent optional fields and unknown codes. The filing block below is a synthetic response.
{ "status": "approved", "filed": true, "simulated": false, "error_code": "IOSS_FILING_FAILED", "carrier_error_code": "02039207", "carrier_error_message": "The YunExpress IOSS agreement has not been accepted.", "last_attempt_status": "failed", "filed_at": "2026-11-03T08:00:00.000Z", "last_attempt_at": "2026-11-06T03:00:00.000Z" }
Rotation
Multiple active keys per account are allowed. Issue a new key, ramp traffic to it, then revoke the old — zero downtime. We recommend rotating live keys every 90 days.