{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/trackingmcp-com/json-schema/trackingmcp-com-error-envelope-schema.json",
  "title": "ErrorEnvelope",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trackingmcp-com-openapi.json#/components/schemas/ErrorEnvelope",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": false
    },
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Machine readable error code."
        },
        "message": {
          "type": "string",
          "description": "Human readable explanation."
        },
        "severity": {
          "type": "string",
          "description": "How serious the error is.",
          "enum": [
            "info",
            "warning",
            "error"
          ]
        },
        "retryable": {
          "type": "boolean",
          "description": "True."
        },
        "reference": {
          "type": "string",
          "description": "The reference."
        },
        "retry_after_seconds": {
          "type": "integer",
          "description": "Seconds to wait."
        },
        "fields": {
          "type": "array",
          "items": {
            "type": "string",
            "description": "Field path."
          },
          "description": "Offending fields. Present on schema and reference pair errors."
        },
        "user_message": {
          "type": "string",
          "description": "CONTAINER_QUOTA_EXCEEDED only."
        },
        "credits_required": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Tokens this request needs."
        },
        "credits_balance": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Tokens the wallet holds."
        },
        "top_up_url": {
          "type": "string",
          "description": "Where to top up.",
          "format": "uri"
        },
        "packages": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "plan": {
                "type": "string",
                "description": "Plan key."
              },
              "credits": {
                "type": "integer",
                "description": "Tokens per month."
              },
              "usd": {
                "type": "number",
                "description": "Monthly price in USD."
              }
            }
          },
          "description": "Plans on offer."
        },
        "reason": {
          "type": "string",
          "description": "CARRIER_NOT_IDENTIFIED only."
        },
        "waited_seconds": {
          "type": "integer",
          "description": "CARRIER_NOT_IDENTIFIED, timed out only."
        },
        "retry_with": {
          "type": "string",
          "const": "carrier_code"
        },
        "member_limit": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The member cycle limit."
        },
        "member_spent": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Tokens the member has used this cycle."
        },
        "member_remaining": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Tokens left for the member."
        },
        "retry_after": {
          "type": "integer",
          "description": "Seconds until the next refresh is allowed."
        },
        "request_id": {
          "type": "string",
          "format": "uuid"
        },
        "requested": {
          "type": [
            "string",
            "null"
          ]
        },
        "supported_versions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "oldest_supported": {
          "type": "string"
        },
        "latest": {
          "type": "string"
        },
        "docs": {
          "type": "string"
        },
        "progress": {
          "type": "object",
          "properties": {
            "carrier_code": {
              "type": "string"
            },
            "carrier_name": {
              "type": [
                "string",
                "null"
              ]
            },
            "carrier_identified": {
              "type": "boolean",
              "enum": [
                true
              ]
            },
            "registered_at": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "last_checked_at": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "next_check_after_seconds": {
              "type": "integer",
              "enum": [
                60
              ]
            }
          }
        },
        "unresolved_reason": {
          "type": "string"
        },
        "outcome": {
          "type": "string",
          "enum": [
            "SEALINE_HASNT_PROVIDE_INFO",
            "NO_EVENTS",
            "WRONG_NUMBER",
            "REFERENCE_REQUIRED",
            "LINE_NOT_SUPPORTED",
            "PENDING",
            "UNRESOLVED"
          ]
        },
        "outcome_class": {
          "type": "string"
        },
        "sealine_status": {
          "type": [
            "string",
            "null"
          ]
        },
        "previous_trip": {
          "type": [
            "object",
            "null"
          ],
          "description": "The trip before yours for this box, when the line still reports it. Null when there is none.",
          "properties": {
            "line": {
              "type": [
                "string",
                "null"
              ],
              "description": "The line that answered, as its SCAC."
            },
            "last_event": {
              "type": "object",
              "properties": {
                "code": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "description": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "location": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "unlocode": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "datetime": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                }
              }
            },
            "events": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "location": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "unlocode": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "datetime": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  }
                }
              }
            },
            "ended_at": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            }
          }
        },
        "lessor_note": {
          "type": [
            "string",
            "null"
          ],
          "description": "A note for leasing-company accounts when no line holds the box yet. Null otherwise."
        },
        "identified_line": {
          "type": [
            "string",
            "null"
          ]
        },
        "identified_party": {
          "type": [
            "string",
            "null"
          ]
        },
        "identified_party_role": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "current_lessee",
            null
          ]
        },
        "required_reference_types": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string",
            "enum": [
              "bill_of_lading",
              "booking"
            ]
          }
        },
        "connector_status": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "in_progress",
            "not_supported",
            "connected",
            "reference_required",
            null
          ]
        },
        "notification_interest_available": {
          "type": "boolean"
        }
      }
    },
    "carrier_notice": {
      "type": [
        "object",
        "null"
      ],
      "description": "Latest reference-specific reply from the named carrier. SHIPMENT_CANCELLED is an explicit matched Maersk cancellation, independent of retained movement history. no_longer_available is Swire stating it no longer serves tracking details for this shipment, or Hapag-Lloyd refusing a number it answered before (the record keeps the line's last data; refused_since and data_as_of date the two). ZIM notices clear after useful tracking, the Hapag-Lloyd one when the line answers the number again.",
      "properties": {
        "carrier_code": {
          "type": "string",
          "enum": [
            "ZIMU",
            "MAEU",
            "CHVW",
            "HLCU"
          ]
        },
        "reference": {
          "type": "string"
        },
        "reference_type": {
          "type": "string",
          "enum": [
            "container",
            "bl",
            "booking"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "other_carrier",
            "temporarily_unavailable",
            "not_found",
            "invalid_reference",
            "SHIPMENT_CANCELLED",
            "no_longer_available"
          ]
        },
        "message": {
          "type": "string"
        },
        "checked_at": {
          "type": "string",
          "format": "date-time"
        },
        "suggested_carrier": {
          "type": [
            "string",
            "null"
          ]
        },
        "suggested_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "refused_since": {
          "type": "string",
          "format": "date-time",
          "description": "Hapag-Lloyd only: when the line first refused the number after its last answer."
        },
        "data_as_of": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Hapag-Lloyd only: the line's last answer about this number, null when none is on record."
        }
      }
    },
    "api_version": {
      "type": "string",
      "description": "The response contract this build answers, as a date (YYYY-MM-DD). Added to every JSON object body on /v1."
    },
    "carrier_hint_applied": {
      "type": "boolean",
      "const": false,
      "description": "Present when the line named was not used."
    },
    "carrier_hint_code": {
      "type": "string",
      "description": "Known line that cannot be asked."
    },
    "upgrade": {
      "type": [
        "object",
        "null"
      ],
      "description": "CONTAINER_QUOTA_EXCEEDED only.",
      "properties": {
        "plan": {
          "type": "string",
          "description": "Next plan."
        },
        "monthly_eur": {
          "type": [
            "number",
            "null"
          ],
          "description": "Monthly price."
        },
        "annual_eur": {
          "type": [
            "number",
            "null"
          ],
          "description": "Annual price."
        }
      }
    },
    "warning": {
      "type": "string",
      "description": "Why the line named was not used."
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Existing record id."
        },
        "archived_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When tracking stopped."
        },
        "archived_reason": {
          "type": [
            "string",
            "null"
          ],
          "description": "Null when your account archived it, otherwise the reason our archiver closed it."
        },
        "resume": {
          "type": "object",
          "properties": {
            "method": {
              "type": "string",
              "const": "POST"
            },
            "path": {
              "type": "string",
              "const": "/v1/containers"
            },
            "body": {
              "type": "object",
              "properties": {
                "identifier": {
                  "type": "string",
                  "description": "The reference to add again."
                }
              }
            }
          }
        }
      },
      "description": "Present only when the reference was already tracked."
    }
  }
}