{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pushary-com/json-schema/pushary-com-create-decision-schema.json",
  "title": "CreateDecision",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pushary-com-openapi.json#/components/schemas/CreateDecision",
  "allOf": [
    {
      "$ref": "#/$defs/DecisionSubject"
    },
    {
      "type": "object",
      "required": [
        "question"
      ],
      "properties": {
        "question": {
          "type": "string",
          "description": "What the person is being asked."
        },
        "presentation": {
          "$ref": "#/$defs/ActionPresentation"
        },
        "type": {
          "type": "string",
          "description": "How the person answers.",
          "enum": [
            "confirm",
            "select",
            "input"
          ]
        },
        "options": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The choices, for a `select` decision."
        },
        "externalId": {
          "type": "string",
          "description": "Your own id for the end-user who should be asked."
        },
        "email": {
          "type": "string",
          "description": "Approver's email. With Slack connected, attempts a DM; lookup or DM failure falls back to the configured shared channel.",
          "format": "email"
        },
        "callbackUrl": {
          "type": "string",
          "description": "Pushary POSTs the resolved decision here, signed with X-Pushary-Signature.",
          "format": "uri"
        },
        "agentName": {
          "type": "string",
          "description": "Shown to the person so they know which agent is asking."
        },
        "context": {
          "type": "string",
          "description": "Free text echoed back after secret redaction on read and on the webhook."
        },
        "placeholder": {
          "type": "string",
          "description": "Placeholder text, for an `input` decision."
        },
        "expiresInSeconds": {
          "type": "integer",
          "description": "Decision lifetime in seconds. Defaults to 3600; clamped to 60–86400."
        },
        "wait": {
          "type": "boolean",
          "description": "Wait for an answer in this request. Defaults to false; does not change the decision lifetime."
        },
        "timeoutSeconds": {
          "type": "integer",
          "description": "Wait budget when wait is true. Defaults to 30 seconds; capped at 55."
        },
        "idempotencyKey": {
          "type": "string",
          "description": "Stable across retries of one logical decision."
        },
        "poweredBy": {
          "type": "boolean",
          "description": "Show Pushary branding on the hosted decision page."
        },
        "approvalUrl": {
          "type": "boolean",
          "description": "Request a recipient-bound bearer approval link on a fresh create. Requires externalId. The link expires after 12 hours or decision expiry, whichever is sooner; omitted on idempotent replays."
        },
        "sandboxOutcome": {
          "type": "string",
          "description": "Simulated answer for sandbox keys only. Ignored for live keys.",
          "enum": [
            "approve",
            "deny",
            "no_answer"
          ]
        },
        "requireReachable": {
          "type": "boolean",
          "description": "Refuse with 409 instead of opening a decision the end-user cannot receive, when the externalId has no enrolled device or push subscription."
        }
      }
    }
  ],
  "$defs": {
    "ActionPresentation": {
      "type": "object",
      "description": "Human-readable action summary. Each change reads its value from parameters; unknown or duplicate parameter references are rejected.",
      "required": [
        "label",
        "effect"
      ],
      "properties": {
        "label": {
          "type": "string",
          "description": "Action name shown to the person.",
          "minLength": 1,
          "maxLength": 80
        },
        "effect": {
          "type": "string",
          "description": "What executing this action does.",
          "minLength": 1,
          "maxLength": 200
        },
        "risk": {
          "type": "string",
          "description": "Why this action needs attention.",
          "maxLength": 200
        },
        "changes": {
          "type": "array",
          "description": "Parameters to display. Values must fit their requested format.",
          "maxItems": 8,
          "items": {
            "type": "object",
            "required": [
              "parameter",
              "label",
              "format"
            ],
            "properties": {
              "parameter": {
                "type": "string",
                "description": "A non-secret key in parameters."
              },
              "label": {
                "type": "string",
                "description": "Human-readable field name.",
                "minLength": 1,
                "maxLength": 80
              },
              "format": {
                "type": "object",
                "description": "Display format. Currency requires an uppercase three-letter currency code and an integer value in minor units.",
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "description": "Format kind.",
                    "enum": [
                      "text",
                      "currency",
                      "quantity",
                      "timestamp",
                      "boolean"
                    ]
                  },
                  "currency": {
                    "type": "string",
                    "description": "Required when kind is currency.",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "unit": {
                    "type": "string",
                    "description": "Optional quantity unit, displayed up to 16 characters."
                  }
                },
                "if": {
                  "properties": {
                    "kind": {
                      "const": "currency"
                    }
                  }
                },
                "then": {
                  "required": [
                    "currency"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "DecisionSubject": {
      "type": "object",
      "description": "What a decision is about. Every field optional: a free-text question alone is a complete decision. Supplying these lets the decision be grouped, risk-classified and matched against a permission rule.",
      "properties": {
        "toolName": {
          "type": "string",
          "description": "The action, e.g. `refund.create` or `database.write`."
        },
        "toolTarget": {
          "type": "string",
          "description": "What the action acts on."
        },
        "actor": {
          "type": "string",
          "description": "Whose authority the action claims, e.g. `user:u_44`. Not necessarily the approver. Maximum 120 characters.",
          "maxLength": 120
        },
        "environment": {
          "type": "string",
          "description": "Which deployment the action runs against, e.g. `production`. Maximum 40 characters.",
          "maxLength": 40
        },
        "parameters": {
          "type": "object",
          "description": "Typed arguments of the action, e.g. `{ \"amount\": 4800, \"currency\": \"EUR\" }`. Scalars only, at most 32 keys. A non-scalar value rejects the whole request with 400 rather than being dropped: a rule that reads a missing parameter can only ever decide more permissively than one that reads it.",
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        }
      }
    }
  }
}