DeepStack API v2 contracts, package 1be436ac1a7c (CC-BY-4.0), new version over 1e3bc19d329b
b650253 verified Download schemas/api-key.schema.json from deepstack-ml/deepstack-api-v2-contracts: direct link, hf CLI and curl.
- Browser
- Download file 7.97 kB
-
https://huggingface.co/datasets/deepstack-ml/deepstack-api-v2-contracts/resolve/main/schemas/api-key.schema.json
- Command line
-
hf download hf://datasets/deepstack-ml/deepstack-api-v2-contracts/schemas/api-key.schema.json
-
curl -L -o api-key.schema.json https://huggingface.co/datasets/deepstack-ml/deepstack-api-v2-contracts/resolve/main/schemas/api-key.schema.json
7.97 kB
| { | |
| "$schema": "https://json-schema.org/draft/2020-12/schema", | |
| "$id": "api-key.schema.json", | |
| "title": "ApiKeyRecord", | |
| "description": "One API key as the server stores it (INT-007/APP-10, R4; R5: the single key system). The secret is never stored: only a salted PBKDF2-HMAC-SHA256 digest, with its own random salt. A key is either a /v2 key (workspace_id null; scopes 'route:purpose' from a closed list) or a workspace key (workspace_id set; workspace:* scopes only), never both. A key is never a forecasting machine, never trains, retains or publishes. rights is the ceiling of the rights a request may claim (and, on /v2/search, the purposes every item must carry). phase is always pre_lock: a key cannot attest a lock. Cross-field rules (semantic.check_api_key): a revoked key has revoked_at and revoked_reason, a live one has neither; expires_at is after created_at; a rotating key names rotated_to and grace_until; workspace scopes exactly when workspace_id. The public view ($defs/public_view) is what /v2/keys/self answers and has no salt and no digest.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "schema_version", | |
| "key_id", | |
| "tenant_id", | |
| "workspace_id", | |
| "label", | |
| "scopes", | |
| "rights", | |
| "quota", | |
| "status", | |
| "phase", | |
| "hash", | |
| "created_at", | |
| "expires_at", | |
| "rotated_from", | |
| "rotated_to", | |
| "grace_until", | |
| "revoked_at", | |
| "revoked_reason" | |
| ], | |
| "properties": { | |
| "schema_version": { | |
| "$ref": "common.schema.json#/$defs/schema_version" | |
| }, | |
| "key_id": { | |
| "$ref": "#/$defs/key_id" | |
| }, | |
| "tenant_id": { | |
| "$ref": "#/$defs/tenant_id" | |
| }, | |
| "workspace_id": { | |
| "$ref": "#/$defs/workspace_id" | |
| }, | |
| "label": { | |
| "$ref": "#/$defs/label" | |
| }, | |
| "scopes": { | |
| "$ref": "#/$defs/scopes" | |
| }, | |
| "rights": { | |
| "$ref": "#/$defs/rights" | |
| }, | |
| "quota": { | |
| "$ref": "#/$defs/quota" | |
| }, | |
| "status": { | |
| "$ref": "#/$defs/status" | |
| }, | |
| "phase": { | |
| "const": "pre_lock" | |
| }, | |
| "hash": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "algorithm", | |
| "iterations", | |
| "salt", | |
| "digest" | |
| ], | |
| "properties": { | |
| "algorithm": { | |
| "const": "pbkdf2-hmac-sha256" | |
| }, | |
| "iterations": { | |
| "type": "integer", | |
| "minimum": 10000, | |
| "maximum": 10000000 | |
| }, | |
| "salt": { | |
| "type": "string", | |
| "pattern": "^[0-9a-f]{32}$" | |
| }, | |
| "digest": { | |
| "$ref": "common.schema.json#/$defs/sha256" | |
| } | |
| } | |
| }, | |
| "created_at": { | |
| "$ref": "common.schema.json#/$defs/utc" | |
| }, | |
| "expires_at": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$" | |
| }, | |
| "rotated_from": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^key_[0-9a-f]{16}$" | |
| }, | |
| "rotated_to": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^key_[0-9a-f]{16}$" | |
| }, | |
| "grace_until": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$" | |
| }, | |
| "revoked_at": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$" | |
| }, | |
| "revoked_reason": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "enum": [ | |
| null, | |
| "owner_revoked", | |
| "rotated", | |
| "compromised", | |
| "tenant_closed", | |
| "workspace_archived" | |
| ] | |
| } | |
| }, | |
| "$defs": { | |
| "key_id": { | |
| "type": "string", | |
| "pattern": "^key_[0-9a-f]{16}$" | |
| }, | |
| "tenant_id": { | |
| "description": "tenant:<slug>. Canonical: tenant:deepstack-public (every reader of the app) and tenant:deepstack-internal; keys exist locally only in tenant:deepstack-internal and, in tests, tenant:qa-*.", | |
| "type": "string", | |
| "pattern": "^tenant:[a-z0-9][a-z0-9-]{1,62}$" | |
| }, | |
| "workspace_id": { | |
| "description": "The one workspace a workspace key is bound to; null for a /v2 key.", | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^ws_[0-9A-Za-z]{4,64}$" | |
| }, | |
| "label": { | |
| "type": "string", | |
| "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]{0,63}$" | |
| }, | |
| "scopes": { | |
| "type": "array", | |
| "minItems": 1, | |
| "maxItems": 8, | |
| "uniqueItems": true, | |
| "items": { | |
| "enum": [ | |
| "answers:analyst", | |
| "answers:resolution_explainer", | |
| "search:analyst", | |
| "scenarios:analyst", | |
| "trackrecord:read", | |
| "workspace:read", | |
| "workspace:collections.read", | |
| "workspace:notes.read", | |
| "workspace:export.process" | |
| ] | |
| } | |
| }, | |
| "rights": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "policy_version", | |
| "purposes" | |
| ], | |
| "properties": { | |
| "policy_version": { | |
| "$ref": "common.schema.json#/$defs/id" | |
| }, | |
| "purposes": { | |
| "type": "array", | |
| "minItems": 1, | |
| "maxItems": 3, | |
| "uniqueItems": true, | |
| "items": { | |
| "enum": [ | |
| "read", | |
| "process", | |
| "external_provider" | |
| ] | |
| } | |
| } | |
| } | |
| }, | |
| "quota": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "per_minute", | |
| "per_day", | |
| "concurrency" | |
| ], | |
| "properties": { | |
| "per_minute": { | |
| "type": "integer", | |
| "minimum": 1, | |
| "maximum": 600 | |
| }, | |
| "per_day": { | |
| "type": "integer", | |
| "minimum": 1, | |
| "maximum": 100000 | |
| }, | |
| "concurrency": { | |
| "type": "integer", | |
| "minimum": 1, | |
| "maximum": 16 | |
| } | |
| } | |
| }, | |
| "status": { | |
| "enum": [ | |
| "active", | |
| "rotating", | |
| "revoked", | |
| "expired" | |
| ] | |
| }, | |
| "public_view": { | |
| "description": "What a key holder may read about its own key: no salt, no digest, no other key of the tenant.", | |
| "type": "object", | |
| "additionalProperties": false, | |
| "required": [ | |
| "schema_version", | |
| "key_id", | |
| "tenant_id", | |
| "workspace_id", | |
| "label", | |
| "scopes", | |
| "rights", | |
| "quota", | |
| "status", | |
| "phase", | |
| "principal_scope", | |
| "expires_at", | |
| "grace_until" | |
| ], | |
| "properties": { | |
| "schema_version": { | |
| "$ref": "common.schema.json#/$defs/schema_version" | |
| }, | |
| "key_id": { | |
| "$ref": "#/$defs/key_id" | |
| }, | |
| "tenant_id": { | |
| "$ref": "#/$defs/tenant_id" | |
| }, | |
| "workspace_id": { | |
| "$ref": "#/$defs/workspace_id" | |
| }, | |
| "label": { | |
| "$ref": "#/$defs/label" | |
| }, | |
| "scopes": { | |
| "$ref": "#/$defs/scopes" | |
| }, | |
| "rights": { | |
| "$ref": "#/$defs/rights" | |
| }, | |
| "quota": { | |
| "$ref": "#/$defs/quota" | |
| }, | |
| "status": { | |
| "$ref": "#/$defs/status" | |
| }, | |
| "phase": { | |
| "const": "pre_lock" | |
| }, | |
| "principal_scope": { | |
| "$ref": "common.schema.json#/$defs/principal_scope" | |
| }, | |
| "expires_at": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$" | |
| }, | |
| "grace_until": { | |
| "type": [ | |
| "string", | |
| "null" | |
| ], | |
| "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|\\+00:00)$" | |
| } | |
| } | |
| } | |
| } | |
| } | |