{"openapi":"3.0.0","info":{"title":"Koshee Console API","version":"0.1.0","description":"REST API for managing zip file assets with presigned S3 uploads.\n\nProduction hosts (both resolve to the same Worker):\n- `https://console.koshee.io` (canonical)\n- `https://caption-assets.james-a83.workers.dev` (permanent alias)\n\n\n## Authentication\n\nAPI keys are passed via the `X-API-Key` header.\n\n## Upload Flow\n\n1. **Create** an asset via `POST /v1/assets` — returns a presigned upload URL\n2. **Upload** the file to the presigned URL using HTTP PUT\n3. **Confirm** the upload via `POST /v1/assets/{id}/confirm` — transitions the asset to active\n\nFor large files, use the multipart upload flow instead (init → get part URLs → complete → confirm).\n\n## Python Example — Small Files (< 100 MB)\n\n```python\nimport requests\n\nBASE = \"https://console.koshee.io\"\nHEADERS = {\"X-API-Key\": \"pac_YOUR_API_KEY_HERE\"}\n\n# Create an asset\nresp = requests.post(f\"{BASE}/v1/assets\", headers=HEADERS, json={\n    \"filename\": \"capture.zip\",\n    \"metadata\": {\n        \"name\": \"Caption upload name\",\n        \"customer\": \"Dustin\",\n        \"tags\": [\"tag1\", \"tag2\"],\n        \"description\": \"description\"\n    }\n})\nasset = resp.json()\nasset_id, upload_url = asset[\"id\"], asset[\"upload_url\"]\n\n# Upload the file (Content-Type must be application/zip)\nwith open(\"capture.zip\", \"rb\") as f:\n    requests.put(upload_url, data=f, headers={\"Content-Type\": \"application/zip\"})\n\n# Confirm, then download or list\nrequests.post(f\"{BASE}/v1/assets/{asset_id}/confirm\", headers=HEADERS)\n```\n\n## Python Example — Large Files (100 MB+, multipart)\n\n```python\nimport requests\n\nBASE = \"https://console.koshee.io\"\nHEADERS = {\"X-API-Key\": \"pac_YOUR_API_KEY_HERE\"}\nPART_SIZE = 100 * 1024 * 1024  # 100 MB per part\n\n# 1. Create asset\nresp = requests.post(f\"{BASE}/v1/assets\", headers=HEADERS, json={\n    \"filename\": \"large-capture.zip\",\n    \"metadata\": {\n        \"name\": \"Caption upload name\",\n        \"customer\": \"Dustin\",\n        \"tags\": [\"tag1\", \"tag2\"],\n        \"description\": \"description\"\n    }\n})\nasset_id = resp.json()[\"id\"]\n\n# 2. Init multipart upload\nsession = requests.post(\n    f\"{BASE}/v1/assets/{asset_id}/upload/multipart\", headers=HEADERS\n).json()\nsession_id = session[\"session_id\"]\n\n# 3. Upload parts\nparts = []\nwith open(\"large-capture.zip\", \"rb\") as f:\n    part_num = 1\n    while True:\n        chunk = f.read(PART_SIZE)\n        if not chunk:\n            break\n        url = requests.get(\n            f\"{BASE}/v1/assets/{asset_id}/upload/multipart/{session_id}/part/{part_num}\",\n            headers=HEADERS,\n        ).json()[\"upload_url\"]\n        etag = requests.put(url, data=chunk).headers[\"ETag\"]\n        parts.append({\"part_number\": part_num, \"etag\": etag})\n        print(f\"  Part {part_num}: {len(chunk) / 1024 / 1024:.0f} MB uploaded\")\n        part_num += 1\n\n# 4. Complete multipart upload\nrequests.post(\n    f\"{BASE}/v1/assets/{asset_id}/upload/multipart/{session_id}/complete\",\n    headers=HEADERS,\n    json={\"parts\": parts},\n)\n\n# 5. Confirm the asset\nrequests.post(f\"{BASE}/v1/assets/{asset_id}/confirm\", headers=HEADERS)\n```\n\n## Generic Files\n\nThe `/v1/files` endpoint group is a parallel pipeline to `/v1/assets` for arbitrary user uploads. Same zip-on-disk storage, same multipart flow, but metadata is optional and confirmation does not send email notifications.\n\n## Public Keys\n\nRegister an Ed25519 or RSA-PSS SHA-256 SPKI public key via `POST /v1/public-keys`. Verify a signature with `POST /v1/public-keys/{id}/verify`. Verification returns HTTP 200 with `{ valid: boolean }` whether or not the signature is valid; revoked keys return 410. Verify requests are rate limited to 60/min per user.\n\n## Error Format\n\nAll errors return a consistent JSON envelope:\n```json\n{ \"error\": \"error_code\", \"message\": \"Human-readable description\" }\n```\n\nCommon error codes: `validation_error`, `not_found`, `forbidden`, `invalid_token`, `idempotency_mismatch`, `upload_not_found`, `rate_limited`, `duplicate_fingerprint`, `key_revoked`."},"tags":[{"name":"Assets","description":"Create, list, get, download, and delete assets. Assets follow a create → upload → confirm lifecycle."},{"name":"Multipart Upload","description":"Upload large files in parts. Start a session, upload each part to its presigned URL, then complete."},{"name":"System","description":"Health and readiness probes for container orchestration."}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","bearerFormat":"JWT"},"apiKey":{"type":"apiKey","in":"header","name":"X-API-Key"}},"schemas":{"HealthResponse":{"type":"object","properties":{"status":{"type":"string","enum":["ok"]}},"required":["status"],"description":"Liveness probe response","example":{"status":"ok"}},"ReadyResponse":{"type":"object","properties":{"status":{"type":"string","enum":["ready"]}},"required":["status"],"description":"Readiness probe response","example":{"status":"ready"}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string","description":"Machine-readable error code","example":"not_found"},"message":{"type":"string","description":"Human-readable error description","example":"Asset not found"}},"required":["error","message"],"description":"Standard error envelope returned by all error responses","example":{"error":"not_found","message":"Asset not found"}},"AssetCreateResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Unique asset ID"},"upload_url":{"type":"string","format":"uri","description":"Presigned S3 PUT URL for uploading the file"},"expires_in":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Seconds until the upload URL expires"}},"required":["id","upload_url","expires_in"],"description":"Returned after creating a new asset. Contains the presigned upload URL.","example":{"id":"550e8400-e29b-41d4-a716-446655440000","upload_url":"https://s3.example.com/assets/550e8400.zip?X-Amz-Signature=...","expires_in":3600}},"ValidationErrorResponse":{"type":"object","properties":{"error":{"type":"string","enum":["validation_error"],"description":"Always 'validation_error'"},"message":{"type":"string","description":"Describes the first validation failure, in the format 'field: reason'","example":"filename: String must contain at least 1 character(s)"}},"required":["error","message"],"description":"Returned when request body, query, or path parameters fail schema validation","example":{"error":"validation_error","message":"filename: String must contain at least 1 character(s)"}},"AssetCreateRequest":{"type":"object","properties":{"filename":{"type":"string","minLength":1,"maxLength":255,"description":"Original filename (1–255 characters)","example":"annotations-v3.zip"},"metadata":{"$ref":"#/components/schemas/AssetMetadata"}},"required":["filename","metadata"],"description":"Request body to create a new asset and receive a presigned upload URL","example":{"filename":"annotations-v3.zip","metadata":{"name":"Training Pack v3","description":"Updated annotations for Q1"}}},"AssetMetadata":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255,"description":"Display name for the asset"},"description":{"type":"string","maxLength":2000,"description":"Optional long description"},"version":{"type":"string","description":"Optional version string"},"tags":{"type":"array","items":{"type":"string"},"description":"Optional tags for categorization"}},"required":["name"],"additionalProperties":{"nullable":true},"description":"Asset metadata. The name field is required; all other fields are optional. Additional properties are allowed.","example":{"name":"Training Pack v3","description":"Updated annotations for Q1","tags":["training","v3"]}},"MultipartInitResponse":{"type":"object","properties":{"session_id":{"type":"string","format":"uuid","description":"Upload session ID, used in subsequent part/complete/abort calls"},"expires_in":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Seconds until the session expires"}},"required":["session_id","expires_in"],"description":"Returned after starting a multipart upload session.","example":{"session_id":"660e8400-e29b-41d4-a716-446655440000","expires_in":3600}},"MultipartPartResponse":{"type":"object","properties":{"upload_url":{"type":"string","format":"uri","description":"Presigned S3 PUT URL for this part"},"expires_in":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Seconds until the part URL expires"}},"required":["upload_url","expires_in"],"description":"Presigned upload URL for a single part of a multipart upload.","example":{"upload_url":"https://s3.example.com/assets/550e8400.zip?partNumber=1&uploadId=...","expires_in":900}},"SuccessResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]}},"required":["success"],"description":"Generic success response for operations that have no specific return data.","example":{"success":true}},"MultipartCompleteRequest":{"type":"object","properties":{"parts":{"type":"array","items":{"type":"object","properties":{"part_number":{"type":"integer","minimum":1,"description":"Part number (1-based)","example":1},"etag":{"type":"string","minLength":1,"description":"ETag returned by S3 after uploading this part","example":"\"d41d8cd98f00b204e9800998ecf8427e\""}},"required":["part_number","etag"]},"minItems":1,"description":"Array of uploaded parts (at least one required)"}},"required":["parts"],"description":"Submit the list of uploaded parts to finalize a multipart upload","example":{"parts":[{"part_number":1,"etag":"\"abc123\""},{"part_number":2,"etag":"\"def456\""}]}},"AssetResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Unique asset ID"},"filename":{"type":"string","description":"Original filename"},"size_bytes":{"type":"number","nullable":true,"description":"File size in bytes, null if not yet uploaded"},"status":{"type":"string","enum":["pending","active","deleted"],"description":"pending = awaiting upload, active = confirmed, deleted = soft-deleted"},"metadata":{"$ref":"#/components/schemas/AssetMetadata"},"uploaded_by":{"type":"string","description":"Name of the user who uploaded the asset"},"assigned_to":{"$ref":"#/components/schemas/AssetAssignee"},"assigned_at":{"type":"string","nullable":true,"format":"date-time","description":"ISO 8601 timestamp the assignee claimed the asset; null when unassigned."},"created_at":{"type":"string","format":"date-time","description":"ISO 8601 creation timestamp"},"updated_at":{"type":"string","format":"date-time","description":"ISO 8601 last-updated timestamp"}},"required":["id","filename","size_bytes","status","metadata","assigned_to","assigned_at","created_at","updated_at"],"description":"Full asset details including status, metadata, assignment, and timestamps.","example":{"id":"550e8400-e29b-41d4-a716-446655440000","filename":"annotations-v3.zip","size_bytes":10485760,"status":"active","metadata":{"name":"Training Pack v3"},"uploaded_by":"API Client","assigned_to":null,"assigned_at":null,"created_at":"2026-01-15T10:30:00.000Z","updated_at":"2026-01-15T10:32:00.000Z"}},"AssetAssignee":{"type":"object","nullable":true,"properties":{"user_id":{"type":"string","description":"Internal user id of the assignee"},"name":{"type":"string","description":"Display name of the assignee"},"email":{"type":"string","format":"email","description":"Email of the assignee"}},"required":["user_id","name","email"],"description":"User currently working on this asset (claimed via Take). Null when unassigned."},"AssetListResponse":{"type":"object","properties":{"assets":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponse"}},"next_cursor":{"type":"string","nullable":true,"format":"uuid","description":"Pass as ?cursor= to fetch the next page. Null when no more results."}},"required":["assets","next_cursor"],"description":"Paginated list of assets. Use next_cursor for keyset pagination."},"AssetDownloadResponse":{"type":"object","properties":{"download_url":{"type":"string","format":"uri","description":"Presigned S3 GET URL for downloading the file"},"expires_in":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Seconds until the download URL expires"}},"required":["download_url","expires_in"],"description":"Presigned download URL for retrieving the asset file.","example":{"download_url":"https://s3.example.com/assets/550e8400.zip?X-Amz-Signature=...","expires_in":3600}},"AssetClaimConflict":{"type":"object","properties":{"error":{"type":"string","enum":["already_claimed"]},"message":{"type":"string"},"assigned_to":{"allOf":[{"$ref":"#/components/schemas/AssetAssignee"},{"description":"The user who has currently claimed this asset."}]}},"required":["error","message","assigned_to"],"description":"Returned with HTTP 409 when the caller tries to claim an asset already held by another user."},"FileCreateResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Unique file ID"},"upload_url":{"type":"string","format":"uri","description":"Presigned S3 PUT URL"},"expires_in":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Seconds until the upload URL expires"}},"required":["id","upload_url","expires_in"]},"FileCreateRequest":{"type":"object","properties":{"filename":{"type":"string","minLength":1,"maxLength":255,"description":"Original filename (1–255 characters)","example":"backup.zip"},"metadata":{"$ref":"#/components/schemas/FileMetadata"}},"required":["filename"],"description":"Request body to create a generic file upload. Metadata is optional.","example":{"filename":"backup.zip","metadata":{"tags":["archive"]}}},"FileMetadata":{"type":"object","additionalProperties":{"nullable":true},"description":"Freeform JSON object. Optional. Any structure is accepted.","example":{"tags":["archive"],"source":"caption-tool"}},"FileResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"filename":{"type":"string"},"size_bytes":{"type":"number","nullable":true},"status":{"type":"string","enum":["pending","active","deleted"]},"metadata":{"allOf":[{"$ref":"#/components/schemas/FileMetadata"},{"nullable":true}]},"uploaded_by":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","filename","size_bytes","status","metadata","created_at","updated_at"],"description":"Full file record."},"FileListResponse":{"type":"object","properties":{"files":{"type":"array","items":{"$ref":"#/components/schemas/FileResponse"}},"next_cursor":{"type":"string","nullable":true,"format":"uuid"}},"required":["files","next_cursor"]},"FileDownloadResponse":{"type":"object","properties":{"download_url":{"type":"string","format":"uri"},"expires_in":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"required":["download_url","expires_in"]},"PublicKeyResponse":{"type":"object","properties":{"id":{"type":"string","description":"Public key record ID"},"name":{"type":"string"},"algorithm":{"type":"string","description":"Key algorithm (e.g. ed25519)"},"public_key_pem":{"type":"string","description":"Public key content as stored"},"key_prefix":{"type":"string","description":"First 8 hex chars of the SHA-256 fingerprint"},"key_fingerprint":{"type":"string","description":"Full hex SHA-256 fingerprint of the key content"},"created_at":{"type":"string","format":"date-time"},"revoked_at":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","name","algorithm","public_key_pem","key_prefix","key_fingerprint","created_at","revoked_at"]},"PublicKeyRegisterRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255,"description":"Human-readable key label (e.g. hostname)"},"algorithm":{"type":"string","description":"Key algorithm hint (e.g. ed25519). Optional — defaults to ed25519."},"public_key_pem":{"type":"string","minLength":1,"description":"Public key content. Any format accepted: SSH (ssh-ed25519 ...), SPKI PEM, or raw PEM."}},"required":["name","public_key_pem"],"example":{"name":"koshee-protect-01","public_key_pem":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... koshee-protect-01"}},"PublicKeyListResponse":{"type":"object","properties":{"keys":{"type":"array","items":{"$ref":"#/components/schemas/PublicKeyResponse"}}},"required":["keys"]},"PublicKeyVerifyResponse":{"type":"object","properties":{"valid":{"type":"boolean"},"verified_at":{"type":"string","format":"date-time"}},"required":["valid","verified_at"]},"PublicKeyVerifyRequest":{"type":"object","properties":{"payload_base64":{"type":"string","minLength":1,"description":"Base64-encoded bytes that were signed"},"signature_base64":{"type":"string","minLength":1,"description":"Base64-encoded signature"}},"required":["payload_base64","signature_base64"]},"ApiKeyListResponse":{"type":"object","properties":{"api_keys":{"type":"array","items":{"$ref":"#/components/schemas/ApiKeyResponse"}}},"required":["api_keys"]},"ApiKeyResponse":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"key_prefix":{"type":"string"},"created_at":{"type":"string","format":"date-time"}},"required":["id","name","key_prefix","created_at"]},"ApiKeyCreateResponse":{"allOf":[{"$ref":"#/components/schemas/ApiKeyResponse"},{"type":"object","properties":{"key":{"type":"string","description":"Full API key — shown only once"}},"required":["key"]}]},"ApiKeyCreateRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100}},"required":["name"]},"TunnelCreateResponse":{"allOf":[{"$ref":"#/components/schemas/TunnelResponse"},{"type":"object","properties":{"tunnel_token":{"type":"string","description":"Cloudflare tunnel token for TUNNEL_TOKEN env var"}},"required":["tunnel_token"]}]},"TunnelResponse":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"cloudflare_tunnel_id":{"type":"string"},"hostname":{"type":"string"},"status":{"type":"string","enum":["active","deleted"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","name","cloudflare_tunnel_id","hostname","status","created_at"]},"TunnelCreateRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"description":"Tunnel name (e.g. dustindemo)"},"hostname":{"type":"string","minLength":1,"maxLength":255,"description":"DNS hostname (e.g. *.dustin.aw.koshee.io)"},"origin_service":{"type":"string","description":"Origin service URL. Defaults to http://app-http:8000"}},"required":["name","hostname"]},"TunnelListResponse":{"type":"object","properties":{"tunnels":{"type":"array","items":{"$ref":"#/components/schemas/TunnelResponse"}}},"required":["tunnels"]},"TunnelTokenResponse":{"type":"object","properties":{"tunnel_token":{"type":"string"}},"required":["tunnel_token"]},"TunnelResetResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"recreated":{"type":"boolean"},"tunnel_token":{"type":"string"}},"required":["success","recreated"]},"DeployAssetResponse":{"type":"object","properties":{"name":{"type":"string"},"size_bytes":{"type":"number","nullable":true},"content_type":{"type":"string"},"updated_at":{"type":"string","format":"date-time"}},"required":["name","size_bytes","content_type","updated_at"]},"DeployAssetListResponse":{"type":"object","properties":{"assets":{"type":"array","items":{"$ref":"#/components/schemas/DeployAssetResponse"}}},"required":["assets"]}},"parameters":{}},"paths":{"/health":{"get":{"operationId":"healthCheck","summary":"Liveness check","description":"Returns 200 if the process is running. Use for Kubernetes liveness probes.","tags":["System"],"responses":{"200":{"description":"Service is alive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/ready":{"get":{"operationId":"readinessCheck","summary":"Readiness check","description":"Returns 200 when the service and all dependencies (database, object storage) are available. Returns 503 if any dependency is unreachable. Use for Kubernetes readiness probes.","tags":["System"],"responses":{"200":{"description":"Service is ready to accept traffic","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadyResponse"}}}},"503":{"description":"One or more dependencies (database, S3) are unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets":{"post":{"operationId":"createAsset","summary":"Create asset","description":"Creates a new asset record and returns a presigned S3 upload URL. Starts in pending status until confirmed via POST /v1/assets/{id}/confirm.","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"idempotency-key","in":"header"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetCreateRequest"}}}},"responses":{"200":{"description":"Asset created. Upload your file to the presigned upload_url via HTTP PUT.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetCreateResponse"}}}},"400":{"description":"Request body failed validation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Missing or invalid credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Web/labeler users cannot create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Idempotency-Key reused with a different payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"get":{"operationId":"listAssets","summary":"List assets","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["all","unassigned","mine","others","assigned"]},"required":false,"name":"assignment","in":"query"},{"schema":{"type":"string","enum":["labeler_workload"]},"required":false,"name":"view","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":256},"required":false,"name":"assigned_to_user_id","in":"query"}],"responses":{"200":{"description":"Paginated list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetListResponse"}}}},"400":{"description":"Invalid query","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}/upload/multipart":{"post":{"operationId":"initMultipartUpload_assets","summary":"Start multipart upload","tags":["Multipart Upload"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Session created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MultipartInitResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Invalid status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}/upload/multipart/{sessionId}/part/{partNumber}":{"get":{"operationId":"getMultipartPartUrl_assets","summary":"Get part upload URL","tags":["Multipart Upload"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"},{"schema":{"type":"integer","nullable":true},"required":false,"name":"partNumber","in":"path"}],"responses":{"200":{"description":"Presigned PUT URL for this part.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MultipartPartResponse"}}}},"400":{"description":"Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Invalid session status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}/upload/multipart/{sessionId}/complete":{"post":{"operationId":"completeMultipartUpload_assets","summary":"Complete multipart upload","tags":["Multipart Upload"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MultipartCompleteRequest"}}}},"responses":{"200":{"description":"Upload assembled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Invalid session status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}/upload/multipart/{sessionId}/abort":{"post":{"operationId":"abortMultipartUpload_assets","summary":"Abort multipart upload","tags":["Multipart Upload"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"}],"responses":{"200":{"description":"Aborted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Invalid session status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}/confirm":{"post":{"operationId":"confirmAsset","summary":"Confirm asset upload","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Asset active.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found or upload missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"413":{"description":"Too large","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}":{"get":{"operationId":"getAsset","summary":"Get asset details","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Asset details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"operationId":"deleteAsset","summary":"Delete asset","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Soft-deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}/download":{"get":{"operationId":"downloadAsset","summary":"Get download URL","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Presigned download URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetDownloadResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}/file":{"get":{"operationId":"streamAssetFile","summary":"Download asset file","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"File streamed as application/zip."},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/assets/{id}/claim":{"post":{"operationId":"claimAsset","summary":"Claim (take) an asset","description":"Marks the caller as the labeler working on this asset. Idempotent for self. Returns 409 if another user already holds it (admin may use ?force=true to take over).","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["true","false"],"description":"Admin-only override that takes over a claim held by another user."},"required":false,"description":"Admin-only override that takes over a claim held by another user.","name":"force","in":"query"}],"responses":{"200":{"description":"Asset claimed (now assigned to caller).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden — force=true requires admin role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Asset not found (or soft-deleted).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Asset is already claimed by another user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetClaimConflict"}}}}}},"delete":{"operationId":"releaseAsset","summary":"Release an asset claim","description":"Clears the assignment. Allowed for the current assignee, or for any admin.","tags":["Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Asset released (now unassigned).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden — only the assignee or admin can release.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Asset not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files":{"post":{"operationId":"createFile","summary":"Create file","description":"Creates a new file record and returns a presigned S3 upload URL. Starts in pending status until confirmed via POST /v1/files/{id}/confirm.","tags":["Files"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"idempotency-key","in":"header"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileCreateRequest"}}}},"responses":{"200":{"description":"File created. Upload your file to the presigned upload_url via HTTP PUT.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileCreateResponse"}}}},"400":{"description":"Request body failed validation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Missing or invalid credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Web/labeler users cannot create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Idempotency-Key reused with a different payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"get":{"operationId":"listFiles","summary":"List files","tags":["Files"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["all","unassigned","mine","others","assigned"]},"required":false,"name":"assignment","in":"query"},{"schema":{"type":"string","enum":["labeler_workload"]},"required":false,"name":"view","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":256},"required":false,"name":"assigned_to_user_id","in":"query"}],"responses":{"200":{"description":"Paginated list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileListResponse"}}}},"400":{"description":"Invalid query","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files/{id}/upload/multipart":{"post":{"operationId":"initMultipartUpload_files","summary":"Start multipart upload","tags":["Files Multipart Upload"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Session created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MultipartInitResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Invalid status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files/{id}/upload/multipart/{sessionId}/part/{partNumber}":{"get":{"operationId":"getMultipartPartUrl_files","summary":"Get part upload URL","tags":["Files Multipart Upload"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"},{"schema":{"type":"integer","nullable":true},"required":false,"name":"partNumber","in":"path"}],"responses":{"200":{"description":"Presigned PUT URL for this part.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MultipartPartResponse"}}}},"400":{"description":"Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Invalid session status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files/{id}/upload/multipart/{sessionId}/complete":{"post":{"operationId":"completeMultipartUpload_files","summary":"Complete multipart upload","tags":["Files Multipart Upload"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MultipartCompleteRequest"}}}},"responses":{"200":{"description":"Upload assembled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Invalid session status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files/{id}/upload/multipart/{sessionId}/abort":{"post":{"operationId":"abortMultipartUpload_files","summary":"Abort multipart upload","tags":["Files Multipart Upload"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"}],"responses":{"200":{"description":"Aborted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Invalid session status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files/{id}/confirm":{"post":{"operationId":"confirmFile","summary":"Confirm file upload","tags":["Files"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"File active.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found or upload missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"413":{"description":"Too large","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files/{id}":{"get":{"operationId":"getFile","summary":"Get file details","tags":["Files"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"File details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"operationId":"deleteFile","summary":"Delete file","tags":["Files"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Soft-deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files/{id}/download":{"get":{"operationId":"downloadFile","summary":"Get download URL","tags":["Files"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Presigned download URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileDownloadResponse"}}}},"400":{"description":"Invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/files/{id}/file":{"get":{"operationId":"streamFileFile","summary":"Download file file","tags":["Files"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"File streamed as application/zip."},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/public-keys":{"post":{"operationId":"registerPublicKey","summary":"Register a public key","description":"Stores a public key for the authenticated user. Any key format is accepted (SSH, SPKI PEM, raw PEM). Returns a SHA-256 fingerprint of the key content. Duplicate fingerprints for the same user are rejected with 409.\n\nThe `name` field is used as the device identifier (e.g. hostname) for key lookup via `GET /v1/public-keys?name=`.\n\n### Register an SSH public key with curl\n\n```bash\ncurl -X POST https://console.koshee.io/v1/public-keys \\\n  -H \"X-API-Key: pac_YOUR_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"koshee-protect-01\",\n    \"public_key_pem\": \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... koshee-protect-01\"\n  }'\n```","tags":["Public Keys"],"security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicKeyRegisterRequest"}}}},"responses":{"200":{"description":"Registered.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicKeyResponse"}}}},"400":{"description":"Invalid PEM or algorithm.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"get":{"operationId":"listPublicKeys","summary":"List registered public keys","description":"Returns public keys for the authenticated user. Supports optional filtering:\n\n- `?name=<hostname>` — exact match on the key name (device hostname / client_id)\n- `?include_revoked=true` — include revoked keys in the response\n\n### Lookup by device hostname\n\n```bash\ncurl \"https://console.koshee.io/v1/public-keys?name=koshee-protect-01\" \\\n  -H \"X-API-Key: pac_YOUR_KEY\"\n```","tags":["Public Keys"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"include_revoked","in":"query"},{"schema":{"type":"string"},"required":false,"name":"name","in":"query"}],"responses":{"200":{"description":"Keys.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicKeyListResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/public-keys/{id}":{"delete":{"operationId":"revokePublicKey","summary":"Revoke a public key","tags":["Public Keys"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/public-keys/{id}/verify":{"post":{"operationId":"verifySignature","summary":"Verify a signature against a stored public key","description":"Accepts base64-encoded payload and signature. Returns `{ valid: boolean }` with HTTP 200 whether or not the signature matches. Revoked keys return 410.","tags":["Public Keys"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicKeyVerifyRequest"}}}},"responses":{"200":{"description":"Verification result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicKeyVerifyResponse"}}}},"400":{"description":"Invalid base64 or payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"410":{"description":"Key has been revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/api-keys":{"get":{"operationId":"listApiKeys","summary":"List your API keys","description":"Returns all active (non-revoked) API keys for the authenticated user.","tags":["API Keys"],"security":[{"bearer":[]}],"responses":{"200":{"description":"API keys list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyListResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"operationId":"createApiKey","summary":"Create an API key","description":"Generates a new API key for the authenticated user. The full key is returned only in this response and cannot be retrieved later.","tags":["API Keys"],"security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreateRequest"}}}},"responses":{"201":{"description":"Created. The `key` field is shown only once.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreateResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}}}}},"/v1/api-keys/{id}":{"delete":{"operationId":"revokeApiKey","summary":"Revoke an API key","description":"Revokes an API key owned by the authenticated user. Revoking an already-revoked key is idempotent (returns 204).","tags":["API Keys"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Revoked (or already revoked)."},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Key not found or not owned by you.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/tunnels":{"post":{"operationId":"createTunnel","summary":"Create a Cloudflare tunnel","description":"Creates a Cloudflare tunnel, configures ingress, and creates a wildcard DNS CNAME. Admin only.","tags":["Tunnels"],"security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TunnelCreateRequest"}}}},"responses":{"200":{"description":"Tunnel created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TunnelCreateResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden — admin only","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Tunnel service not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"get":{"operationId":"listTunnels","summary":"List tunnels","description":"Admin sees all tunnels. Other roles see their own.","tags":["Tunnels"],"security":[{"bearer":[]}],"responses":{"200":{"description":"Tunnels.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TunnelListResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/tunnels/{id}/token":{"get":{"operationId":"getTunnelToken","summary":"Get tunnel token","description":"Returns the tunnel token for use in TUNNEL_TOKEN env var. Owner or admin.","tags":["Tunnels"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TunnelTokenResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/tunnels/{id}/reset":{"post":{"operationId":"resetTunnel","summary":"Reset or recreate a tunnel","description":"Clears stale connections. With ?recreate=true, deletes and recreates the tunnel entirely.","tags":["Tunnels"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"recreate","in":"query"}],"responses":{"200":{"description":"Reset result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TunnelResetResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Tunnel service not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/tunnels/{id}":{"delete":{"operationId":"deleteTunnel","summary":"Delete a tunnel","description":"Deletes the Cloudflare tunnel and DNS record. Admin only.","tags":["Tunnels"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden — admin only","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Tunnel service not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/deploy-assets/{name}":{"put":{"operationId":"putDeployAsset","summary":"Upload or replace a deploy asset","description":"Accepts raw binary body. Admin only. Upserts by name.","tags":["Deploy Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":255},"required":true,"name":"name","in":"path"}],"responses":{"200":{"description":"Uploaded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeployAssetResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden — admin only","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"get":{"operationId":"getDeployAsset","summary":"Download a deploy asset","description":"Returns raw binary. Admin or api role.","tags":["Deploy Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":255},"required":true,"name":"name","in":"path"}],"responses":{"200":{"description":"Asset binary."},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"operationId":"deleteDeployAsset","summary":"Delete a deploy asset","description":"Admin only.","tags":["Deploy Assets"],"security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":255},"required":true,"name":"name","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden — admin only","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/deploy-assets":{"get":{"operationId":"listDeployAssets","summary":"List deploy assets","description":"Admin or api role.","tags":["Deploy Assets"],"security":[{"bearer":[]}],"responses":{"200":{"description":"Assets.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeployAssetListResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}