{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:cede:schema:exchange-grants:v0",
  "title": "Craton model exchange grants, v0",
  "description": "The body of GET /exchange/models/{id}/grants, and of the PUT and DELETE that grant and revoke one account: the accounts the provider of a listing has granted the right to run it. Read and changed by the provider only. A grant matters on a listing whose access is by_grant; on a free listing every account may run the model and grants are kept but read by nothing. Craton records who is granted and nothing about why: any payment for access is between the user and the provider, outside Craton.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "model_id", "access", "count", "grants"],
  "properties": {
    "schema_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "model_id": { "type": "string", "pattern": "^xm_[0-9a-f]{16}$" },
    "access": { "enum": ["free", "by_grant"], "description": "The listing's access, restated so a reader of this list alone knows whether it is read." },
    "count": { "type": "integer", "minimum": 0, "description": "Equal to the length of `grants`: Craton pages nothing." },
    "grants": {
      "type": "array",
      "description": "The granted accounts, oldest grant first.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["account_id", "granted_at"],
        "properties": {
          "account_id": { "type": "string", "pattern": "^acct_[0-9a-f]{24}$" },
          "granted_at": { "type": "string", "format": "date-time" }
        }
      }
    }
  }
}
