{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/spoofy-social/json-schema/spoofy-social-automation-schema.json",
  "title": "Automation",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/spoofy-social-openapi.json#/components/schemas/Automation",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "description": "Automation number (never the same as an order number)."
    },
    "kind": {
      "type": "string",
      "enum": [
        "spread",
        "scheduled",
        "recurring",
        "split",
        "campaign",
        "keep_above",
        "feed",
        "per_link",
        "withdrawn"
      ],
      "description": "`per_link`: a new post each run — each run waits for the link you send (POST /api/v1/automations/{id}/links). `withdrawn`: a kind Spoofy no longer offers; it has stopped and `note` says why."
    },
    "kindLabel": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "completed",
        "cancelled",
        "failed"
      ],
      "description": "Active with nothing left to place = finishing its last orders."
    },
    "pausedBecause": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why it is paused, in words. Paused for balance or an unavailable service, it resumes by itself."
    },
    "name": {
      "type": "string"
    },
    "service": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "platform": {
          "type": "string"
        },
        "metric": {
          "type": "string"
        },
        "minQty": {
          "type": "integer",
          "description": "One delivery of it at the least."
        },
        "maxQty": {
          "type": "integer",
          "description": "One delivery of it at the most."
        }
      }
    },
    "link": {
      "type": [
        "string",
        "null"
      ]
    },
    "timezone": {
      "type": "string"
    },
    "startsAt": {
      "type": "string",
      "format": "date-time"
    },
    "endsAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "nextRunAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "finishedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "budget": {
      "type": [
        "string",
        "null"
      ],
      "description": "USD, or null when only the plan bounds it."
    },
    "spent": {
      "type": "string",
      "pattern": "^\\d+\\.\\d{2,4}$",
      "description": "Charged by its orders so far, net of refunds. USD as a decimal string."
    },
    "planned": {
      "type": "string",
      "pattern": "^\\d+\\.\\d{2,4}$",
      "description": "What the plan costs at its price: the price on sale its last run followed (open-ended kinds: up to the budget). USD as a decimal string."
    },
    "progress": {
      "type": "object",
      "properties": {
        "runs": {
          "type": "integer"
        },
        "placed": {
          "type": "integer"
        },
        "skipped": {
          "type": "integer"
        },
        "failed": {
          "type": "integer"
        },
        "left": {
          "type": "integer"
        },
        "ordered": {
          "type": "integer",
          "description": "Units in placed orders."
        },
        "delivered": {
          "type": "integer"
        },
        "total": {
          "type": "integer",
          "description": "The plan's total units."
        },
        "running": {
          "type": "integer",
          "description": "Orders still delivering."
        },
        "unused": {
          "type": "integer",
          "description": "per_link only: runs no post's link was sent for — never charged. `runs` is what the plan covers; `left` what it still takes (a run refunded in full comes back)."
        }
      }
    },
    "settings": {
      "type": "object",
      "additionalProperties": true,
      "description": "The kind's settings (every, at, times, pace, target, feed …). A spread delivered as one order in runs adds oneOrder, perRun and intervalMinutes. A new-post plan (feed): quantityMin and quantityMax (each post's amount is drawn from them), spreadMinutes and parts (0 and 1: all at once) and their pace, delayMinMinutes and delayMaxMinutes, posts, maxPerDay — and quantity (the range's top) and delayMinutes (the shortest wait) as before ranges."
    },
    "watch": {
      "type": "object",
      "description": "feed only: how the account is watched — how often it is read, when it was read last (null before its first check), its first read and how many posts were already there then (never ordered), and how far its posts are.",
      "properties": {
        "checkEveryMinutes": {
          "type": "integer"
        },
        "lastCheckAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "firstReadAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "postsBefore": {
          "type": [
            "integer",
            "null"
          ]
        },
        "stopped": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "ended",
            "budget",
            "posts",
            null
          ],
          "description": "Why it no longer reads the account: its days are over, its budget is spent, or its posts all had their orders."
        },
        "posts": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The next N posts it orders for (null: its days and budget alone bound it)."
        },
        "postsOrdered": {
          "type": "integer",
          "description": "Of those, how many had their orders: one placed and not refunded in full, a post in parts once (\"Post 3 of 30\")."
        },
        "postsFound": {
          "type": "integer",
          "description": "The new posts it found since it began, a post in parts once."
        }
      }
    },
    "note": {
      "type": [
        "string",
        "null"
      ],
      "description": "The last thing worth saying (a skipped run, a count not read this time)."
    },
    "source": {
      "type": "string",
      "enum": [
        "web",
        "api",
        "v2",
        "mcp"
      ]
    },
    "timeline": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AutomationRun"
      },
      "description": "Every run, in order (detail answers only)."
    }
  },
  "$defs": {
    "AutomationRun": {
      "type": "object",
      "description": "One run of an automation: an order it placed (or will place).",
      "properties": {
        "seq": {
          "type": "integer"
        },
        "step": {
          "type": "integer",
          "description": "Campaign step."
        },
        "action": {
          "type": "string",
          "enum": [
            "order"
          ]
        },
        "at": {
          "type": "string",
          "format": "date-time",
          "description": "When it ran, or is due."
        },
        "dueAt": {
          "type": "string",
          "format": "date-time"
        },
        "status": {
          "type": "string",
          "enum": [
            "planned",
            "starting",
            "placed",
            "skipped",
            "failed",
            "cancelled"
          ],
          "description": "`skipped`: not placed, `note` says why (balance, budget, a daily limit of posts)."
        },
        "serviceId": {
          "type": [
            "integer",
            "null"
          ]
        },
        "link": {
          "type": [
            "string",
            "null"
          ]
        },
        "quantity": {
          "type": [
            "integer",
            "null"
          ]
        },
        "order": {
          "type": [
            "object",
            "null"
          ],
          "description": "The order it placed: an ordinary order (GET /api/v1/orders/{id}).",
          "properties": {
            "id": {
              "type": "integer"
            },
            "status": {
              "type": "string"
            },
            "quantity": {
              "type": "integer"
            },
            "delivered": {
              "type": "integer"
            },
            "startCount": {
              "type": [
                "integer",
                "null"
              ]
            },
            "charge": {
              "type": "string",
              "pattern": "^\\d+\\.\\d{2,4}$",
              "description": "Charged. USD as a decimal string."
            },
            "refunded": {
              "type": "string",
              "pattern": "^\\d+\\.\\d{2,4}$",
              "description": "Refunded. USD as a decimal string."
            }
          }
        },
        "note": {
          "type": [
            "string",
            "null"
          ]
        },
        "post": {
          "type": "integer",
          "description": "feed only: the new post this order is for, 1 = the first found."
        },
        "part": {
          "type": "integer",
          "description": "feed only: which of its post's orders this is (1 = the first, or its one order)."
        },
        "parts": {
          "type": "integer",
          "description": "feed only: how many orders its post is in; their quantities add up to the amount drawn for it."
        }
      }
    }
  }
}