{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://autoagentprotocol.org/v4.0/schemas/consent-grant.schema.json",
  "title": "ConsentGrant",
  "description": "Explicit, auditable permission for one lead_submit or trade_in_submit payload and its selected contact channels. A missing grant returns CONTACT_CONSENT_REQUIRED. A malformed, expired or inapplicable grant returns INVALID_CONSENT. A session, tool selection or OAuth authorization is not customer contact consent.",
  "type": "object",
  "properties": {
    "granted_at": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 / RFC 3339 timestamp at which the user authorized this share (e.g. '2026-04-30T11:05:00Z'). MUST include a timezone offset (Z or ±HH:MM)."
    },
    "allowed_channels": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": ["email", "phone", "sms"]
      },
      "description": "Channels the user has authorized the dealer to use for follow-up."
    },
    "consent_text": {
      "type": "string",
      "minLength": 1,
      "description": "Verbatim text the user agreed to (e.g. the disclosure shown by the buyer agent). MUST be non-empty — this is the audit trail of what the user actually saw.",
      "pattern": "\\S"
    },
    "scope": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": ["lead_submission", "trade_in_submission"]
      },
      "description": "Scope of the consent, exactly one value. `lead_submission` covers the unified `lead_submit` skill (general inquiries, vehicle interest, trade-in and appointments). `trade_in_submission` covers contact data sent with `trade_in_submit`. Each skill accepts only its own value. The request body itself shows what was actually submitted; the meaningful audit granularity is `allowed_channels`."
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "Optional deadline for using this grant. When present it must follow granted_at. The dealer must not deliver or use customer contact data after this time without renewed permission. AAP does not prescribe a legal consent lifetime."
    }
  },
  "required": ["granted_at", "allowed_channels", "consent_text", "scope"],
  "additionalProperties": false
}
