{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://actionreceipt.com/spec/v0.1/schema.json",
  "type": "object",
  "required": [
    "spec",
    "id",
    "issued_at",
    "issuer",
    "principal",
    "agent",
    "mandate",
    "action",
    "verify_url",
    "status"
  ],
  "properties": {
    "spec": {
      "const": "actionreceipt/0.1"
    },
    "id": {
      "type": "string",
      "minLength": 10
    },
    "issued_at": {
      "type": "string",
      "format": "date-time"
    },
    "issuer": {
      "type": "object",
      "required": [
        "name",
        "domain",
        "keys"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "domain": {
          "type": "string"
        },
        "keys": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "principal": {
      "type": "object",
      "required": [
        "name",
        "identity_assurance",
        "principal_id"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "role": {
          "type": "string"
        },
        "org": {
          "type": "string"
        },
        "identity_assurance": {
          "enum": [
            "self_asserted",
            "email_verified",
            "verified"
          ]
        },
        "principal_id": {
          "type": "string"
        }
      }
    },
    "agent": {
      "type": "object",
      "required": [
        "agent_id"
      ],
      "properties": {
        "agent_id": {
          "type": "string"
        },
        "software": {
          "type": "string"
        },
        "model": {
          "type": "string"
        },
        "operator": {
          "type": "string"
        }
      }
    },
    "mandate": {
      "type": "object",
      "required": [
        "mandate_id",
        "granted_at",
        "scope"
      ],
      "properties": {
        "mandate_id": {
          "type": "string"
        },
        "granted_at": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "scope": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "review_policy": {
          "enum": [
            "none",
            "flagged",
            "full"
          ]
        },
        "constraints": {
          "type": "object"
        },
        "revocable": {
          "type": "boolean"
        }
      }
    },
    "action": {
      "type": "object",
      "required": [
        "type",
        "performed_at"
      ],
      "properties": {
        "type": {
          "type": "string"
        },
        "performed_at": {
          "type": "string",
          "format": "date-time"
        },
        "channel": {
          "type": "string"
        },
        "counterparty": {
          "type": "object"
        },
        "summary": {
          "type": "string",
          "maxLength": 280
        }
      }
    },
    "evidence": {
      "type": "object",
      "properties": {
        "input_hash": {
          "type": "string"
        },
        "output_hash": {
          "type": "string"
        },
        "hash_alg": {
          "type": "string"
        }
      }
    },
    "review": {
      "type": "object",
      "required": [
        "reviewed_by",
        "reviewed_at",
        "items",
        "decision"
      ],
      "properties": {
        "reviewed_by": {
          "type": "object",
          "required": [
            "name"
          ],
          "properties": {
            "name": {
              "type": "string"
            },
            "principal_id": {
              "type": "string"
            }
          }
        },
        "reviewed_at": {
          "type": "string",
          "format": "date-time"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "decision": {
          "const": "approved"
        }
      }
    },
    "chain": {
      "type": "object",
      "properties": {
        "seq": {
          "type": "integer",
          "minimum": 0
        },
        "prev_receipt_id": {
          "type": "string"
        },
        "prev_receipt_hash": {
          "type": "string"
        }
      }
    },
    "verify_url": {
      "type": "string",
      "format": "uri"
    },
    "status": {
      "enum": [
        "valid",
        "revoked",
        "disputed",
        "settled"
      ]
    }
  },
  "patternProperties": {
    "^x_": {}
  },
  "additionalProperties": false
}