{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/spoofy-social/json-schema/spoofy-social-order-schema.json",
  "title": "Order",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/spoofy-social-openapi.json#/components/schemas/Order",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "description": "Order number."
    },
    "service": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "platform": {
          "type": "string"
        },
        "metric": {
          "type": "string"
        }
      }
    },
    "link": {
      "type": "string"
    },
    "quantity": {
      "type": "integer"
    },
    "charge": {
      "type": "string",
      "pattern": "^\\d+\\.\\d{2,4}$",
      "description": "Charged at placement. USD as a decimal string."
    },
    "refunded": {
      "type": "string",
      "pattern": "^\\d+\\.\\d{2,4}$",
      "description": "Refunded so far (partial deliveries and failures refund automatically). USD as a decimal string."
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "processing",
        "completed",
        "partial",
        "refunded",
        "cancelled",
        "failed"
      ]
    },
    "kind": {
      "type": "string",
      "enum": [
        "count",
        "time",
        "manual"
      ],
      "description": "As the service’s `kind`."
    },
    "startCount": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Count on the target when delivery started."
    },
    "delivered": {
      "type": [
        "integer",
        "null"
      ]
    },
    "remains": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Units not delivered. Time-based orders: viewers, already counting the minutes that did not run — the refund is charge × remains / quantity."
    },
    "run": {
      "type": [
        "object",
        "null"
      ],
      "description": "Time-based orders: minutes ordered, minutes run so far, and the peak live count reached (at most `quantity`).",
      "properties": {
        "minutes": {
          "type": "integer"
        },
        "servedMinutes": {
          "type": "integer"
        },
        "peak": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "stage": {
      "type": [
        "object",
        "null"
      ],
      "description": "Done-for-you orders: where the work is. `step`: queued, submitted (with the platform, waiting for their review), approved, rejected (refunded in full), cancelled or failed.",
      "properties": {
        "step": {
          "type": "string"
        },
        "label": {
          "type": "string",
          "description": "The step in words."
        },
        "note": {
          "type": [
            "string",
            "null"
          ]
        },
        "at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "inputs": {
      "type": [
        "object",
        "null"
      ],
      "description": "The order fields as sent and checked (`shape` + its fields); null for a plain order.",
      "additionalProperties": true
    },
    "review": {
      "type": [
        "object",
        "null"
      ],
      "description": "Text orders our team checks before they go out: `state` checking (nothing started; cancel any time for a full refund) or rejected (refunded in full).",
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "checking",
            "rejected"
          ]
        },
        "label": {
          "type": "string"
        }
      }
    },
    "refundReason": {
      "type": [
        "object",
        "null"
      ],
      "description": "Why a refunded order was refunded, when there is something to say: `not_started` — live viewers that had not started within the live start window (30 minutes by default) of going out, stopped and refunded in full.",
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "not_started"
          ]
        },
        "label": {
          "type": "string",
          "description": "In words: “Didn’t start in time: refunded in full”."
        }
      }
    },
    "startReason": {
      "type": [
        "object",
        "null"
      ],
      "description": "How a live run’s start was seen, when there is something to say: `room_count` — TikTok live viewers whose live’s public viewer count rose by the viewers within minutes of sending: counted as started, so the live start window does not refund it, though no other report of the start had come yet.",
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "room_count"
          ]
        },
        "label": {
          "type": "string",
          "description": "In words, e.g. “Started: your live’s viewer count rose from 78 to 133 within 2 minutes”."
        }
      }
    },
    "finishReason": {
      "type": [
        "object",
        "null"
      ],
      "description": "How a completed live run’s end was seen, when there is something to say: `run_over` — TikTok live viewers started by the live’s viewer count (`startReason` room_count) whose run was over (its minutes from that start, and a few more) while no other report of its end had come: completed.",
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "run_over"
          ]
        },
        "label": {
          "type": "string",
          "description": "In words, e.g. “Completed: your 15-minute live run finished”."
        }
      }
    },
    "cancelable": {
      "type": "boolean",
      "description": "A cancel can be requested now."
    },
    "source": {
      "type": "string",
      "enum": [
        "web",
        "api",
        "v2",
        "mcp"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "finishedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "expectedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When we expect it fully delivered (estimate made when the order was placed); null when there is no estimate."
    }
  }
}