Shipment tracking

Use a connection key authorized for shipment tracking. The catalog workspace uses the signed-in session and active workspace.

Submit a shipment

Replace the sample tracking number and key with your values. HTTP 202 returns the task id for the next step. Reuse the Idempotency-Key when retrying the same request and use a new key for a new lookup.

BASH
curl -sS -X POST 'https://api.anycap.io/api/v1/logistics/trackings' \  -H 'Authorization: Bearer YOUR_ANYCAP_KEY' \  -H 'Content-Type: application/json' \  -H 'Idempotency-Key: shipment-demo-001' \  -d '{"tracking_number":"RR123456789CN"}'
FieldValue
tracking_number
Required string. Leading and trailing whitespace is trimmed.
carrier_code
Optional integer. Omit or pass null for automatic detection. To track the same shipment again, specify its previous carrier code. Successful registrations with different carriers are billed separately.

Use 5–50 letters, digits or hyphens for the tracking number. Omit the carrier code for automatic detection, or provide an integer from 1 to 2147483647. Shipments that require postal code, phone or shipping date verification are currently unsupported.

Read the task and tracking events

Replace TRACKING_ID with the returned id and use the same key. Poll every five seconds while state is queued or processing. Reading a task does not create another registration charge.

BASH
curl -sS -i 'https://api.anycap.io/api/v1/logistics/trackings/TRACKING_ID' \  -H 'Authorization: Bearer YOUR_ANYCAP_KEY'

Output

GET returns HTTP 202 while processing. On completion HTTP 200 serves the original tracking JSON with all fields and the original event order. Read details from data.accepted[].track_info. X-Anycap-Task-State carries the task state. For a shipment rejection the original data.rejected response is returned when captured. Historical tasks and tasks without a verified original response return the task record.

For a raw rejection read data.rejected[].error.code and message. For a task record read error_code and error_message. A pending task has an unconfirmed registration and billing outcome. Keep the task ID and reuse the same idempotency key to recover the original task. HTTP entry errors use error.code and error.message.

JSON
{  "id": "00000000-0000-4000-8000-000000000001",  "state": "failed",  "input": {    "tracking_number": "RR123456789CN"  },  "billing_status": "released",  "charged_microcredits": "0",  "error_code": "carrier_required",  "error_message": "The carrier could not be determined. Enter the correct carrier code and submit again."}