API reference › Cancel & refunds

POST/shipments/{id}/cancel

Cancel a shipment + refund per policy. Requires Idempotency-Key.

By the carrier's pickup scan (x-conventions.cancellations): before it — cancelled and refunded in full (200; paid on the platform: refund_due, confirm the refund); after it — 202, held for IDS's review, nothing cancelled or refunded.

Key scope
shipments:cancel
Idempotency-Key
Required — 1–255 characters, one per logical operation, reused on every retry (rules)
URL
https://ids.express/api/v1/shipments/{id}/cancel

Parameters

  • idpath · stringrequired

    Shipment UUID or its master tracking number

Request body

Optional: send {} with Content-Type: application/json, or no body and no Content-Type. Unknown fields are rejected.

application/json

No fields.

Call it

OPERATION_KEY=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)   # one per logical operation — keep it, reuse it on every retry
curl -s -X POST "https://ids.express/api/v1/shipments/$ID/cancel" \
  -H "Authorization: Bearer $IDS_KEY" \
  -H "Idempotency-Key: $OPERATION_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Answers

200 Cancelled (+ refund result)

Headers: X-Request-Id

application/json — CancelResult

  • idstring (uuid)required
  • cancelledbooleanrequired

    one of: true

  • alreadyCancelledboolean

    one of: true

  • statusstringrequired

    one of: cancelled

  • pickupobject

    Present when this call cancelled the label (not on alreadyCancelled).

  • cancelledbooleanrequired
  • keptForShipmentsinteger> 0

    BOOK: the pickup was kept — this many other shipments of it (a plan booked in one call) still wait for the courier; it is cancelled with the last of them.

  • refundobjectrequired
  • statusstringrequired

    one of: refunded · not_applicable · not_eligible · blocked_pickup_window · pending_review · refund_due

    refund_due (CXL) — paid on the platform: the platform refunds its buyer this amount on its original payment and confirms it (POST /shipments/{id}/refunds/{refundId}/confirm). A repeated cancel after that confirmation answers refunded with target platform_payment — never refund it again.

  • refundedbooleanrequired
  • amountnumber
  • amountMinorinteger

    The amount beside it in minor units (cents).

  • currencystring
  • reasonstring
  • targetstring

    one of: balance · test_wallet · platform_payment

    CXL: where the money goes back.

  • refundIdstring (uuid)

    CXL: target platform_payment — the refund (to confirm while refund_due).

Example 200
{
  "id": "0192f0c2-5d1e-7a3b-9c4d-2e8f1a6b7c90",
  "cancelled": true,
  "status": "cancelled",
  "pickup": {
    "cancelled": true
  },
  "refund": {
    "status": "refunded",
    "refunded": true,
    "amount": 60.5,
    "amountMinor": 6050,
    "currency": "RON",
    "reason": "Cancelled before pickup"
  }
}
202 The carrier has the parcel: the cancellation is held for IDS's review (cancelRequest); nothing cancelled or refunded

Headers: X-Request-Id

application/json — CancelRequested

  • idstring (uuid)required
  • cancelledbooleanrequired

    one of: false

  • statusstringrequired

    one of: draft · pending · confirmed · in_transit · delivered · cancelled · exception · failed

    The shipment's status now (the carrier has the parcel).

  • cancelRequestobjectrequired
  • idstring (uuid)required
  • statestringrequired

    one of: open · declined · return_ordered · cancelled

    open — IDS reviews it; declined — the delivery goes on; return_ordered — IDS arranged a stop / return to the sender with the carrier; cancelled — IDS cancelled the label.

  • requestedAtstring (date-time)required
  • channelstringrequired

    one of: api · dashboard

  • evidencestringrequired

    one of: scan · pickup_completed · dropped_off

    Why it is held: the carrier scanned the parcel, the pickup is completed, or the seller handed it in.

  • decidedAtstring (date-time)requirednullable
  • refundobjectrequired
  • statusstringrequired

    one of: refunded · not_applicable · not_eligible · blocked_pickup_window · pending_review · refund_due

    refund_due (CXL) — paid on the platform: the platform refunds its buyer this amount on its original payment and confirms it (POST /shipments/{id}/refunds/{refundId}/confirm). A repeated cancel after that confirmation answers refunded with target platform_payment — never refund it again.

  • refundedbooleanrequired
  • amountnumber
  • amountMinorinteger

    The amount beside it in minor units (cents).

  • currencystring
  • reasonstring
  • targetstring

    one of: balance · test_wallet · platform_payment

    CXL: where the money goes back.

  • refundIdstring (uuid)

    CXL: target platform_payment — the refund (to confirm while refund_due).

400 VALIDATION_FAILED — missing Idempotency-Key, delivered shipment, bad body

Headers: X-Request-Id

Codes: VALIDATION_FAILED

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

401 AUTHENTICATION_FAILED — missing, malformed, invalid, revoked or expired key

Headers: X-Request-Id

Codes: AUTHENTICATION_FAILED

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

403 API_ACCESS_DISABLED / API_ACCOUNT_DISABLED / API_KEY_IP_NOT_ALLOWED / API_TERMS_NOT_ACCEPTED / FORBIDDEN_SCOPE / API_OWNER_NOT_BILLABLE; a platform's key: PLATFORM_SUSPENDED (a quote, booking or test operation of a suspended platform) / PLATFORM_TARIFF_MISSING (a quote or booking before IDS set its tariff)

Headers: X-Request-Id

