{
  "openapi": "3.1.0",
  "info": {
    "title": "ShipOrbit API",
    "version": "1.0.0",
    "description": "Unified parcel tracking by tracking number: carrier detection by number/URL, 3498 carriers, 249 countries, localized status, API keys, admin token issuance, processing time.\n\nGet a free key via POST /v1/register. Support: thekingoffamily2017@gmail.com",
    "contact": {
      "name": "ShipOrbit Support",
      "email": "thekingoffamily2017@gmail.com",
      "url": "https://shiporbit.space/"
    }
  },
  "servers": [
    {
      "url": "https://shiporbit.space"
    }
  ],
  "paths": {
    "/v1/health": {
      "get": {
        "summary": "Service health and coverage counters",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "tags": [
          "Service"
        ]
      }
    },
    "/v1/detect": {
      "get": {
        "summary": "Detect carrier by tracking number or tracking URL",
        "parameters": [
          {
            "name": "number",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "url",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "schema": {
              "type": "string",
              "default": "en"
            }
          },
          {
            "name": "country",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "ISO country code for numeric GLS numbers."
          },
          {
            "name": "postcode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Recipient postcode/ZIP."
          }
        ],
        "responses": {
          "200": {
            "description": "Detection result"
          },
          "422": {
            "description": "carrier_required with candidates/reason=country_required when ambiguous."
          }
        },
        "tags": [
          "Detection"
        ]
      }
    },
    "/v1/carriers": {
      "get": {
        "summary": "List carriers, optionally filtered by country or query",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "schema": {
              "type": "string",
              "default": "en"
            }
          },
          {
            "name": "region",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "RU"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Carrier catalog"
          }
        },
        "tags": [
          "Reference"
        ]
      }
    },
    "/v1/countries": {
      "get": {
        "summary": "List all countries and their carrier coverage",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "schema": {
              "type": "string",
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Country coverage"
          }
        },
        "tags": [
          "Reference"
        ]
      }
    },
    "/v1/track": {
      "post": {
        "summary": "Track one parcel",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "number"
                ],
                "properties": {
                  "number": {
                    "type": "string",
                    "example": "63816376771"
                  },
                  "carrier": {
                    "type": "string",
                    "description": "Carrier id. Optional if the number is unambiguous; otherwise return 422 carrier_required with candidates.",
                    "example": "gls-si"
                  },
                  "postcode": {
                    "type": "string",
                    "description": "Recipient postcode/ZIP where the carrier requires it.",
                    "example": "1000"
                  },
                  "url": {
                    "type": "string",
                    "description": "Optional tracking URL"
                  },
                  "language": {
                    "type": "string",
                    "default": "en",
                    "example": "ru"
                  },
                  "country": {
                    "type": "string",
                    "description": "ISO country code used to disambiguate numeric GLS numbers.",
                    "example": "RO"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tracking result with localized status, resource_urls for manual verification, provider, processing_ms and cache_hit."
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "404": {
            "description": "Carrier could not find the parcel"
          },
          "400": {
            "description": "Invalid request body or missing number"
          },
          "402": {
            "description": "Monthly plan quota exceeded (error=quota_exceeded; plan, limit, used, resets_at in body)"
          },
          "429": {
            "description": "Rate limited. Includes Retry-After and X-RateLimit-Limit/Remaining/Reset headers plus retry_after_seconds."
          },
          "422": {
            "description": "Expected tracking error: error is one of reference_only, unsupported_carrier, no_source, carrier_required, not_found, timeout. Includes retryable, needs_verification and candidates for carrier_required."
          },
          "403": {
            "description": "Explicit abuse/IP ban only. Includes retry_after_seconds, Retry-After and X-RateLimit-* headers."
          },
          "504": {
            "description": "All tracking sources timed out. error=timeout, retryable=true."
          }
        },
        "tags": [
          "Tracking"
        ]
      }
    },
    "/v1/track/batch": {
      "post": {
        "summary": "Track up to 100 parcels",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "language": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "maxItems": 100,
                    "items": {
                      "type": "object",
                      "required": [
                        "number"
                      ],
                      "properties": {
                        "number": {
                          "type": "string"
                        },
                        "carrier": {
                          "type": "string",
                          "description": "Carrier id; required unless a top-level carrier is provided"
                        },
                        "postcode": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "language": {
                          "type": "string"
                        },
                        "country": {
                          "type": "string",
                          "description": "Optional ISO country code."
                        }
                      }
                    }
                  },
                  "carrier": {
                    "type": "string",
                    "description": "Optional fallback carrier applied to items without their own carrier"
                  },
                  "country": {
                    "type": "string",
                    "description": "Optional ISO country code for ambiguous numeric numbers."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch results"
          },
          "400": {
            "description": "Invalid request body"
          },
          "402": {
            "description": "Monthly plan quota exceeded (error=quota_exceeded; plan, limit, used, resets_at in body)"
          },
          "429": {
            "description": "Per-key rate limit exceeded"
          },
          "422": {
            "description": "Expected per-item tracking errors; see ErrorCode."
          }
        },
        "tags": [
          "Tracking"
        ]
      }
    },
    "/v1/usage": {
      "get": {
        "summary": "Usage for the calling API key",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Usage counters"
          }
        },
        "tags": [
          "Account"
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "ErrorCode": {
        "type": "string",
        "enum": [
          "reference_only",
          "unsupported_carrier",
          "no_source",
          "carrier_required",
          "not_found",
          "rate_limited",
          "ip_banned",
          "timeout",
          "quota_exceeded",
          "missing_number",
          "internal_error"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "ok",
          "error",
          "message"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "message": {
            "type": "string"
          },
          "message_ru": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "needs_verification": {
            "type": "boolean"
          },
          "retry_after_seconds": {
            "type": "integer"
          },
          "processing_ms": {
            "type": "integer"
          },
          "candidates": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "resource_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      },
      "TrackingResult": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "carrier": {
            "type": "string"
          },
          "carrier_name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "in_transit",
              "out_for_delivery",
              "delivered",
              "return",
              "exception",
              "not_found",
              "cancelled",
              "unknown"
            ]
          },
          "status_code": {
            "type": "string"
          },
          "status_text": {
            "type": "string"
          },
          "status_source": {
            "type": "string"
          },
          "needs_verification": {
            "type": "boolean"
          },
          "summary_only": {
            "type": "boolean"
          },
          "timezone": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "processing_ms": {
            "type": "integer"
          },
          "cache_hit": {
            "type": "boolean"
          },
          "resource_url": {
            "type": "string"
          },
          "resource_urls": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Swagger UI",
    "url": "https://shiporbit.space/docs"
  },
  "tags": [
    {
      "name": "Tracking",
      "description": "Track one parcel or up to 100 parcels per request."
    },
    {
      "name": "Detection",
      "description": "Carrier detection by tracking number or URL."
    },
    {
      "name": "Reference",
      "description": "Carrier catalog and country coverage."
    },
    {
      "name": "Account",
      "description": "API key usage and limits."
    },
    {
      "name": "Service",
      "description": "Health and coverage counters."
    }
  ]
}
