{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Cubstack signed mandate",
  "type": "object",
  "required": [
    "mandate",
    "signature"
  ],
  "properties": {
    "signature": {
      "type": "string",
      "description": "Ed25519 (base64url) by mandate.principal.public_key over the canonical JSON (sorted keys) of `mandate`"
    },
    "mandate": {
      "type": "object",
      "required": [
        "v",
        "id",
        "principal",
        "agent",
        "merchant",
        "actions",
        "expires_at"
      ],
      "properties": {
        "v": {
          "const": 1
        },
        "id": {
          "type": "string"
        },
        "principal": {
          "type": "object",
          "required": [
            "public_key"
          ],
          "properties": {
            "public_key": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "email": {
              "type": "string"
            },
            "custodial": {
              "type": "boolean"
            }
          }
        },
        "agent": {
          "type": "string",
          "description": "agent id or \"*\""
        },
        "merchant": {
          "type": "string",
          "description": "merchant id, slug, or \"*\""
        },
        "actions": {
          "type": "array",
          "items": {
            "enum": [
              "checkout",
              "book",
              "hold",
              "quote",
              "lead"
            ]
          }
        },
        "limits": {
          "type": "object",
          "properties": {
            "currency": {
              "type": "string"
            },
            "per_action": {
              "type": "integer"
            },
            "total": {
              "type": "integer"
            }
          }
        },
        "offers": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "confirm_above": {
          "type": "integer"
        },
        "not_before": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "intent": {
          "type": "string"
        }
      }
    }
  }
}