Codes: API_ACCESS_DISABLEDAPI_ACCOUNT_DISABLEDAPI_KEY_IP_NOT_ALLOWEDAPI_TERMS_NOT_ACCEPTEDFORBIDDEN_SCOPEAPI_OWNER_NOT_BILLABLEPLATFORM_SUSPENDEDPLATFORM_TARIFF_MISSING

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

404 NOT_FOUND — not visible to this key (other account or other environment)

Headers: X-Request-Id

Codes: NOT_FOUND

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

409 IDEMPOTENCY_CONFLICT / IDEMPOTENCY_IN_PROGRESS / IDEMPOTENCY_UNDER_REVIEW

Headers: X-Request-Id

Codes: IDEMPOTENCY_CONFLICTIDEMPOTENCY_IN_PROGRESSIDEMPOTENCY_UNDER_REVIEW

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

422 CARRIER_ERROR — the carrier cancel failed; shipment unchanged

Headers: X-Request-Id

Codes: CARRIER_ERROR

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

429 RATE_LIMITED — per-key or per-IP limit exceeded; wait Retry-After seconds

Headers: X-Request-IdRetry-After

Codes: RATE_LIMITED

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

500 INTERNAL_ERROR

Headers: X-Request-Id

Codes: INTERNAL_ERROR

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

503 API_DISABLED (API switched off); CARRIER_NOT_CONFIGURED / CURRENCY_RATE_MISSING where a carrier or FX rate is used

Headers: X-Request-Id

Codes: API_DISABLEDCARRIER_NOT_CONFIGUREDCURRENCY_RATE_MISSING

The error envelope — Error (error.code, message, retryable, details, requestId); the codes below.

Error codes of this operation

The codes the answers of this operation name. Always read error.retryable of the answer itself — «varies» means it differs per answer. The gates of every keyed request (401, 403, 429, 503) and the whole catalog: errors.

  • VALIDATION_FAILEDHTTP 400retryable: nodetails: ValidationIssuesdetails: ServiceRefusal

    The request is invalid: a field (details[].path), an unknown field, a missing Idempotency-Key, a body that is not JSON, an address the label cannot print. Fix it; repeating it unchanged fails again.

  • AUTHENTICATION_FAILEDHTTP 401retryable: no

    Missing, malformed, invalid, revoked or expired key; an environment tag that does not match. (An account switched off answers 403 API_ACCOUNT_DISABLED since SEC.)

  • API_ACCESS_DISABLEDHTTP 403retryable: no

    API access is switched off for this account.

  • API_ACCOUNT_DISABLEDHTTP 403retryable: no

    The IDS account of this key is switched off, not approved or closed (for an employee's key: its franchise owner's account) — the key stops with it; contact IDS.

  • API_KEY_IP_NOT_ALLOWEDHTTP 403retryable: no

    IDS keeps a list of IP addresses for this key and the request came from another one — send it from a listed address, or ask IDS to change the list.

  • API_TERMS_NOT_ACCEPTEDHTTP 403retryable: no

    The IDS account of this key has not accepted the API Terms of Use (/legal/api-terms) — its holder accepts them in the IDS cabinet (Integrations / API), or IDS records a signed agreement (for an employee's key: its franchise owner's account). Retrying does not help until then.

  • FORBIDDEN_SCOPEHTTP 403retryable: no

    The key lacks the scope of this operation (x-scope).

  • API_OWNER_NOT_BILLABLEHTTP 403retryable: no

    The account cannot be billed through the API (no pricing tier, or an admin account).

  • PLATFORM_SUSPENDEDHTTP 403retryable: no

    The platform of this key is suspended by IDS: quotes, bookings and test operations are refused until IDS resumes it; reads, the tracking refresh, a cancellation and a complaint still work. A retry of a booking finished before the suspension replays its answer.

  • PLATFORM_TARIFF_MISSINGHTTP 403retryable: no

    The platform has no tariff yet — IDS sets it; no quote or booking until then.

  • NOT_FOUNDHTTP 404retryable: no

    Unknown path, or an object this key may not see (another account, the other environment).

  • IDEMPOTENCY_CONFLICTHTTP 409retryable: no

    The Idempotency-Key was used for a different body, operation or environment.

  • IDEMPOTENCY_IN_PROGRESSHTTP 409retryable: yes

    The first request with this Idempotency-Key is still running — retry the same key later.

  • IDEMPOTENCY_UNDER_REVIEWHTTP 409retryable: nodetails: ValidationIssues

    The first request with this key stopped without an answer and is held for IDS review — look the operation up; use a new key only if it did not happen.

  • CARRIER_ERRORHTTP 422retryable: variesdetails: CarrierErrorDetails

    The carrier refused or failed the request. retryable true: it throttled, failed or did not answer — the route's availability is unknown, try later; false: it refused this request — or, on a booking, the carrier may have made the label without answering (the Idempotency-Key and the operationRef are closed, IDS reviews it: look the booking up with GET /shipments?operationRef= before booking again).

  • RATE_LIMITEDHTTP 429retryable: yes

    A limit per minute — the key's requests, its quotes, its platform's keys together, or the client IP (limitScope) — wait Retry-After seconds (retryAfterSec, limit).

  • INTERNAL_ERRORHTTP 500retryable: no

    Unexpected — for a booking, check GET /shipments before using a new key; quote the requestId.

  • API_DISABLEDHTTP 503retryable: no

    IDS switched the whole API off (/ping and /openapi.json keep answering).

  • CARRIER_NOT_CONFIGUREDHTTP 503retryable: no

    The carrier credentials of this environment are missing.

  • CURRENCY_RATE_MISSINGHTTP 503retryable: no

    IDS has no exchange rate for the balance currency.