{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://weverlabs.com/schemas/agent-access-key-delivery.schema.json",
  "title": "Agent Access Key Delivery",
  "description": "Delivery object for issuing an OS access key after agent trust approval. The object carries delivery state, credential envelope references, callback routing, scope, expiration, rotation, and audit trail pointers.",
  "type": "object",
  "required": [
    "delivery_id",
    "agent_id",
    "trust_profile_id",
    "credential_envelope_id",
    "delivery_status",
    "issued_at",
    "scope",
    "delivery_channels",
    "links"
  ],
  "properties": {
    "delivery_id": {
      "type": "string"
    },
    "agent_id": {
      "type": "string"
    },
    "agent_name": {
      "type": "string"
    },
    "trust_profile_id": {
      "type": "string"
    },
    "onboarding_id": {
      "type": "string"
    },
    "credential_envelope_id": {
      "type": "string"
    },
    "access_key_id": {
      "type": "string"
    },
    "delivery_status": {
      "type": "string",
      "enum": [
        "created",
        "queued_for_delivery",
        "callback_delivered",
        "contact_delivered",
        "retrieval_ready",
        "rotated",
        "revoked",
        "delivery_failed"
      ]
    },
    "issued_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "scope": {
      "type": "object",
      "properties": {
        "allowed_tools": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "allowed_capabilities": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "accepted_data_modes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "credit_account_id": {
          "type": "string"
        },
        "contract_required": {
          "type": "boolean"
        }
      },
      "additionalProperties": true
    },
    "delivery_channels": {
      "type": "object",
      "properties": {
        "callback_url": {
          "type": "string",
          "format": "uri"
        },
        "contact_channel": {
          "type": "string"
        },
        "status_url": {
          "type": "string",
          "format": "uri"
        }
      },
      "additionalProperties": true
    },
    "rotation_policy": {
      "type": "object",
      "properties": {
        "rotation_supported": {
          "type": "boolean"
        },
        "rotation_url": {
          "type": "string",
          "format": "uri"
        },
        "default_rotation_days": {
          "type": "integer"
        }
      },
      "additionalProperties": true
    },
    "links": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    }
  },
  "additionalProperties": true
}
