{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/plainrouter/json-schema/plainrouter-action-batch-read-schema.json",
  "title": "ActionBatchRead",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/plainrouter-actionreadapi-api-openapi.yml#/components/schemas/ActionBatchRead",
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "workspace_id": {
          "type": "integer"
        },
        "platform_ad_account_id": {
          "type": "integer"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "approved",
            "approved_without_execution",
            "auto_approved",
            "rejected",
            "executing",
            "executed_pending_verification",
            "compensating",
            "measuring",
            "completed",
            "failed",
            "rolled_back",
            "rollback_incomplete",
            "blocked",
            "halted"
          ]
        },
        "batch_status": {
          "type": "string",
          "enum": [
            "pending",
            "approved",
            "approved_without_execution",
            "auto_approved",
            "rejected",
            "executing",
            "executed_pending_verification",
            "compensating",
            "measuring",
            "completed",
            "failed",
            "rolled_back",
            "rollback_incomplete",
            "blocked",
            "halted"
          ]
        },
        "restoration_summary": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "all_receipts_compensated_late",
            null
          ]
        },
        "policy_decision": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "allow",
            "require_approval",
            "block",
            null
          ]
        },
        "policy_reasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "rationale": {
          "type": "string"
        },
        "idempotency_key": {
          "type": "string"
        },
        "actions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ActionReadItem"
          }
        }
      },
      "required": [
        "id",
        "workspace_id",
        "platform_ad_account_id",
        "status",
        "batch_status",
        "restoration_summary",
        "policy_decision",
        "policy_reasons",
        "rationale",
        "idempotency_key",
        "actions"
      ]
    }
  },
  "required": [
    "data"
  ],
  "$defs": {
    "ActionCurrentDisposition": {
      "type": "object",
      "properties": {
        "receipt_status": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "pending",
            "attempting",
            "reconciliation_required",
            "committed",
            "executed_pending_verification",
            "measuring",
            "verified",
            "compensating",
            "compensated",
            "compensation_failed",
            "irreversible",
            "failed",
            "reconciliation_exhausted",
            null
          ]
        },
        "outcome_payload": {
          "type": [
            "object",
            "null"
          ],
          "description": "Write-once outcome. Management comparisons use PlainRouter counted arrivals and Inventory spend. Resume compares the target after the change with the rest of the same account over those same days. Pause is not judged. Missing data never yields a verdict. Other action types retain their existing payloads.",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "measurable",
                "not_measurable",
                "unavailable"
              ]
            },
            "observed_at": {
              "type": "string",
              "format": "date-time"
            },
            "reason_code": {
              "type": [
                "string",
                "null"
              ]
            },
            "reason": {
              "type": [
                "string",
                "null"
              ]
            },
            "baseline": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "scope": {
                      "type": "string",
                      "enum": [
                        "target",
                        "rest_of_account"
                      ]
                    },
                    "days": {
                      "type": "array",
                      "description": "Three whole days in the ad account timezone; excludes the change day.",
                      "items": {
                        "type": "string",
                        "format": "date"
                      }
                    },
                    "currency": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "spend_minor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Decimal spend in ISO currency minor units; null when daily mirror data is missing."
                    },
                    "counted_arrivals": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "description": "Arrivals counted by PlainRouter through Signals, never provider conversions."
                    },
                    "cost_per_counted_arrival_minor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Spend divided by counted arrivals, in ISO currency minor units, displayed to six decimal places."
                    }
                  }
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            },
            "metrics": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "scope": {
                      "type": "string",
                      "enum": [
                        "target",
                        "rest_of_account"
                      ]
                    },
                    "days": {
                      "type": "array",
                      "description": "Three whole days in the ad account timezone; excludes the change day.",
                      "items": {
                        "type": "string",
                        "format": "date"
                      }
                    },
                    "currency": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "spend_minor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Decimal spend in ISO currency minor units; null when daily mirror data is missing."
                    },
                    "counted_arrivals": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "description": "Arrivals counted by PlainRouter through Signals, never provider conversions."
                    },
                    "cost_per_counted_arrival_minor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Spend divided by counted arrivals, in ISO currency minor units, displayed to six decimal places."
                    },
                    "verdict": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "held",
                        "lost",
                        "not_judged",
                        null
                      ]
                    },
                    "loss_threshold_percent": {
                      "type": "string"
                    }
                  }
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            },
            "inverse": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string",
                  "enum": [
                    "proposed",
                    "inverse_not_proposed"
                  ]
                },
                "batch_id": {
                  "type": "string"
                },
                "reason_code": {
                  "type": "string"
                }
              },
              "required": [
                "status"
              ]
            }
          },
          "additionalProperties": {}
        },
        "outcome_status": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "measurable",
            "not_measurable",
            "unavailable",
            null
          ]
        },
        "outcome_reason_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "outcome_checked_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "compensation_reason_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "recovery_disposition": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "no_compensation",
            "restored",
            "unrestored",
            "contradictory",
            "irreversible",
            "uncertain",
            null
          ]
        },
        "late_restored": {
          "type": "boolean"
        }
      },
      "required": [
        "receipt_status",
        "outcome_status",
        "outcome_reason_code",
        "outcome_checked_at",
        "outcome_payload",
        "compensation_reason_code",
        "recovery_disposition",
        "late_restored"
      ],
      "title": "ActionCurrentDisposition"
    },
    "ActionPolicyResult": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "policy_id": {
          "type": "string"
        },
        "policy_version": {
          "type": "integer"
        },
        "phase": {
          "type": "string",
          "enum": [
            "proposal",
            "approval",
            "execution"
          ]
        },
        "outcome": {
          "type": "string",
          "enum": [
            "allowed",
            "approval_required",
            "blocked"
          ]
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "reason_details": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        },
        "requested_minor": {
          "type": [
            "integer",
            "null"
          ]
        },
        "evaluated_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "policy_id",
        "policy_version",
        "phase",
        "outcome",
        "reasons",
        "reason_details",
        "requested_minor",
        "evaluated_at"
      ],
      "title": "ActionPolicyResult"
    },
    "ActionReadItem": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "batch_id": {
          "type": "string"
        },
        "workspace_id": {
          "type": "integer"
        },
        "type": {
          "type": "string",
          "enum": [
            "increase_budget",
            "decrease_budget",
            "pause",
            "resume",
            "replace_creative",
            "shift_spend",
            "rollback",
            "create_campaign",
            "create_ad_set",
            "create_ad",
            "upload_asset",
            "adjust_budget",
            "set_status",
            "duplicate_ad_with_creative",
            "duplicate_adset",
            "duplicate_ad_with_creative_v2"
          ]
        },
        "target_entity_type": {
          "type": "string"
        },
        "target_entity_id": {
          "type": "string"
        },
        "target_entity_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "params": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {}
            },
            {
              "type": "array",
              "items": {}
            }
          ]
        },
        "rationale": {
          "type": "string"
        },
        "proposer": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "user",
                "agent",
                "system"
              ]
            },
            "name": {
              "type": "string",
              "description": "PlainRouter for a system proposer; omitted for people and agents."
            }
          },
          "required": [
            "type"
          ]
        },
        "evidence": {
          "description": "System evidence cites either the original action and its counted outcome or the rule, revision, run and decision.",
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "original_action_id": {
                  "type": "string"
                },
                "outcome": {
                  "type": "object",
                  "description": "Write-once outcome. Management comparisons use PlainRouter counted arrivals and Inventory spend. Resume compares the target after the change with the rest of the same account over those same days. Pause is not judged. Missing data never yields a verdict. Other action types retain their existing payloads.",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "measurable",
                        "not_measurable",
                        "unavailable"
                      ]
                    },
                    "observed_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "reason_code": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "baseline": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "scope": {
                              "type": "string",
                              "enum": [
                                "target",
                                "rest_of_account"
                              ]
                            },
                            "days": {
                              "type": "array",
                              "description": "Three whole days in the ad account timezone; excludes the change day.",
                              "items": {
                                "type": "string",
                                "format": "date"
                              }
                            },
                            "currency": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "timezone": {
                              "type": "string"
                            },
                            "spend_minor": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Decimal spend in ISO currency minor units; null when daily mirror data is missing."
                            },
                            "counted_arrivals": {
                              "type": [
                                "integer",
                                "null"
                              ],
                              "description": "Arrivals counted by PlainRouter through Signals, never provider conversions."
                            },
                            "cost_per_counted_arrival_minor": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Spend divided by counted arrivals, in ISO currency minor units, displayed to six decimal places."
                            }
                          }
                        },
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "metrics": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "scope": {
                              "type": "string",
                              "enum": [
                                "target",
                                "rest_of_account"
                              ]
                            },
                            "days": {
                              "type": "array",
                              "description": "Three whole days in the ad account timezone; excludes the change day.",
                              "items": {
                                "type": "string",
                                "format": "date"
                              }
                            },
                            "currency": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "timezone": {
                              "type": "string"
                            },
                            "spend_minor": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Decimal spend in ISO currency minor units; null when daily mirror data is missing."
                            },
                            "counted_arrivals": {
                              "type": [
                                "integer",
                                "null"
                              ],
                              "description": "Arrivals counted by PlainRouter through Signals, never provider conversions."
                            },
                            "cost_per_counted_arrival_minor": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Spend divided by counted arrivals, in ISO currency minor units, displayed to six decimal places."
                            },
                            "verdict": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "enum": [
                                "held",
                                "lost",
                                "not_judged",
                                null
                              ]
                            },
                            "loss_threshold_percent": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "inverse": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "proposed",
                            "inverse_not_proposed"
                          ]
                        },
                        "batch_id": {
                          "type": "string"
                        },
                        "reason_code": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "status"
                      ]
                    }
                  },
                  "additionalProperties": {}
                }
              },
              "required": [
                "original_action_id",
                "outcome"
              ]
            },
            {
              "type": "object",
              "properties": {
                "rule_id": {
                  "type": "string"
                },
                "revision_id": {
                  "type": "string"
                },
                "run_id": {
                  "type": "string"
                },
                "decision_id": {
                  "type": "string"
                }
              },
              "required": [
                "rule_id",
                "revision_id",
                "run_id",
                "decision_id"
              ]
            },
            {
              "type": "object",
              "description": "System evidence from a completed Test cites its Test, verdict and selected winner member.",
              "properties": {
                "test_id": {
                  "type": "string"
                },
                "verdict_id": {
                  "type": "string"
                },
                "winner_member_id": {
                  "type": "string"
                }
              },
              "required": [
                "test_id",
                "verdict_id",
                "winner_member_id"
              ]
            }
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "approved_without_execution",
            "rejected",
            "executing",
            "executed_pending_verification",
            "compensating",
            "measuring",
            "verified",
            "failed",
            "execution_uncertain",
            "rolled_back",
            "blocked"
          ]
        },
        "batch_status": {
          "type": "string",
          "enum": [
            "pending",
            "approved",
            "approved_without_execution",
            "auto_approved",
            "rejected",
            "executing",
            "executed_pending_verification",
            "compensating",
            "measuring",
            "completed",
            "failed",
            "rolled_back",
            "rollback_incomplete",
            "blocked",
            "halted"
          ]
        },
        "disposition": {
          "$ref": "#/$defs/ActionCurrentDisposition"
        },
        "policy_decision": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "allow",
            "require_approval",
            "block",
            null
          ]
        },
        "policy_reasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "policy_result": {
          "anyOf": [
            {
              "$ref": "#/$defs/ActionPolicyResult"
            },
            {
              "type": "null"
            }
          ]
        },
        "policy_results": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ActionPolicyResult"
          }
        }
      },
      "required": [
        "id",
        "batch_id",
        "workspace_id",
        "type",
        "target_entity_type",
        "target_entity_id",
        "target_entity_name",
        "params",
        "rationale",
        "status",
        "batch_status",
        "disposition",
        "policy_decision",
        "policy_reasons",
        "policy_result",
        "policy_results"
      ],
      "title": "ActionReadItem"
    }
  }
}