{"openapi":"3.0.0","info":{"title":"Centrali Data Service API","version":"6.8.1","description":"API documentation for the Centrali Data Service - Core data management for records, structures, compute functions, and more.","contact":{"name":"Centrali Support"}},"servers":[{"url":"https://api.centrali.io/data/workspace/{workspaceSlug}/api/v1","description":"Workspace-scoped API","variables":{"workspaceSlug":{"default":"demo","description":"The workspace slug"}}}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token obtained from the IAM service"},"apiKey":{"type":"apiKey","in":"header","name":"X-API-Key","description":"API key for service-to-service communication"}},"schemas":{"Error":{"type":"object","required":["error","message","status","timestamp","path"],"properties":{"error":{"type":"string","example":"VALIDATION_ERROR","description":"Machine-readable error code"},"message":{"type":"string","example":"structureSlug is required","description":"Human-readable error message"},"status":{"type":"integer","example":400,"description":"HTTP status code"},"timestamp":{"type":"string","format":"date-time","example":"2026-03-02T10:00:00.000Z"},"path":{"type":"string","example":"/workspace/my-ws/api/v1/records","description":"Request path"},"requestId":{"type":"string","description":"Optional request ID for tracing"}}},"PaginatedResponse":{"type":"object","properties":{"data":{"type":"array","items":{}},"meta":{"type":"object","properties":{"total":{"type":"integer","example":100},"page":{"type":"integer","example":1},"pageSize":{"type":"integer","example":50}}}}},"Record":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"workspaceSlug":{"type":"string"},"recordSlug":{"type":"string"},"data":{"type":"object","additionalProperties":true},"status":{"type":"string","enum":["active","archived"]},"version":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","format":"uuid"},"lockedBy":{"type":"string","format":"uuid","nullable":true},"lockedAt":{"type":"string","format":"date-time","nullable":true}}},"RecordVersion":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"recordId":{"type":"string","format":"uuid"},"workspaceSlug":{"type":"string"},"recordSlug":{"type":"string"},"data":{"type":"object","additionalProperties":true},"version":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","format":"uuid"}}},"RecordChangeLog":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"recordId":{"type":"string","format":"uuid"},"workspaceSlug":{"type":"string"},"version":{"type":"integer"},"changeType":{"type":"string","enum":["created","updated","deleted","restored","reverted"]},"changes":{"type":"object","additionalProperties":true,"nullable":true},"updatedBy":{"type":"string","format":"uuid"},"timestamp":{"type":"string","format":"date-time"}}},"Structure":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"workspaceSlug":{"type":"string"},"recordSlug":{"type":"string"},"description":{"type":"string"},"properties":{"type":"array","items":{"$ref":"#/components/schemas/Property"}},"defaultSearchField":{"type":"string"},"status":{"type":"string","enum":["active","inactive"]},"schemaDiscoveryMode":{"type":"string","enum":["strict","schemaless","auto-evolving"]},"enableVersioning":{"type":"boolean"},"isDeleted":{"type":"boolean"},"createdBy":{"type":"string","format":"uuid"},"lastUpdatedBy":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"recordRetentionPolicy":{"type":"object","nullable":true},"tags":{"type":"array","items":{"type":"string"},"nullable":true}}},"Property":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string","enum":["string","number","boolean","datetime","array","object","reference"]},"description":{"type":"string"},"required":{"type":"boolean"},"nullable":{"type":"boolean"},"default":{},"enum":{"type":"array","items":{}},"isUnique":{"type":"boolean"},"immutable":{"type":"boolean"},"minLength":{"type":"integer","description":"String only"},"maxLength":{"type":"integer","description":"String only"},"pattern":{"type":"string","description":"String only - regex pattern"},"renderAs":{"type":"string","enum":["textarea","secret","color","code","html","markdown"],"description":"String only - UI rendering hint"},"minimum":{"type":"number","description":"Number only"},"maximum":{"type":"number","description":"Number only"},"exclusiveMinimum":{"type":"boolean","description":"Number only"},"exclusiveMaximum":{"type":"boolean","description":"Number only"},"multipleOf":{"type":"number","description":"Number only"},"autoIncrement":{"type":"object","description":"Number only","properties":{"startAt":{"type":"number"},"incrementBy":{"type":"number"}}},"earliestDate":{"type":"string","description":"Datetime only - ISO 8601"},"latestDate":{"type":"string","description":"Datetime only - ISO 8601"},"items":{"type":"object","description":"Array only","properties":{"type":{"type":"string"}}},"minItems":{"type":"integer","description":"Array only"},"maxItems":{"type":"integer","description":"Array only"},"uniqueItems":{"type":"boolean","description":"Array only"},"properties":{"type":"array","items":{"$ref":"#/components/schemas/Property"},"description":"Object only - nested properties"},"requiredProperties":{"type":"array","items":{"type":"string"},"description":"Object only"},"target":{"type":"string","description":"Reference only - target structure recordSlug"},"relationship":{"type":"string","enum":["many-to-one","one-to-one","many-to-many"],"description":"Reference only"},"onDelete":{"type":"string","enum":["restrict","cascade","set_null"],"description":"Reference only"}}},"ComputeFunction":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string"},"code":{"type":"string"},"workspaceSlug":{"type":"string"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"WebhookSubscription":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"url":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string"}},"secret":{"type":"string"},"active":{"type":"boolean"},"workspaceSlug":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"Draft":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"resourceType":{"type":"string"},"data":{"type":"object","additionalProperties":true},"workspaceSlug":{"type":"string"},"createdBy":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"}}},"SmartQuery":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"query":{"type":"object"},"structureId":{"type":"string","format":"uuid"},"workspaceSlug":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"AiValidationSuggestion":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"workspaceSlug":{"type":"string"},"structureId":{"type":"string","format":"uuid"},"recordId":{"type":"string","format":"uuid"},"recordSlug":{"type":"string"},"field":{"type":"string"},"issueType":{"type":"string","enum":["format","typo","duplicate","semantic"]},"originalValue":{"type":"string","nullable":true},"suggestedValue":{"type":"string","nullable":true},"confidence":{"type":"number","minimum":0,"maximum":1},"status":{"type":"string","enum":["pending","accepted","rejected","auto-applied"]},"batchId":{"type":"string","nullable":true},"metadata":{"type":"object","additionalProperties":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"resolvedAt":{"type":"string","format":"date-time","nullable":true},"resolvedBy":{"type":"string","format":"uuid","nullable":true}}},"SchemaSuggestion":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"workspaceSlug":{"type":"string"},"structureId":{"type":"string","format":"uuid"},"batchId":{"type":"string","nullable":true},"dedupeKey":{"type":"string"},"operation":{"type":"string","enum":["add_field","update_field_type","initial_schema"]},"fieldName":{"type":"string","nullable":true},"suggestedProperty":{"type":"object","description":"PropertyDefinition or array of PropertyDefinitions"},"sampleValues":{"type":"array","items":{},"nullable":true},"sampleRecordIds":{"type":"array","items":{"type":"string"},"nullable":true},"confidence":{"type":"number","minimum":0,"maximum":1},"status":{"type":"string","enum":["pending","accepted","rejected"]},"resolvedAt":{"type":"string","format":"date-time","nullable":true},"resolvedBy":{"type":"string","format":"uuid","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}}}},"tags":[{"name":"Collections","description":"Collection management — primary endpoints (formerly Structures)"},{"name":"Collections - Migrations","description":"Collection migration and upgrade operations — primary endpoints"},{"name":"Collection AI Config","description":"AI validation configuration for collections — primary endpoints"},{"name":"Structures (Deprecated)","description":"Deprecated — use /collections endpoints instead"},{"name":"Structures - Migrations (Deprecated)","description":"Deprecated — use /collections migration endpoints instead"},{"name":"Structure AI Config (Deprecated)","description":"Deprecated — use /collections AI config endpoints instead"}],"security":[{"bearerAuth":[]}],"paths":{"/admin/secrets/rotation/stats":{"get":{"summary":"Get secret rotation statistics","description":"Retrieve statistics about secrets that need key rotation. If workspaceSlug is omitted, returns stats for all workspaces.","tags":["Admin"],"parameters":[{"in":"query","name":"apiKey","required":true,"schema":{"type":"string"},"description":"Admin API key for authentication"},{"in":"query","name":"workspaceSlug","schema":{"type":"string"},"description":"Optional workspace slug to scope stats to a single workspace"}],"responses":{"200":{"description":"Rotation statistics","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object"}}}}}},"400":{"description":"Missing apiKey query parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/admin/secrets/rotation/execute":{"post":{"summary":"Execute secret key rotation","description":"Trigger re-encryption of all secrets from old key versions to the current key version. If workspaceSlug is omitted, rotates all workspaces.","tags":["Admin"],"parameters":[{"in":"query","name":"apiKey","required":true,"schema":{"type":"string"},"description":"Admin API key for authentication"},{"in":"query","name":"workspaceSlug","schema":{"type":"string"},"description":"Optional workspace slug to limit rotation to a single workspace"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"batchSize":{"type":"integer","default":100,"description":"Number of records to process per batch"}}}}}},"responses":{"200":{"description":"Rotation result","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object"}}}}}},"400":{"description":"Missing apiKey query parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/admin/secrets/rotation/structure/{recordSlug}":{"post":{"summary":"Rotate secrets for a specific structure","description":"Re-encrypt secrets for a single structure within a workspace. Requires workspaceSlug query parameter.","tags":["Admin"],"parameters":[{"in":"path","name":"recordSlug","required":true,"schema":{"type":"string"},"description":"The structure slug to rotate secrets for"},{"in":"query","name":"apiKey","required":true,"schema":{"type":"string"},"description":"Admin API key for authentication"},{"in":"query","name":"workspaceSlug","required":true,"schema":{"type":"string"},"description":"The workspace containing the structure"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"batchSize":{"type":"integer","default":100,"description":"Number of records to process per batch"}}}}}},"responses":{"200":{"description":"Structure rotation result","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object"}}}}}},"400":{"description":"Missing required query parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/summary":{"get":{"summary":"Get validation summary statistics","description":"Get aggregated statistics for AI validation suggestions","tags":["AI Validation"],"parameters":[{"in":"query","name":"structureSlug","schema":{"type":"string"},"description":"Filter by structure slug/recordSlug (optional)"}],"responses":{"200":{"description":"Validation summary","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"integer"},"pending":{"type":"integer"},"accepted":{"type":"integer"},"rejected":{"type":"integer"},"autoApplied":{"type":"integer"},"byIssueType":{"type":"object","additionalProperties":{"type":"integer"}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/suggestions/bulk-accept":{"post":{"summary":"Bulk accept suggestions","description":"Accept multiple validation suggestions and apply fixes to records","tags":["AI Validation"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":100}}}}}},"responses":{"200":{"description":"Bulk accept result","content":{"application/json":{"schema":{"type":"object","properties":{"accepted":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"error":{"type":"string"}}}},"message":{"type":"string"}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/suggestions/bulk-reject":{"post":{"summary":"Bulk reject suggestions","description":"Reject multiple validation suggestions","tags":["AI Validation"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":100}}}}}},"responses":{"200":{"description":"Bulk reject result","content":{"application/json":{"schema":{"type":"object","properties":{"rejected":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"error":{"type":"string"}}}},"message":{"type":"string"}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/suggestions":{"post":{"summary":"Create a validation suggestion (internal)","description":"Internal API for AI Service to create validation suggestions","tags":["AI Validation"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["structureId","recordId","recordSlug","field","issueType","confidence"],"properties":{"structureId":{"type":"string","format":"uuid"},"recordId":{"type":"string","format":"uuid"},"recordSlug":{"type":"string"},"field":{"type":"string"},"issueType":{"type":"string","enum":["format","typo","duplicate","semantic"]},"originalValue":{"type":"string","nullable":true},"suggestedValue":{"type":"string","nullable":true},"confidence":{"type":"number","minimum":0,"maximum":1},"status":{"type":"string","enum":["pending","auto-applied"]},"batchId":{"type":"string","format":"uuid","nullable":true},"metadata":{"type":"object"}}}}}},"responses":{"201":{"description":"Suggestion created"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"summary":"List validation suggestions","description":"List AI validation suggestions with filters and pagination","tags":["AI Validation"],"parameters":[{"in":"query","name":"structureSlug","schema":{"type":"string"},"description":"Filter by structure slug/recordSlug"},{"in":"query","name":"recordId","schema":{"type":"string","format":"uuid"},"description":"Filter by record ID"},{"in":"query","name":"status","schema":{"type":"string","enum":["pending","accepted","rejected","auto-applied"]},"description":"Filter by status"},{"in":"query","name":"issueType","schema":{"type":"string","enum":["format","typo","duplicate","semantic"]},"description":"Filter by issue type"},{"in":"query","name":"batchId","schema":{"type":"string","format":"uuid"},"description":"Filter by batch scan ID"},{"in":"query","name":"limit","schema":{"type":"integer","default":50,"maximum":100}},{"in":"query","name":"offset","schema":{"type":"integer","default":0}}],"responses":{"200":{"description":"List of suggestions","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AiValidationSuggestion"}},"meta":{"type":"object","properties":{"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"},"hasMore":{"type":"boolean"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/suggestions/{id}":{"get":{"summary":"Get a validation suggestion","description":"Retrieve a single validation suggestion by ID","tags":["AI Validation"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The suggestion","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiValidationSuggestion"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Suggestion not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/suggestions/{id}/accept":{"post":{"summary":"Accept a suggestion","description":"Accept a validation suggestion and apply the fix to the record","tags":["AI Validation"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Suggestion accepted","content":{"application/json":{"schema":{"type":"object","properties":{"suggestion":{"$ref":"#/components/schemas/AiValidationSuggestion"},"recordUpdated":{"type":"boolean"},"message":{"type":"string"}}}}}},"400":{"description":"Suggestion is not pending","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Suggestion not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/suggestions/{id}/reject":{"post":{"summary":"Reject a suggestion","description":"Reject a validation suggestion","tags":["AI Validation"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Suggestion rejected","content":{"application/json":{"schema":{"type":"object","properties":{"suggestion":{"$ref":"#/components/schemas/AiValidationSuggestion"},"message":{"type":"string"}}}}}},"400":{"description":"Suggestion is not pending","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Suggestion not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/records/{recordId}/suggestions":{"get":{"summary":"Get suggestions for a record","description":"Get all validation suggestions for a specific record","tags":["AI Validation"],"parameters":[{"in":"path","name":"recordId","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"query","name":"status","schema":{"type":"string","enum":["pending","accepted","rejected","auto-applied"]},"description":"Filter by status"}],"responses":{"200":{"description":"List of suggestions for the record","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AiValidationSuggestion"}},"meta":{"type":"object","properties":{"total":{"type":"integer"},"recordId":{"type":"string"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/validation/structures/{structureSlug}/pending-count":{"get":{"summary":"Get pending suggestions count","description":"Get the count of pending validation suggestions for a structure","tags":["AI Validation"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug (recordSlug)"}],"responses":{"200":{"description":"Pending count","content":{"application/json":{"schema":{"type":"object","properties":{"structureSlug":{"type":"string"},"pendingCount":{"type":"integer"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/settings/allowed-domains":{"get":{"summary":"List allowed domains","description":"Retrieve all allowed domains configured for the workspace","tags":["Allowed Domains"],"responses":{"200":{"description":"List of allowed domains","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"domain":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string"}}}},"meta":{"type":"object","properties":{"total":{"type":"integer"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Add an allowed domain","description":"Add a new domain to the workspace allowlist","tags":["Allowed Domains"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"Domain name (e.g. 'api.example.com')"}}}}}},"responses":{"201":{"description":"Domain added successfully","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"domain":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Domain already exists in the allowlist","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/settings/allowed-domains/{id}":{"delete":{"summary":"Remove an allowed domain","description":"Delete a domain from the workspace allowlist","tags":["Allowed Domains"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The domain ID to delete"}],"responses":{"204":{"description":"Domain removed successfully"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Domain not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureSlug}/anomaly-config":{"get":{"summary":"Get anomaly detection config","description":"Get the anomaly detection configuration for a structure","tags":["Anomaly Detection"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"Structure slug"}],"responses":{"200":{"description":"Anomaly detection config"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update anomaly detection config","description":"Update the anomaly detection configuration for a structure","tags":["Anomaly Detection"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"Structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"frequency":{"type":"string","enum":["daily","weekly"]},"analysisTypes":{"type":"array","items":{"type":"string","enum":["time_series","statistical","pattern"]}},"sensitivityLevel":{"type":"string","enum":["low","medium","high"]},"lookbackPeriod":{"type":"integer","minimum":1,"maximum":365},"minRecordsForAnalysis":{"type":"integer","minimum":1},"notifySeverities":{"type":"array","items":{"type":"string","enum":["info","warning","critical"]}}}}}}},"responses":{"200":{"description":"Updated config"},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureSlug}/insights":{"get":{"summary":"Get insights for a structure","description":"List anomaly insights for a specific structure","tags":["Anomaly Detection"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"query","name":"status","schema":{"type":"string","enum":["active","acknowledged","dismissed"]}},{"in":"query","name":"severity","schema":{"type":"string","enum":["info","warning","critical"]}},{"in":"query","name":"insightType","schema":{"type":"string"}},{"in":"query","name":"limit","schema":{"type":"integer","default":50}},{"in":"query","name":"offset","schema":{"type":"integer","default":0}}],"responses":{"200":{"description":"List of insights"}}}},"/structures/{structureSlug}/insights/active-count":{"get":{"summary":"Get active insights count","description":"Get the count of active insights for a structure (for badges)","tags":["Anomaly Detection"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Active count","content":{"application/json":{"schema":{"type":"object","properties":{"count":{"type":"integer"}}}}}}}}},"/ai/insights/active-count":{"get":{"summary":"Get workspace-wide active insights count","description":"Get the count of active insights across all structures (for nav badge)","tags":["Anomaly Detection"],"responses":{"200":{"description":"Active count","content":{"application/json":{"schema":{"type":"object","properties":{"count":{"type":"integer"}}}}}}}}},"/ai/insights":{"get":{"summary":"List all insights","description":"List all anomaly insights in the workspace","tags":["Anomaly Detection"],"parameters":[{"in":"query","name":"structureSlug","schema":{"type":"string"}},{"in":"query","name":"status","schema":{"type":"string","enum":["active","acknowledged","dismissed"]}},{"in":"query","name":"severity","schema":{"type":"string","enum":["info","warning","critical"]}},{"in":"query","name":"insightType","schema":{"type":"string"}},{"in":"query","name":"limit","schema":{"type":"integer","default":50}},{"in":"query","name":"offset","schema":{"type":"integer","default":0}}],"responses":{"200":{"description":"List of insights"}}}},"/ai/insights/summary":{"get":{"summary":"Get insights summary","description":"Get summary statistics for insights","tags":["Anomaly Detection"],"parameters":[{"in":"query","name":"structureSlug","schema":{"type":"string"}}],"responses":{"200":{"description":"Summary statistics"}}}},"/ai/insights/bulk-acknowledge":{"post":{"summary":"Bulk acknowledge insights","description":"Acknowledge multiple insights at once","tags":["Anomaly Detection"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string"},"maxItems":100}}}}}},"responses":{"200":{"description":"Bulk operation result"}}}},"/ai/insights/bulk-dismiss":{"post":{"summary":"Bulk dismiss insights","description":"Dismiss multiple insights at once","tags":["Anomaly Detection"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string"},"maxItems":100}}}}}},"responses":{"200":{"description":"Bulk operation result"}}}},"/ai/insights/{id}":{"get":{"summary":"Get a single insight","description":"Get details of a specific insight","tags":["Anomaly Detection"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Insight details"},"404":{"description":"Insight not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/insights/{id}/acknowledge":{"post":{"summary":"Acknowledge an insight","description":"Mark an insight as acknowledged","tags":["Anomaly Detection"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Insight acknowledged"},"400":{"description":"Insight not active","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Insight not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/insights/{id}/dismiss":{"post":{"summary":"Dismiss an insight","description":"Mark an insight as dismissed","tags":["Anomaly Detection"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Insight dismissed"},"400":{"description":"Insight not active","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Insight not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/anomalies/analyze":{"post":{"summary":"Trigger anomaly analysis","description":"Manually trigger anomaly analysis for a structure","tags":["Anomaly Detection"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["structureSlug"],"properties":{"structureSlug":{"type":"string"}}}}}},"responses":{"200":{"description":"Analysis triggered"},"400":{"description":"Invalid input or not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/backups":{"get":{"summary":"List backups","description":"Retrieve all backups for the workspace","tags":["Backups"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}},{"in":"query","name":"status","schema":{"type":"string","enum":["pending","in_progress","completed","failed"]},"description":"Filter by backup status"}],"responses":{"200":{"description":"List of backups"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create a backup","description":"Create a new backup of workspace data","tags":["Backups"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["full","incremental"],"default":"full"},"includeRecords":{"type":"boolean","default":true},"includeFiles":{"type":"boolean","default":true}}}}}},"responses":{"202":{"description":"Backup started","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"backupId":{"type":"string","format":"uuid"},"status":{"type":"string"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/backups/{backupId}":{"get":{"summary":"Get backup details","description":"Retrieve details of a specific backup","tags":["Backups"],"parameters":[{"in":"path","name":"backupId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Backup details","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["pending","in_progress","completed","failed"]},"created_at":{"type":"string","format":"date-time"},"completed_at":{"type":"string","format":"date-time"},"size_bytes":{"type":"integer"},"download_url":{"type":"string","format":"uri"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Backup not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/backups/{backupId}/retry":{"post":{"summary":"Retry a failed backup","description":"Retry a backup that previously failed","tags":["Backups"],"parameters":[{"in":"path","name":"backupId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"202":{"description":"Backup retry started"},"400":{"description":"Backup cannot be retried (not in failed state)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Backup not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{structureSlug}/ai-config":{"get":{"summary":"Get AI validation config for a collection","description":"Retrieve the AI-powered data validation configuration for a collection. Returns default values if not configured.","tags":["Collection AI Config"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The collection slug"}],"responses":{"200":{"description":"AI config for the collection","content":{"application/json":{"schema":{"type":"object","properties":{"structureId":{"type":"string","format":"uuid"},"validationEnabled":{"type":"boolean","description":"Whether AI validation is enabled"},"validationMode":{"type":"string","enum":["advisory","auto-correct"],"description":"Advisory shows suggestions, auto-correct applies fixes automatically"},"validationTypes":{"type":"array","items":{"type":"string","enum":["format","typo","duplicate","semantic"]},"description":"Types of validation to perform"},"autoCorrectThreshold":{"type":"number","minimum":0,"maximum":1,"nullable":true,"description":"Confidence threshold for auto-correct (0.0-1.0)"},"config":{"type":"object","description":"Additional configuration options"},"configured":{"type":"boolean","description":"Whether a config has been explicitly set"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Create or update AI validation config","description":"Create or update the AI-powered data validation configuration for a collection","tags":["Collection AI Config"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The collection slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"validationEnabled":{"type":"boolean","description":"Enable or disable AI validation"},"validationMode":{"type":"string","enum":["advisory","auto-correct"],"description":"Advisory shows suggestions, auto-correct applies fixes automatically"},"validationTypes":{"type":"array","items":{"type":"string","enum":["format","typo","duplicate","semantic"]},"description":"Types of validation to perform"},"autoCorrectThreshold":{"type":"number","minimum":0,"maximum":1,"nullable":true,"description":"Required when validationMode is auto-correct"},"config":{"type":"object","description":"Additional configuration options"}}},"example":{"validationEnabled":true,"validationMode":"advisory","validationTypes":["format","typo","duplicate"],"autoCorrectThreshold":null,"config":{}}}}},"responses":{"200":{"description":"AI config updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StructureAiConfig"}}}},"400":{"description":"Invalid request body","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete AI validation config","description":"Delete the AI validation configuration for a collection, effectively disabling validation","tags":["Collection AI Config"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The collection slug"}],"responses":{"204":{"description":"Config deleted successfully"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{structureSlug}/ai-config/enabled":{"get":{"summary":"Check if AI validation is enabled","description":"Quick check to see if AI validation is enabled for a collection","tags":["Collection AI Config"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The collection slug"}],"responses":{"200":{"description":"Validation enabled status","content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/bulk":{"delete":{"summary":"Bulk delete collections","description":"Delete multiple collections by their IDs","tags":["Collections"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Collections deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Bulk create collections","description":"Create multiple collections in a single operation","tags":["Collections"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Structure"},"maxItems":100},"options":{"type":"object","properties":{"dryRun":{"type":"boolean","description":"Validate without committing"},"continueOnError":{"type":"boolean","description":"Continue processing on failure"}}}}}}}},"responses":{"201":{"description":"Collections created successfully"},"207":{"description":"Partial success (some items failed)"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}":{"get":{"summary":"Get collection by slug","description":"Retrieve a collection by its slug","tags":["Collections"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"},"description":"The collection slug"}],"responses":{"200":{"description":"The collection","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Structure"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections":{"get":{"summary":"List collections","description":"Retrieve all collections in the workspace","tags":["Collections"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of collections","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create a collection","description":"Create a new collection (schema) for storing records","tags":["Collections"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","slug"],"properties":{"name":{"type":"string","description":"Display name for the collection"},"slug":{"type":"string","description":"URL-friendly identifier"},"description":{"type":"string"},"properties":{"type":"array","items":{"$ref":"#/components/schemas/Property"}}}}}}},"responses":{"201":{"description":"Collection created","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Structure"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Collection with this slug already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/publish/{draftId}":{"post":{"summary":"Publish a collection from draft","description":"Publish a collection that was saved as a draft","tags":["Collections"],"parameters":[{"in":"path","name":"draftId","required":true,"schema":{"type":"string"},"description":"The draft ID (short ID from draft system)"}],"responses":{"200":{"description":"Collection published"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Draft not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/draft":{"get":{"summary":"Get resource draft for a collection","description":"Retrieve the current user's draft for an existing collection, including drift detection","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The collection ID"}],"responses":{"200":{"description":"The resource draft with drift status","content":{"application/json":{"schema":{"type":"object","properties":{"draft":{"type":"object","nullable":true},"drifted":{"type":"boolean"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Create or update a resource draft for a collection","description":"Save a versioned draft for an existing collection. Preserves baseline version and snapshot from first save.","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The collection ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"The draft data to save"}}}},"responses":{"200":{"description":"Draft saved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a resource draft for a collection","description":"Discard the current user's draft for an existing collection","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The collection ID"}],"responses":{"204":{"description":"Draft deleted successfully"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/deploy":{"post":{"summary":"Deploy a resource draft to live","description":"Applies the current user's draft to the live collection via the standard update flow,\ncreates version history, and deletes the draft. Includes drift detection if the live\ncollection was modified after the draft was started.\n","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The collection ID"}],"responses":{"200":{"description":"Draft deployed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"resource":{"$ref":"#/components/schemas/Structure"},"versionNumber":{"type":"integer"},"historyEntryId":{"type":"string","format":"uuid"},"drifted":{"type":"boolean"},"driftDiff":{"type":"array","nullable":true,"items":{"type":"object","properties":{"field":{"type":"string"},"from":{"type":"object"},"to":{"type":"object"}}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No draft to deploy or collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/validate":{"post":{"summary":"Validate a collection","description":"Validate a collection definition without creating it","tags":["Collections"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"properties":{"type":"array","items":{"$ref":"#/components/schemas/Property"}}}}}}},"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"valid":{"type":"boolean"},"errors":{"type":"array","items":{"type":"string"}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/upgrade/{jobId}/progress":{"get":{"summary":"Get upgrade/migration progress","description":"Get real-time progress of an in-progress upgrade job","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"Collection ID or slug"},{"in":"path","name":"jobId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Progress information"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Job not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}":{"get":{"summary":"Get a collection","description":"Retrieve a collection by ID","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The collection","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Structure"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update a collection","description":"Update an existing collection","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"properties":{"type":"array","items":{"$ref":"#/components/schemas/Property"}}}}}}},"responses":{"200":{"description":"Collection updated"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a collection","description":"Soft delete a collection (can be restored)","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Collection deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/history":{"get":{"summary":"Get collection history","description":"Retrieve the full change history of a collection","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Collection history"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/analyze-update":{"post":{"summary":"Analyze collection update before committing","description":"Quick analysis of proposed changes to show migration requirements in commit modal","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["properties"],"properties":{"properties":{"type":"array","items":{"$ref":"#/components/schemas/Property"}}}}}}},"responses":{"200":{"description":"Analysis results","content":{"application/json":{"schema":{"type":"object","properties":{"needsMigration":{"type":"boolean"},"canSkip":{"type":"boolean"},"recordCount":{"type":"integer"},"classification":{"type":"object"},"suggestedFixes":{"type":"array"},"estimatedDuration":{"type":"string","enum":["instant","seconds","minutes","long"]}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/preview-fixes":{"post":{"summary":"Preview migration fix effects","description":"Preview the effect of migration fixes on sample records before committing.\nReturns before/after snapshots for a small number of matching records per fix,\nplus extrapolated match counts.\n","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["fixes","properties"],"properties":{"fixes":{"type":"array","items":{"type":"object"}},"properties":{"type":"array","items":{"type":"object"}}}}}}},"responses":{"200":{"description":"Fix preview results","content":{"application/json":{"schema":{"type":"object","properties":{"previews":{"type":"array","items":{"type":"object","properties":{"fixIndex":{"type":"integer"},"matchCount":{"type":"integer"},"totalRecords":{"type":"integer"},"samples":{"type":"array"}}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/upgrade":{"post":{"summary":"Atomic collection upgrade with migration","description":"Update collection and execute migration atomically.\n- If no migration needed: completes synchronously\n- If migration needed: locks collection and returns job ID for progress tracking\n","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"properties":{"type":"array","items":{"$ref":"#/components/schemas/Property"}},"name":{"type":"string"},"description":{"type":"string"},"migrationPlan":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","manual"]},"fixes":{"type":"array"}}}}}}}},"responses":{"200":{"description":"Upgrade result","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["completed","in_progress","failed"]},"structure":{"$ref":"#/components/schemas/Structure"},"jobId":{"type":"string"},"progressUrl":{"type":"string"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Migration already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/force-unlock":{"post":{"summary":"Force unlock a stuck collection","description":"Admin endpoint to force unlock a collection that is stuck in a locked state\ndue to a failed migration or worker crash. Use with caution.\n","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Collection unlocked","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"previousState":{"type":"object"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/restore":{"post":{"summary":"Restore a deleted collection","description":"Restore a soft-deleted collection","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Collection restored"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/{id}/properties/delete":{"post":{"summary":"Bulk delete properties","description":"Delete multiple properties from a collection","tags":["Collections"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"propertyIds":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Properties deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}/impact":{"post":{"summary":"Analyze migration impact","description":"Analyze the impact of proposed collection changes on existing records","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"changes":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["add","remove","modify"]},"property":{"type":"string"}}}}}}}}},"responses":{"200":{"description":"Impact analysis results"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}/integrity":{"get":{"summary":"Check data integrity","description":"Analyze data integrity for a collection's records","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Integrity analysis results"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}/integrity/status":{"get":{"summary":"Get integrity check status","description":"Get the status of the most recent integrity check for a collection. Returns progress if running, or cached results if completed.","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Integrity check status","content":{"application/json":{"schema":{"type":"object","properties":{"hasCheck":{"type":"boolean"},"jobId":{"type":"string"},"progress":{"type":"object"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}/integrity/cancel":{"delete":{"summary":"Cancel integrity check","description":"Cancel a running or stuck integrity check for a collection. Use this to clear stuck checks that show \"running\" status but have stopped progressing.","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Integrity check cancelled successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"cancelled":{"type":"boolean"},"previousProgress":{"type":"object"}}}}}},"400":{"description":"Cannot cancel (no active check or already completed/failed)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}/execute-migration":{"post":{"summary":"Execute a migration","description":"Execute a collection migration on existing records","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"planId":{"type":"string","description":"Migration plan ID to execute"}}}}}},"responses":{"200":{"description":"Migration executed"},"400":{"description":"Migration failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection or plan not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}/simulate-migration":{"post":{"summary":"Simulate a migration","description":"Simulate a migration without making changes","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Simulation results"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}/migrations":{"get":{"summary":"Get migration history","description":"Retrieve the migration history for a collection","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Migration history"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/collections/slug/{collectionSlug}/migrations/{migrationId}/rollback":{"post":{"summary":"Rollback a migration","description":"Rollback a previously executed migration","tags":["Collections - Migrations"],"parameters":[{"in":"path","name":"collectionSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"migrationId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Migration rolled back"},"400":{"description":"Rollback failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Migration not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/functions/bulk":{"delete":{"summary":"Bulk delete functions","description":"Delete multiple compute functions by their IDs","tags":["Compute Functions"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Functions deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Bulk create compute functions","description":"Create multiple compute functions in a single operation","tags":["Compute Functions"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ComputeFunction"},"maxItems":100},"options":{"type":"object","properties":{"dryRun":{"type":"boolean","description":"Validate without committing"},"continueOnError":{"type":"boolean","description":"Continue processing on failure"}}}}}}}},"responses":{"201":{"description":"Functions created successfully"},"207":{"description":"Partial success (some items failed)"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/functions":{"get":{"summary":"List compute functions","description":"Retrieve all compute functions in the workspace","tags":["Compute Functions"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of compute functions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create a compute function","description":"Create a new serverless compute function","tags":["Compute Functions"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","code"],"properties":{"name":{"type":"string","description":"Display name for the function"},"description":{"type":"string"},"code":{"type":"string","description":"JavaScript code to execute"},"timeoutMs":{"type":"integer","description":"Execution timeout in milliseconds (default 30000, min 1000, max 300000)"}}}}}},"responses":{"201":{"description":"Function created","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/ComputeFunction"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Function with this name already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/functions/test":{"post":{"summary":"Test execute a function","description":"Execute a function with test input without saving","tags":["Compute Functions"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","description":"Function code to test"},"params":{"type":"object","description":"Parameters passed as executionParams"},"timeoutMs":{"type":"integer","description":"Execution timeout in milliseconds"}}}}}},"responses":{"200":{"description":"Test execution result","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"output":{"type":"object"},"duration_ms":{"type":"integer"},"logs":{"type":"array","items":{"type":"string"}}}}}}},"400":{"description":"Execution error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/functions/{id}":{"get":{"summary":"Get a compute function","description":"Retrieve a compute function by ID","tags":["Compute Functions"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The compute function","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/ComputeFunction"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Function not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update a compute function","description":"Update an existing compute function","tags":["Compute Functions"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"code":{"type":"string"},"timeoutMs":{"type":"integer","description":"Execution timeout in milliseconds (min 1000, max 300000)"}}}}}},"responses":{"200":{"description":"Function updated"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Function not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a compute function","description":"Delete a compute function","tags":["Compute Functions"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Function deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Function not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/functions/{draftId}/publish":{"post":{"summary":"Publish a function from draft","description":"Publish a function that was saved as a draft","tags":["Compute Functions"],"parameters":[{"in":"path","name":"draftId","required":true,"schema":{"type":"string"},"description":"The draft ID (short ID from draft system)"}],"responses":{"200":{"description":"Function published"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Draft not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/functions/{id}/draft":{"get":{"summary":"Get resource draft for a compute function","description":"Retrieve the current user's draft for an existing compute function, including drift detection","tags":["Compute Functions"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The function ID"}],"responses":{"200":{"description":"The resource draft with drift status","content":{"application/json":{"schema":{"type":"object","properties":{"draft":{"type":"object","nullable":true},"drifted":{"type":"boolean"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Create or update a resource draft for a compute function","description":"Save a versioned draft for an existing compute function. Preserves baseline version and snapshot from first save.","tags":["Compute Functions"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The function ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"The draft data to save"}}}},"responses":{"200":{"description":"Draft saved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Function not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a resource draft for a compute function","description":"Discard the current user's draft for an existing compute function","tags":["Compute Functions"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The function ID"}],"responses":{"204":{"description":"Draft deleted successfully"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/functions/{id}/deploy":{"post":{"summary":"Deploy a resource draft to the live compute function","description":"Apply the current user's draft to the live function, creating a new version. Includes drift detection and diff.","tags":["Compute Functions"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The function ID"}],"responses":{"200":{"description":"Draft deployed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"resource":{"$ref":"#/components/schemas/ComputeFunction"},"versionNumber":{"type":"integer"},"historyEntryId":{"type":"string","format":"uuid"},"drifted":{"type":"boolean"},"driftDiff":{"type":"array","nullable":true,"items":{"type":"object","properties":{"field":{"type":"string"},"from":{"type":"object"},"to":{"type":"object"}}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No draft to deploy or function not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/dashboard/recent-activity":{"get":{"summary":"Get recent activity","description":"Retrieve the authenticated user's recent activity within the workspace","tags":["Dashboard"],"responses":{"200":{"description":"Recent activity entries","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/dashboard/metrics":{"get":{"summary":"Get dashboard metrics","description":"Retrieve aggregate workspace metrics including record counts, compute function activity, smart query usage, and trend comparisons","tags":["Dashboard"],"responses":{"200":{"description":"Dashboard metrics with trend indicators","content":{"application/json":{"schema":{"type":"object","properties":{"totalRecords":{"type":"integer"},"newRecords":{"type":"integer"},"newRecordsTrend":{"type":"object","nullable":true,"properties":{"direction":{"type":"string","enum":["up","down"]},"percentage":{"type":"integer"}}},"activeComputeFunctions":{"type":"integer"},"activeComputeTrend":{"type":"object","nullable":true,"properties":{"direction":{"type":"string","enum":["up","down"]},"percentage":{"type":"integer"}}},"smartQueriesExecuted":{"type":"integer"},"smartQueriesTrend":{"type":"object","nullable":true,"properties":{"direction":{"type":"string","enum":["up","down"]},"percentage":{"type":"integer"}}},"failedComputeRuns24h":{"type":"integer"},"failedComputeTrend":{"type":"object","nullable":true,"properties":{"direction":{"type":"string","enum":["up","down"]},"percentage":{"type":"integer"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/dashboard/trends":{"get":{"summary":"Get dashboard trends","description":"Retrieve time-series trend data for a specific metric over a given period and interval","tags":["Dashboard"],"parameters":[{"in":"query","name":"metric","required":true,"schema":{"type":"string","enum":["records_added","compute_runs","queries_executed","runs_failed"]},"description":"The metric to retrieve trend data for"},{"in":"query","name":"period","schema":{"type":"string","default":"30d"},"description":"Time period (e.g. '30d', '7d', '24h')"},{"in":"query","name":"interval","schema":{"type":"string","default":"day","enum":["day","hour"]},"description":"Aggregation interval"}],"responses":{"200":{"description":"Trend data points","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object"}}}}}}},"400":{"description":"Unsupported metric","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/dlq":{"get":{"summary":"Query DLQ jobs","description":"Retrieve a filtered and paginated list of dead letter queue jobs for the workspace","tags":["Dead Letter Queue"],"parameters":[{"in":"query","name":"status","schema":{"type":"string"},"description":"Filter by job status"},{"in":"query","name":"service_name","schema":{"type":"string"},"description":"Filter by originating service name"},{"in":"query","name":"topic","schema":{"type":"string"},"description":"Filter by message topic"},{"in":"query","name":"limit","schema":{"type":"integer","default":50},"description":"Maximum number of results to return"},{"in":"query","name":"offset","schema":{"type":"integer","default":0},"description":"Number of results to skip"},{"in":"query","name":"sort_by","schema":{"type":"string","default":"created_at"},"description":"Field to sort by"},{"in":"query","name":"sort_order","schema":{"type":"string","default":"desc","enum":["asc","desc"]},"description":"Sort direction"}],"responses":{"200":{"description":"Paginated list of DLQ jobs","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/dlq/stats":{"get":{"summary":"Get DLQ statistics","description":"Retrieve aggregate statistics about dead letter queue jobs for the workspace","tags":["Dead Letter Queue"],"responses":{"200":{"description":"DLQ statistics","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/dlq/{jobId}":{"get":{"summary":"Get a DLQ job by ID","description":"Retrieve details of a specific dead letter queue job","tags":["Dead Letter Queue"],"parameters":[{"in":"path","name":"jobId","required":true,"schema":{"type":"string"},"description":"The DLQ job ID"}],"responses":{"200":{"description":"DLQ job details","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"DLQ job not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a DLQ job","description":"Permanently remove a dead letter queue job","tags":["Dead Letter Queue"],"parameters":[{"in":"path","name":"jobId","required":true,"schema":{"type":"string"},"description":"The DLQ job ID to delete"}],"responses":{"200":{"description":"Job deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"jobId":{"type":"string"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"DLQ job not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/dlq/{jobId}/retry":{"post":{"summary":"Retry a DLQ job","description":"Attempt to re-process a failed dead letter queue job","tags":["Dead Letter Queue"],"parameters":[{"in":"path","name":"jobId","required":true,"schema":{"type":"string"},"description":"The DLQ job ID to retry"}],"responses":{"200":{"description":"Retry initiated","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"jobId":{"type":"string"}}}}}},"400":{"description":"Job cannot be retried in its current state","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"DLQ job not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/drafts/{type}/{id}":{"get":{"summary":"Get a draft","description":"Retrieve a draft by type and ID","tags":["Drafts"],"parameters":[{"in":"path","name":"type","required":true,"schema":{"type":"string","enum":["structure","function","trigger","smart-query"]},"description":"The draft type"},{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"The draft ID"}],"responses":{"200":{"description":"The draft","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Draft"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Draft not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update a draft","description":"Update an existing draft","tags":["Drafts"],"parameters":[{"in":"path","name":"type","required":true,"schema":{"type":"string","enum":["structure","function","trigger","smart-query"]},"description":"The draft type"},{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"The draft ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","description":"Updated draft data"}}}}}},"responses":{"200":{"description":"Draft updated"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Draft not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a draft","description":"Delete a draft","tags":["Drafts"],"parameters":[{"in":"path","name":"type","required":true,"schema":{"type":"string","enum":["structure","function","trigger","smart-query"]},"description":"The draft type"},{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"The draft ID"}],"responses":{"200":{"description":"Draft deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Draft not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/drafts/{type}":{"post":{"summary":"Save a draft","description":"Save a new draft for structures, functions, triggers, or queries","tags":["Drafts"],"parameters":[{"in":"path","name":"type","required":true,"schema":{"type":"string","enum":["structure","function","trigger","smart-query"]},"description":"The draft type"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","description":"Draft data specific to the type"}}}}}},"responses":{"201":{"description":"Draft saved","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"id":{"type":"string","description":"The draft ID"}}}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"summary":"List drafts","description":"List all drafts of a specific type","tags":["Drafts"],"parameters":[{"in":"path","name":"type","required":true,"schema":{"type":"string","enum":["structure","function","trigger","smart-query"]},"description":"The draft type"},{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of drafts"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/endpoints/{path}":{"post":{"summary":"Invoke a function endpoint","description":"Execute a function via its endpoint trigger and return the function's output inline.","tags":["Endpoints"],"parameters":[{"in":"path","name":"path","required":true,"schema":{"type":"string"},"description":"The endpoint path configured on the trigger"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","description":"Payload to pass to the function"}}}},"responses":{"200":{"description":"Function executed successfully — response body is the function's return value"},"401":{"description":"Authentication required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden — valid credentials but insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Endpoint not found or disabled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"405":{"description":"HTTP method not allowed for this endpoint","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Function execution error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No compute worker available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"504":{"description":"Function execution timed out","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/event-lineage":{"get":{"summary":"Resolve the event lineage for a correlation id","description":"Return the ordered chain of Tier 1 events that share a correlation id\n(CEN-1298). The chain unions inbound HTTP-trigger arrivals, record\nchanges, and outbound webhook deliveries, oldest event first.\nEncrypted inbound payloads are decrypted on read.\n","tags":["Event Lineage"],"parameters":[{"in":"query","name":"correlationId","required":true,"schema":{"type":"string"},"description":"The correlation id shared across the event chain."}],"responses":{"200":{"description":"The lineage chain, oldest event first.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"eventType":{"type":"string"},"sourceTable":{"type":"string","enum":["inbound_events","record_change_log","webhook_deliveries"]},"sourceId":{"type":"string"},"correlationId":{"type":"string"},"timestamp":{"type":"string","format":"date-time"},"payload":{"nullable":true}}}}}}}}},"400":{"description":"Missing or empty correlationId query parameter.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Failed to resolve event lineage.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/event-log/query":{"post":{"summary":"Query the workspace Event Log (canonical)","description":"Run a canonical `QueryDefinition` body against the `event-log`\nresource — the Tier 1 event projection (CEN-1298) unioning inbound\nHTTP-trigger arrivals, record changes, and outbound webhook\ndeliveries. Same body shape as `POST /records/query` and\n`POST /function-runs/query`.\n\nRows are metadata only: `eventType`, `sourceTable`, `sourceId`,\n`correlationId`, `timestamp`, `clockTier`. The stored payload is not\nreturned by the list surface — fetch a single event via\n`GET /event-log/{sourceTable}/{sourceId}` for the decrypted payload.\n\nQueryable fields: `eventType`, `sourceTable`, `sourceId`,\n`correlationId`, `timestamp`, `clockTier`. Callers pass an explicit\n`sort` (e.g. `timestamp` descending) for reverse-chronological order.\n","tags":["Event Log"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["resource"],"properties":{"resource":{"type":"string","enum":["event-log"]},"where":{"type":"object"},"sort":{"type":"array"},"page":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"}}},"select":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string"}}}}}}}}},"responses":{"200":{"description":"Canonical query result envelope"},"400":{"description":"Invalid query shape or wrong resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Unsupported clause / unreachable field"}}}},"/event-log/{sourceTable}/{sourceId}":{"get":{"summary":"Retrieve a single Event Log event","description":"Resolve a single projected event by its `(sourceTable, sourceId)`\nnatural key. The stored payload is decrypted on read — an inbound\narrival whose AES-256-GCM envelope cannot be decrypted is still\nreturned, with `payload` set to null.\n\nThe detail is enriched (CEN-1299) with `inbound` — the inbound-event\nmetadata (signature result, dispatch status, credential-stripped\nrequest headers, replay source), present only for `inbound_events`\nrows and `null` otherwise — and `functionRuns`, the Tier 2 nesting of\nevery function run sharing the event's `correlationId`, oldest-first.\n`functionRuns` is `null` (omitted) when the caller lacks\n`function-triggers:retrieve`, the resource that governs function runs.\n","tags":["Event Log"],"parameters":[{"in":"path","name":"sourceTable","required":true,"schema":{"type":"string","enum":["inbound_events","record_change_log","webhook_deliveries"]}},{"in":"path","name":"sourceId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The projected event with its decrypted payload.","content":{"application/json":{"schema":{"type":"object","properties":{"eventType":{"type":"string"},"sourceTable":{"type":"string","enum":["inbound_events","record_change_log","webhook_deliveries"]},"sourceId":{"type":"string"},"correlationId":{"type":"string","nullable":true},"timestamp":{"type":"string","format":"date-time"},"clockTier":{"type":"integer"},"payload":{"nullable":true},"tenantId":{"type":"string","nullable":true,"description":"Per-row tenancy axis (CEN-1340). Sourced from `webhook_subscriptions.tenantId` for outbound rows; null on inbound and record-change rows."},"inbound":{"nullable":true,"description":"Inbound-event metadata; null for non-inbound events.","type":"object","properties":{"signatureResult":{"type":"string","enum":["verified","rejected","unsigned"]},"dispatchStatus":{"type":"string","enum":["received","queued","dropped_dispatch","dispatched"]},"headers":{"type":"object","additionalProperties":{"type":"string"}},"replayedFrom":{"type":"string","nullable":true}}},"functionRuns":{"type":"array","nullable":true,"description":"Tier 2 — function runs sharing the event's correlationId. null when the caller lacks function-triggers:retrieve.","items":{"type":"object","properties":{"id":{"type":"string"},"functionId":{"type":"string"},"triggerId":{"type":"string","nullable":true},"triggerType":{"type":"string","nullable":true},"status":{"type":"string"},"startedAt":{"type":"string","format":"date-time"},"endedAt":{"type":"string","format":"date-time","nullable":true},"inboundEventId":{"type":"string","nullable":true}}}}}}}}},"400":{"description":"Invalid sourceTable or missing sourceId.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Event not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Failed to resolve event detail.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/http-trigger/{path}":{"post":{"summary":"Execute an HTTP trigger","description":"Execute a function via its HTTP trigger endpoint","tags":["HTTP Triggers"],"parameters":[{"in":"path","name":"path","required":true,"schema":{"type":"string"},"description":"The trigger path (configured when creating the trigger)"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","description":"Payload to pass to the function"}}}},"responses":{"200":{"description":"Function executed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","description":"Function output"}}}}}},"400":{"description":"Execution error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trigger not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Function execution failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import-export/export":{"get":{"summary":"Export workspace data","description":"Export structures, functions, or other resources from the workspace","tags":["Import/Export"],"parameters":[{"in":"query","name":"type","required":true,"schema":{"type":"string","enum":["structure","function","trigger","smart-query"]},"description":"Type of resource to export"},{"in":"query","name":"ids","schema":{"type":"string"},"description":"Comma-separated list of IDs to export (exports all if not specified)"}],"responses":{"200":{"description":"Exported data","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import-export/import":{"post":{"summary":"Import workspace data","description":"Import structures, functions, or other resources into the workspace","tags":["Import/Export"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["structure","function","trigger","smart-query"]},"data":{"type":"object","description":"Resource data to import"},"overwrite":{"type":"boolean","default":false,"description":"Whether to overwrite existing resources"}}}}}},"responses":{"200":{"description":"Import completed"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict with existing resources","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import-export/bulk/export-structure-bundle":{"post":{"summary":"Export structure bundle","description":"Export a complete structure bundle including properties and related data","tags":["Import/Export - Bulk"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"structureIds":{"type":"array","items":{"type":"string","format":"uuid"}},"includeRecords":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"Structure bundle exported"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import-export/bulk/export-function-bundle":{"post":{"summary":"Export function bundle","description":"Export a complete function bundle including triggers and related data","tags":["Import/Export - Bulk"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"functionIds":{"type":"array","items":{"type":"string","format":"uuid"}},"includeTriggers":{"type":"boolean","default":true}}}}}},"responses":{"200":{"description":"Function bundle exported"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import-export/bulk/detect-structure-conflicts":{"post":{"summary":"Detect structure import conflicts","description":"Check for conflicts before importing a structure bundle","tags":["Import/Export - Bulk"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"bundle":{"type":"object","description":"Structure bundle to check"}}}}}},"responses":{"200":{"description":"Conflict analysis result","content":{"application/json":{"schema":{"type":"object","properties":{"hasConflicts":{"type":"boolean"},"conflicts":{"type":"array","items":{"type":"object"}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import-export/bulk/detect-function-conflicts":{"post":{"summary":"Detect function import conflicts","description":"Check for conflicts before importing a function bundle","tags":["Import/Export - Bulk"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"bundle":{"type":"object","description":"Function bundle to check"}}}}}},"responses":{"200":{"description":"Conflict analysis result"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import-export/bulk/import-structure-bundle":{"post":{"summary":"Import structure bundle","description":"Import a complete structure bundle","tags":["Import/Export - Bulk"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"bundle":{"type":"object","description":"Structure bundle to import"},"conflictResolution":{"type":"string","enum":["skip","overwrite","rename"],"default":"skip"}}}}}},"responses":{"200":{"description":"Import completed"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import-export/bulk/import-function-bundle":{"post":{"summary":"Import function bundle","description":"Import a complete function bundle","tags":["Import/Export - Bulk"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"bundle":{"type":"object","description":"Function bundle to import"},"conflictResolution":{"type":"string","enum":["skip","overwrite","rename"],"default":"skip"}}}}}},"responses":{"200":{"description":"Import completed"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/inbound-events/{id}/replay":{"post":{"summary":"Replay a buffered inbound webhook event","description":"Re-dispatch a previously buffered inbound webhook event (CEN-1297).\nThe stored payload is decrypted and the function re-queued through its\noriginal trigger. A new inbound_events row is written with\n`replayedFrom` pointing at the source event.\n","tags":["Inbound Events"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"The inbound event id (ievt_-prefixed)"}],"responses":{"202":{"description":"Replay queued","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"inboundEventId":{"type":"string"},"correlationId":{"type":"string"},"replayedFrom":{"type":"string"},"dispatchStatus":{"type":"string"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Inbound event, trigger, or function not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Replay failed (queue, decrypt, or database error)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/logs":{"post":{"summary":"Query logs","description":"Retrieve logs from the logging backend using filter criteria and a time range","tags":["Logs"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"filter":{"type":"object","description":"Filter criteria for the log query"},"startTimestamp":{"type":"string","format":"date-time","description":"Start of the time range"},"endTimestamp":{"type":"string","format":"date-time","description":"End of the time range"}}}}}},"responses":{"200":{"description":"Log query results","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/logs/sources":{"get":{"summary":"List log sources","description":"Retrieve the list of allowed log sources that can be used as filter criteria","tags":["Logs"],"responses":{"200":{"description":"List of available log sources","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/metadata/version":{"get":{"summary":"Get service version","description":"Retrieve the current version information of the Data service","tags":["Service"],"responses":{"200":{"description":"Service version information","content":{"application/json":{"schema":{"type":"object","properties":{"version":{"type":"string"},"name":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/metadata/health":{"get":{"summary":"Get service health","description":"Check the health status of the Data service and its dependencies (database, NATS, blob storage, Redis)","tags":["Service"],"responses":{"200":{"description":"Service is healthy","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["ok","error"]},"timestamp":{"type":"string","format":"date-time"},"dependencies":{"type":"object","properties":{"database":{"type":"string"},"nats":{"type":"string"},"blobStorage":{"type":"string"},"redis":{"type":"string"}}},"pool":{"type":"object","properties":{"active":{"type":"integer"},"idle":{"type":"integer"},"waiting":{"type":"integer"},"total":{"type":"integer"}}}}}}}},"503":{"description":"Service is unhealthy","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["error"]},"dependencies":{"type":"object"}}}}}}}}},"/record-files/slug/{structureSlug}/files/upload":{"post":{"summary":"Upload a file for records","description":"Upload a file to be attached to records in a structure","tags":["Record Files"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","description":"The file to upload"},"recordId":{"type":"string","format":"uuid","description":"Optional record ID to attach the file to"},"propertySlug":{"type":"string","description":"Optional property slug for file attachment"}}}}}},"responses":{"200":{"description":"File uploaded successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"fileId":{"type":"string","format":"uuid"},"url":{"type":"string","format":"uri"},"filename":{"type":"string"},"size":{"type":"integer"},"mimeType":{"type":"string"}}}}}}}},"400":{"description":"Invalid file or validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (10 uploads per minute)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}":{"get":{"summary":"List records","description":"Retrieve a paginated list of records for a structure","tags":["Records"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"query","name":"page","schema":{"type":"integer","default":1},"description":"Page number"},{"in":"query","name":"limit","schema":{"type":"integer","default":20},"description":"Number of records per page"},{"in":"query","name":"sort","schema":{"type":"string"},"description":"Sort field (prefix with - for descending)"},{"in":"query","name":"filter","schema":{"type":"string"},"description":"JSON filter object"}],"responses":{"200":{"description":"List of records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create a record","description":"Create a new record in a structure","tags":["Records"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"header","name":"Idempotency-Key","schema":{"type":"string"},"description":"Optional idempotency key for safe retries"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","additionalProperties":true,"description":"Record data matching the structure schema"}}}}}},"responses":{"201":{"description":"Record created","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Record"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Duplicate record (unique constraint violation)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/archives":{"get":{"summary":"List archived records","description":"Retrieve soft-deleted records for a structure","tags":["Records"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of archived records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}":{"get":{"summary":"Get a record","description":"Retrieve a single record by ID","tags":["Records"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The record ID"}],"responses":{"200":{"description":"The record","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Record"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update a record","description":"Update an existing record","tags":["Records"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The record ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","additionalProperties":true,"description":"Record data to update"}}}}}},"responses":{"200":{"description":"Record updated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Record"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a record","description":"Soft delete a record (can be restored)","tags":["Records"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The record ID"}],"responses":{"200":{"description":"Record deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/query":{"post":{"summary":"Query records (canonical)","description":"Run a canonical `QueryDefinition` body against the records resource.\nPhase 1 of the Query Foundation (CEN-1179) — accepts the canonical\noperator vocabulary and returns the canonical `{ data, meta }`\nenvelope. `text` and `include` clauses are reserved and rejected\nwith `422 unsupported_clause` until later phases.\n\nThe body's `resource` field carries the collection slug; there is\nno slug in the URL. Saved queries (Phase 4) use the same shape, so\nthe ad-hoc and saved paths stay aligned.\n","tags":["Records"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["resource"],"properties":{"resource":{"type":"string","description":"The collection slug to query (e.g. \"orders\")."},"where":{"type":"object"},"sort":{"type":"array","items":{"type":"object"}},"page":{"type":"object"},"select":{"type":"object"}}}}}},"responses":{"200":{"description":"Canonical query result envelope","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array"},"meta":{"type":"object"}}}}}},"400":{"description":"Invalid query shape (missing/empty resource, etc.)"},"422":{"description":"Unsupported clause / operator / unreadable field"}}}},"/records/query/test":{"post":{"summary":"Plan a canonical query without executing it (authoring dry-run)","description":"Validates and plans a `QueryDefinition` against the records resource\nunder `surface: 'authoring'` semantics — references to unreadable\nfields surface as `422 unreadable_field` errors instead of silently\nfiltering to empty results. Use from saved-query builders, MCP\ntooling, or the console visual builder to validate a definition\nbefore saving or executing it.\n\nSame body shape as `POST /records/query`. Returns\n`{ ok: true, plan: { executor, resource, mode, hasUnreadableField } }`\non success.\n","tags":["Records"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["resource"],"properties":{"resource":{"type":"string"},"where":{"type":"object"},"sort":{"type":"array","items":{"type":"object"}},"page":{"type":"object"},"select":{"type":"object"},"text":{"type":"object"},"include":{"type":"array","items":{"type":"object"}}}}}}},"responses":{"200":{"description":"Plan summary (no rows fetched)"},"400":{"description":"Invalid query shape"},"422":{"description":"Unsupported clause / unreadable field / unsupported operator"}}}},"/records/slug/{structureSlug}/upsert":{"post":{"summary":"Upsert a record","description":"Find a record by match fields and update it, or create a new one if not found. Uses advisory locking for atomicity.","tags":["Records"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"header","name":"Idempotency-Key","schema":{"type":"string"},"description":"Optional idempotency key for safe retries"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["match","data"],"properties":{"match":{"type":"object","additionalProperties":true,"description":"Key-value pairs to match an existing record"},"data":{"type":"object","additionalProperties":true,"description":"Record data to create or update with"}}}}}},"responses":{"200":{"description":"Record updated (match found)"},"201":{"description":"Record created (no match found)"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/bulk":{"delete":{"summary":"Bulk delete records","description":"Delete multiple records in a single request","tags":["Records - Bulk Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Records deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Bulk create records","description":"Create multiple records in a single request","tags":["Records - Bulk Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"records":{"type":"array","items":{"type":"object","properties":{"data":{"type":"object","additionalProperties":true}}}}}}}}},"responses":{"201":{"description":"Records created"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"summary":"Bulk update records","description":"Update multiple records in a single request","tags":["Records - Bulk Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"data":{"type":"object","additionalProperties":true}}}}}}}}},"responses":{"200":{"description":"Records updated"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/restore":{"post":{"summary":"Restore a deleted record","description":"Restore a soft-deleted record","tags":["Records"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The record ID"}],"responses":{"200":{"description":"Record restored"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/bulk/restore":{"post":{"summary":"Bulk restore records","description":"Restore multiple deleted records","tags":["Records - Bulk Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Records restored"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/bulk/get":{"post":{"summary":"Bulk get records","description":"Retrieve multiple records by IDs","tags":["Records - Bulk Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Records retrieved"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/bulk/import":{"post":{"summary":"Import records from CSV/JSON","description":"Bulk import records from a file","tags":["Records - Bulk Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"}}}}}},"responses":{"200":{"description":"Import completed"},"400":{"description":"Invalid file format","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/batch":{"post":{"summary":"Batch create records","description":"Create multiple records with per-record event triggers. Each record fires an individual record_created event. Use this when you need per-record trigger processing.","tags":["Records - Batch Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"array","items":{"type":"object","additionalProperties":true}}}}},"responses":{"201":{"description":"Records created with per-record events"},"400":{"description":"Validation error"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden"}}},"patch":{"summary":"Batch update records","description":"Update multiple records with individual changes and per-record event triggers. Each record fires an individual record_updated event.","tags":["Records - Batch Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"updates":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"changes":{"type":"object","additionalProperties":true}}}},"options":{"type":"object","properties":{"stopOnError":{"type":"boolean"},"returnRecords":{"type":"boolean"}}}}}}}},"responses":{"200":{"description":"Records updated with per-record events"},"400":{"description":"Validation error"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden"}}},"delete":{"summary":"Batch delete records","description":"Delete multiple records with per-record event triggers. Each record fires an individual record_deleted event.","tags":["Records - Batch Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}},"options":{"type":"object","properties":{"hardDelete":{"type":"boolean"},"stopOnError":{"type":"boolean"}}}}}}}},"responses":{"200":{"description":"Records deleted with per-record events"},"400":{"description":"Validation error"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden"}}}},"/records/slug/{structureSlug}/{id}/fields/{field}/increment":{"post":{"summary":"Increment a numeric field","description":"Atomically increment a numeric field value","tags":["Records - Field Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"path","name":"field","required":true,"schema":{"type":"string"},"description":"Field slug to increment"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"number","default":1}}}}}},"responses":{"200":{"description":"Field incremented"},"400":{"description":"Field is not numeric","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/fields/{field}/decrement":{"post":{"summary":"Decrement a numeric field","description":"Atomically decrement a numeric field value","tags":["Records - Field Operations"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"path","name":"field","required":true,"schema":{"type":"string"},"description":"Field slug to decrement"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"number","default":1}}}}}},"responses":{"200":{"description":"Field decremented"},"400":{"description":"Field is not numeric","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/aggregate":{"post":{"summary":"Aggregate records","description":"Perform aggregation operations on records (count, sum, avg, etc.)","tags":["Records - Analytics"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"structureSlug":{"type":"string"},"operations":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["count","sum","avg","min","max"]},"field":{"type":"string"}}}},"groupBy":{"type":"array","items":{"type":"string"}},"filter":{"type":"object"}}}}}},"responses":{"200":{"description":"Aggregation results"},"400":{"description":"Invalid aggregation query","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/versions":{"get":{"summary":"List record versions","description":"Get all versions of a record","tags":["Records - Versioning"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of versions"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/versions/{versionId}":{"get":{"summary":"Get a specific version","description":"Retrieve a specific version of a record","tags":["Records - Versioning"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"path","name":"versionId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The record version"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Version not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/versions/{versionId}/revert":{"put":{"summary":"Revert to a version","description":"Revert record to a previous version","tags":["Records - Versioning"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"path","name":"versionId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Record reverted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Version not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/history":{"get":{"summary":"Get full history","description":"Get complete history of a record including all changes","tags":["Records - Versioning"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Full record history"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/changelogs":{"get":{"summary":"Get changelogs","description":"Get audit log of changes to a record","tags":["Records - Versioning"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Record changelogs"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/secrets/reveal":{"post":{"summary":"Reveal secret values","description":"Reveal plaintext values of secret fields for a record. Requires secrets:reveal permission.","tags":["Records - Secrets"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The record ID"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string"},"description":"Optional list of specific secret fields to reveal. If omitted, all secret fields are revealed."}}}}}},"responses":{"200":{"description":"Secret values revealed","content":{"application/json":{"schema":{"type":"object","properties":{"revealed":{"type":"object","additionalProperties":{"type":"string"},"description":"Object with field names as keys and plaintext secret values"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - requires secrets:reveal permission","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/records/slug/{structureSlug}/{id}/secrets/compare":{"post":{"summary":"Compare secret value","description":"Compare a candidate value against a secret field. Returns only a boolean result, never reveals the secret. Requires secrets:compare permission.","tags":["Records - Secrets"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"The structure slug"},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The record ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["field","value"],"properties":{"field":{"type":"string","description":"The secret field name to compare against"},"value":{"type":"string","description":"The candidate value to compare"}}}}}},"responses":{"200":{"description":"Comparison result","content":{"application/json":{"schema":{"type":"object","properties":{"matches":{"type":"boolean","description":"True if the candidate value matches the stored secret"}}}}}},"400":{"description":"Field is not a secret field or missing required parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - requires secrets:compare permission","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/runs":{"get":{"summary":"List function runs","description":"Retrieve all function execution runs in the workspace","tags":["Function Runs"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}},{"in":"query","name":"status","schema":{"type":"string","enum":["pending","running","completed","failed","timeout"]},"description":"Filter by run status"}],"responses":{"200":{"description":"List of function runs"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Bulk delete runs","description":"Delete multiple function runs by IDs","tags":["Function Runs"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Runs deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/function-runs/query":{"post":{"summary":"Query function runs (canonical)","description":"Run a canonical `QueryDefinition` body against the function-runs\nresource. Phase 3 of the Query Foundation (CEN-1216) — same body shape\nas `POST /records/query`.\n","tags":["Function Runs"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["resource"],"properties":{"resource":{"type":"string","enum":["function-runs"]},"where":{"type":"object"},"sort":{"type":"array"},"page":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"}}},"select":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string"}}}}}}}}},"responses":{"200":{"description":"Canonical query result envelope"},"400":{"description":"Invalid query shape"},"422":{"description":"Unsupported clause / unreadable field"}}}},"/function-runs/query/test":{"post":{"summary":"Plan a canonical function-runs query without executing (authoring dry-run)","description":"Validates and plans a `QueryDefinition` against the function-runs\nresource. `surface: 'authoring'` — references to unreadable fields\nsurface as 422 errors instead of silently filtering to empty.\n","tags":["Function Runs"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["resource"],"properties":{"resource":{"type":"string","enum":["function-runs"]}}}}}},"responses":{"200":{"description":"Plan returned"},"422":{"description":"Invalid or unsupported query"}}}},"/runs/trigger/{triggerId}":{"get":{"summary":"Get runs by trigger","description":"Retrieve all runs for a specific trigger","tags":["Function Runs"],"parameters":[{"in":"path","name":"triggerId","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of function runs"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trigger not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/runs/function/{functionId}":{"get":{"summary":"Get runs by function","description":"Retrieve all runs for a specific function","tags":["Function Runs"],"parameters":[{"in":"path","name":"functionId","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of function runs"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Function not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/runs/{id}":{"get":{"summary":"Get a function run","description":"Retrieve details of a specific function run","tags":["Function Runs"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The function run details","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"function_id":{"type":"string","format":"uuid"},"trigger_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["pending","running","completed","failed","timeout"]},"started_at":{"type":"string","format":"date-time"},"completed_at":{"type":"string","format":"date-time"},"duration_ms":{"type":"integer"},"input":{"type":"object"},"output":{"type":"object"},"error":{"type":"string"},"logs":{"type":"array","items":{"type":"string"}}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Run not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a function run","description":"Delete a specific function run","tags":["Function Runs"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Run deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Run not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/runs/{id}/rerun-history":{"get":{"summary":"Get rerun history","description":"Get the history of reruns for a specific run","tags":["Function Runs"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Rerun history"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Run not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/runs/{id}/archive":{"get":{"summary":"Download archived run payload","description":"Download the archived runData payload from blob storage for a stripped run","tags":["Function Runs"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Archived payload JSON file","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Run not archived or invalid ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Archived payload expired or no longer available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/runs/{id}/rerun":{"post":{"summary":"Rerun a function","description":"Re-execute a function with the same input","tags":["Function Runs"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Rerun started","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"run_id":{"type":"string","format":"uuid","description":"ID of the new run"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Run not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/runs/{id}/decrypt-context":{"post":{"summary":"Decrypt run context","description":"Decrypt and return the encrypted run parameters. Requires manage permission on compute-functions.","tags":["Function Runs"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Decrypted run parameters","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - requires manage permission","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Run not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{id}/saved-filters":{"get":{"summary":"List saved filters","description":"Retrieve all saved filters for a structure, scoped to the authenticated user","tags":["Saved Filters"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The structure ID"}],"responses":{"200":{"description":"List of saved filters","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"type":"array","items":{"type":"object"}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create a saved filter","description":"Create a new saved filter preset for a structure","tags":["Saved Filters"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The structure ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","filterDefinition"],"properties":{"name":{"type":"string","description":"Name for the saved filter","maxLength":255},"filterDefinition":{"type":"object","description":"The filter configuration object"}}}}}},"responses":{"201":{"description":"Saved filter created","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"type":"object"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A saved filter with this name already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{id}/saved-filters/{filterId}":{"put":{"summary":"Update a saved filter","description":"Update the name or filter definition of an existing saved filter. Only the filter owner can update it.","tags":["Saved Filters"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The structure ID"},{"in":"path","name":"filterId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The saved filter ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Updated filter name","maxLength":255},"filterDefinition":{"type":"object","description":"Updated filter configuration"}}}}}},"responses":{"200":{"description":"Saved filter updated","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"type":"object"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - not the filter owner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Saved filter not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A saved filter with this name already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a saved filter","description":"Permanently remove a saved filter. Only the filter owner can delete it.","tags":["Saved Filters"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The structure ID"},{"in":"path","name":"filterId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The saved filter ID"}],"responses":{"200":{"description":"Saved filter deleted","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - not the filter owner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Saved filter not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureSlug}/schema-discovery/settings":{"get":{"summary":"Get schema discovery settings","description":"Get the schema discovery mode and configuration for a structure","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"Structure slug"}],"responses":{"200":{"description":"Schema discovery settings"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update schema discovery settings","description":"Update the schema discovery mode and configuration for a structure","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"Structure slug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"schemaDiscoveryMode":{"type":"string","enum":["strict","schemaless","auto-evolving"]},"schemaDiscoveryConfig":{"type":"object"}}}}}},"responses":{"200":{"description":"Settings updated"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-discovery/summary":{"get":{"summary":"Get schema discovery summary","description":"Get aggregated statistics for schema discovery suggestions","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"},"description":"Structure ID"}],"responses":{"200":{"description":"Schema discovery summary","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"integer"},"pending":{"type":"integer"},"accepted":{"type":"integer"},"rejected":{"type":"integer"},"byOperation":{"type":"object","additionalProperties":{"type":"integer"}},"bufferCount":{"type":"integer"},"hasPendingBatch":{"type":"boolean"},"pendingBatchId":{"type":"string","nullable":true}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-discovery/trigger":{"post":{"summary":"Trigger schema inference","description":"Manually trigger schema inference for a structure","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Inference triggered","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"batchId":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Inference already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureSlug}/schema-discovery/scan":{"post":{"summary":"Scan existing records for schema discovery","description":"Samples existing records from the database to discover unknown fields. Works independently of buffer.","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"},"description":"Structure slug"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sampleSize":{"type":"integer","default":50,"maximum":200,"description":"Number of records to sample"}}}}}},"responses":{"200":{"description":"Scan completed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"recordsScanned":{"type":"integer"},"unknownFieldsFound":{"type":"array","items":{"type":"string"}},"batchId":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Scan already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-suggestions/bulk-accept":{"post":{"summary":"Bulk accept schema suggestions","description":"Accept multiple schema suggestions and apply changes","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":100}}}}}},"responses":{"200":{"description":"Bulk accept result","content":{"application/json":{"schema":{"type":"object","properties":{"accepted":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"error":{"type":"string"}}}},"message":{"type":"string"}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-suggestions/bulk-reject":{"post":{"summary":"Bulk reject schema suggestions","description":"Reject multiple schema suggestions","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":100}}}}}},"responses":{"200":{"description":"Bulk reject result","content":{"application/json":{"schema":{"type":"object","properties":{"rejected":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"error":{"type":"string"}}}},"message":{"type":"string"}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-suggestions/pending-count":{"get":{"summary":"Get pending suggestions count","description":"Get the count of pending schema suggestions for a structure","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Pending count","content":{"application/json":{"schema":{"type":"object","properties":{"structureId":{"type":"string","format":"uuid"},"pendingCount":{"type":"integer"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-suggestions":{"get":{"summary":"List schema suggestions","description":"List schema discovery suggestions with filters and pagination","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"query","name":"batchId","schema":{"type":"string","format":"uuid"},"description":"Filter by batch ID"},{"in":"query","name":"operation","schema":{"type":"string","enum":["add_field","update_field_type","initial_schema"]},"description":"Filter by operation type"},{"in":"query","name":"status","schema":{"type":"string","enum":["pending","accepted","rejected"]},"description":"Filter by status"},{"in":"query","name":"limit","schema":{"type":"integer","default":50,"maximum":100}},{"in":"query","name":"offset","schema":{"type":"integer","default":0}}],"responses":{"200":{"description":"List of suggestions","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SchemaSuggestion"}},"meta":{"type":"object","properties":{"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"},"hasMore":{"type":"boolean"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-suggestions/{id}":{"get":{"summary":"Get a schema suggestion","description":"Retrieve a single schema suggestion by ID","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The suggestion","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SchemaSuggestion"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Suggestion not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-suggestions/{id}/accept":{"post":{"summary":"Accept a schema suggestion","description":"Accept a schema suggestion and apply the change to the structure","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Suggestion accepted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}}}}}},"400":{"description":"Suggestion is not pending or cannot be applied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Suggestion not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{structureId}/schema-suggestions/{id}/reject":{"post":{"summary":"Reject a schema suggestion","description":"Reject a schema suggestion","tags":["Schema Discovery"],"parameters":[{"in":"path","name":"structureId","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Suggestion rejected","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}}}}}},"400":{"description":"Suggestion is not pending","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Suggestion not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/service/version":{"get":{"summary":"Get service version","description":"Retrieve the current version information of the Data service (workspace-scoped)","tags":["Service"],"responses":{"200":{"description":"Service version information","content":{"application/json":{"schema":{"type":"object","properties":{"version":{"type":"string"},"name":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/service/health":{"get":{"summary":"Get service health","description":"Check the health status of the Data service and its dependencies (workspace-scoped)","tags":["Service"],"responses":{"200":{"description":"Service is healthy","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["ok","error"]},"timestamp":{"type":"string","format":"date-time"},"dependencies":{"type":"object"}}}}}},"503":{"description":"Service is unhealthy","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/service/datatypes":{"get":{"summary":"List supported data types","description":"Retrieve the list of all supported field data types for structures","tags":["Service"],"responses":{"200":{"description":"List of supported data types","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/service/filterable-fields/{type}":{"get":{"summary":"Get filterable fields","description":"Retrieve the list of fields that can be used for filtering, based on the resource type","tags":["Service"],"parameters":[{"in":"path","name":"type","required":true,"schema":{"type":"string"},"description":"The resource type (e.g. 'record', 'structure')"},{"in":"query","name":"rs","schema":{"type":"string"},"description":"Required when type is 'record' — the record structure slug"}],"responses":{"200":{"description":"List of filterable fields","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}},"400":{"description":"Missing required fields","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/service/jobs/{type}/{id}":{"get":{"summary":"Get job status","description":"Retrieve the status and details of a background job by type and ID","tags":["Service"],"parameters":[{"in":"path","name":"type","required":true,"schema":{"type":"string","enum":["simulate","integrity","execute","backup","impact","compute"]},"description":"The job type"},{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"The job ID"}],"responses":{"200":{"description":"Job details","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Invalid job type or missing job ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Job not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/bulk":{"delete":{"summary":"Bulk delete smart queries","description":"Delete multiple smart queries by their IDs (workspace-level)","tags":["Smart Queries"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Smart queries deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Bulk create smart queries","description":"Create multiple smart queries in a single operation","tags":["Smart Queries"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/SmartQuery"},"maxItems":100},"options":{"type":"object","properties":{"dryRun":{"type":"boolean","description":"Validate without committing"},"continueOnError":{"type":"boolean","description":"Continue processing on failure"}}}}}}}},"responses":{"201":{"description":"Smart queries created successfully"},"207":{"description":"Partial success (some items failed)"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/slug/{structureSlug}/{id}":{"get":{"summary":"Get a smart query","description":"Retrieve a smart query by ID for a specific structure","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The smart query","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/SmartQuery"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Query not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update a smart query","description":"Update an existing smart query","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"query":{"type":"object"}}}}}},"responses":{"200":{"description":"Smart query updated"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Query not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a smart query","description":"Delete a smart query","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Smart query deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Query not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/slug/{structureSlug}/{id}/history":{"get":{"summary":"Get smart query history","description":"Retrieve version history for a smart query","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":50}}],"responses":{"200":{"description":"Smart query history"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Query not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/slug/{structureSlug}":{"post":{"summary":"Create a smart query","description":"Create a new saved query for a structure","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","query"],"properties":{"name":{"type":"string","description":"Display name for the query"},"slug":{"type":"string","description":"URL-friendly identifier"},"query":{"type":"object","description":"Query definition (filters, sorting, etc.)"}}}}}},"responses":{"201":{"description":"Smart query created"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Bulk delete smart queries","description":"Delete multiple smart queries by IDs","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Smart queries deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"summary":"List smart queries for a structure","description":"Get all smart queries for a specific structure","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of smart queries"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/slug/{structureSlug}/name/{name}":{"get":{"summary":"Get a smart query by name","description":"Retrieve a smart query by its name","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The smart query"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Query not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/slug/{structureSlug}/execute/{id}":{"post":{"summary":"Execute a smart query with variables","description":"Execute a saved query with optional variable substitution","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"variables":{"type":"object","additionalProperties":{"type":"string"},"description":"Variables to substitute in the query (e.g., { userId: abc123 })","example":{"userId":"user_123","startDate":"2024-01-01"}}}}}}},"responses":{"200":{"description":"Query results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedResponse"}}}},"400":{"description":"Missing required variables","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"MISSING_VARIABLE"},"message":{"type":"string"},"requiredVariables":{"type":"array","items":{"type":"string"}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Query not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"summary":"Execute a smart query (deprecated)","description":"Execute a saved query and return results. DEPRECATED - Use POST with variables instead.","deprecated":true,"tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Query results"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Query not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/slug/{structureSlug}/{draftId}/publish":{"post":{"summary":"Publish a smart query from draft","description":"Publish a smart query that was saved as a draft","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}},{"in":"path","name":"draftId","required":true,"schema":{"type":"string"},"description":"The draft ID (short ID from draft system)"}],"responses":{"200":{"description":"Smart query published"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Draft not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/slug/{structureSlug}/test":{"post":{"summary":"Test a smart query","description":"Test a query definition without saving it. Supports variable substitution using {{variableName}} syntax.","tags":["Smart Queries"],"parameters":[{"in":"path","name":"structureSlug","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"queryDefinition":{"type":"object","description":"Query definition to test. Use {{variableName}} syntax for dynamic values.","example":{"where":{"userId":{"$eq":"{{currentUserId}}"}},"limit":10}},"variables":{"type":"object","additionalProperties":{"type":"string"},"description":"Variables to substitute in the query","example":{"currentUserId":"user_123"}}}}}}},"responses":{"200":{"description":"Test results","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"type":"object","properties":{"error":{"type":"string","nullable":true},"data":{"type":"array"},"meta":{"type":"object","properties":{"variablesUsed":{"type":"array","items":{"type":"string"}}}}}}}}}}},"400":{"description":"Invalid query or missing variables","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries":{"get":{"summary":"List all smart queries","description":"Get all smart queries in the workspace","tags":["Smart Queries"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of smart queries"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/smart-queries/{id}":{"get":{"summary":"Get a smart query by ID","description":"Retrieve a smart query by its ID (workspace-wide)","tags":["Smart Queries"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The smart query"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Query not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{id}/deploy":{"post":{"summary":"Deploy a resource draft to live","description":"Applies the current user's draft to the live structure via the standard update flow,\ncreates version history, and deletes the draft. Includes drift detection if the live\nstructure was modified after the draft was started. **Deprecated**: Use the /collections equivalent instead.\n","deprecated":true,"tags":["Structures (Deprecated)"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"The structure ID"}],"responses":{"200":{"description":"Draft deployed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"resource":{"$ref":"#/components/schemas/Structure"},"versionNumber":{"type":"integer"},"historyEntryId":{"type":"string","format":"uuid"},"drifted":{"type":"boolean"},"driftDiff":{"type":"array","nullable":true,"items":{"type":"object","properties":{"field":{"type":"string"},"from":{"type":"object"},"to":{"type":"object"}}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No draft to deploy or structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{id}/preview-fixes":{"post":{"summary":"Preview migration fix effects","description":"Preview the effect of migration fixes on sample records before committing.\nReturns before/after snapshots for a small number of matching records per fix,\nplus extrapolated match counts. **Deprecated**: Use the /collections equivalent instead.\n","deprecated":true,"tags":["Structures - Migrations (Deprecated)"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["fixes","properties"],"properties":{"fixes":{"type":"array","items":{"type":"object"}},"properties":{"type":"array","items":{"type":"object"}}}}}}},"responses":{"200":{"description":"Fix preview results","content":{"application/json":{"schema":{"type":"object","properties":{"previews":{"type":"array","items":{"type":"object","properties":{"fixIndex":{"type":"integer"},"matchCount":{"type":"integer"},"totalRecords":{"type":"integer"},"samples":{"type":"array"}}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{id}/upgrade":{"post":{"summary":"Atomic structure upgrade with migration","description":"Update structure and execute migration atomically.\n- If no migration needed: completes synchronously\n- If migration needed: locks structure and returns job ID for progress tracking\n**Deprecated**: Use the /collections equivalent instead.\n","deprecated":true,"tags":["Structures - Migrations (Deprecated)"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"properties":{"type":"array","items":{"$ref":"#/components/schemas/Property"}},"name":{"type":"string"},"description":{"type":"string"},"migrationPlan":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","manual"]},"fixes":{"type":"array"}}}}}}}},"responses":{"200":{"description":"Upgrade result","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["completed","in_progress","failed"]},"structure":{"$ref":"#/components/schemas/Structure"},"jobId":{"type":"string"},"progressUrl":{"type":"string"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Migration already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/structures/{id}/force-unlock":{"post":{"summary":"Force unlock a stuck structure","description":"Admin endpoint to force unlock a structure that is stuck in a locked state\ndue to a failed migration or worker crash. Use with caution. **Deprecated**: Use the /collections equivalent instead.\n","deprecated":true,"tags":["Structures - Migrations (Deprecated)"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Structure unlocked","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"previousState":{"type":"object"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Structure not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/triggers/health":{"get":{"summary":"List trigger health metrics","description":"Get aggregated health metrics for all triggers in the workspace","tags":["Trigger Health"],"parameters":[{"in":"query","name":"period","schema":{"type":"integer","enum":[7,30],"default":30}},{"in":"query","name":"sort","schema":{"type":"string","enum":["failureRate","totalRuns","avgDurationMs","lastRunAt"],"default":"failureRate"}},{"in":"query","name":"order","schema":{"type":"string","enum":["asc","desc"],"default":"desc"}},{"in":"query","name":"attentionOnly","schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"Trigger health list"}}}},"/triggers/{triggerId}/health/trend":{"get":{"summary":"Get trigger health trend","description":"Get daily health breakdown for a specific trigger","tags":["Trigger Health"],"parameters":[{"in":"path","name":"triggerId","required":true,"schema":{"type":"string"}},{"in":"query","name":"period","schema":{"type":"integer","enum":[7,30],"default":30}}],"responses":{"200":{"description":"Trigger health trend"},"404":{"description":"Trigger not found"}}}},"/triggers/bulk":{"delete":{"summary":"Bulk delete triggers","description":"Delete multiple function triggers by their IDs","tags":["Function Triggers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Triggers deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Bulk create function triggers","description":"Create multiple function triggers in a single operation","tags":["Function Triggers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/FunctionTrigger"},"maxItems":100},"options":{"type":"object","properties":{"dryRun":{"type":"boolean","description":"Validate without committing"},"continueOnError":{"type":"boolean","description":"Continue processing on failure"}}}}}}}},"responses":{"201":{"description":"Triggers created successfully"},"207":{"description":"Partial success (some items failed)"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/triggers":{"get":{"summary":"List function triggers","description":"Retrieve all function triggers in the workspace","tags":["Function Triggers"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}},{"in":"query","name":"functionId","schema":{"type":"string","format":"uuid"},"description":"Filter by function ID"}],"responses":{"200":{"description":"List of function triggers"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create a function trigger","description":"Create a new trigger that executes a compute function","tags":["Function Triggers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","functionId","type"],"properties":{"name":{"type":"string"},"functionId":{"type":"string","format":"uuid","description":"The compute function to execute"},"type":{"type":"string","enum":["record.created","record.updated","record.deleted","schedule","http"],"description":"Trigger type"},"structureSlug":{"type":"string","description":"Structure to watch (for record triggers)"},"schedule":{"type":"string","description":"Cron expression (for schedule triggers)"},"config":{"type":"object","description":"Additional trigger configuration"}}}}}},"responses":{"201":{"description":"Trigger created"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/triggers/analyze":{"post":{"summary":"Analyze trigger-function combination for self-loops","description":"Check if a trigger-function combination would create a recursive loop","tags":["Function Triggers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["functionId","eventType","recordSlug"],"properties":{"functionId":{"type":"string","format":"uuid"},"eventType":{"type":"string","enum":["record_created","record_updated","record_deleted"]},"recordSlug":{"type":"string"}}}}}},"responses":{"200":{"description":"Analysis result","content":{"application/json":{"schema":{"type":"object","properties":{"hasConflict":{"type":"boolean"},"conflicts":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string"},"collection":{"type":"string"}}}}}}}}},"400":{"description":"Validation error"},"404":{"description":"Function not found"}}}},"/triggers/{id}":{"get":{"summary":"Get a function trigger","description":"Retrieve a function trigger by ID","tags":["Function Triggers"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The function trigger"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trigger not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update a function trigger","description":"Update an existing function trigger","tags":["Function Triggers"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"enabled":{"type":"boolean"},"config":{"type":"object"}}}}}},"responses":{"200":{"description":"Trigger updated"},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trigger not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a function trigger","description":"Delete a function trigger","tags":["Function Triggers"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Trigger deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trigger not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/triggers/{id}/execute":{"post":{"summary":"Manually execute a trigger","description":"Manually trigger execution of a function","tags":["Function Triggers"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"input":{"type":"object","description":"Input data to pass to the function"}}}}}},"responses":{"200":{"description":"Execution started"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trigger not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/triggers/{draftId}/publish":{"post":{"summary":"Publish a trigger from draft","description":"Publish a trigger that was saved as a draft","tags":["Function Triggers"],"parameters":[{"in":"path","name":"draftId","required":true,"schema":{"type":"string"},"description":"The draft ID (short ID from draft system)"}],"responses":{"200":{"description":"Trigger published"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Draft not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/triggers/{id}/pause":{"patch":{"summary":"Pause a trigger","description":"Pause a trigger to temporarily disable it from firing. For scheduled triggers, this also pauses the scheduler job.","tags":["Function Triggers"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Trigger paused successfully"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - system triggers cannot be paused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trigger not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/triggers/{id}/resume":{"patch":{"summary":"Resume a trigger","description":"Resume a paused trigger to re-enable it. For scheduled triggers, this also resumes the scheduler job.","tags":["Function Triggers"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Trigger resumed successfully"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - system triggers cannot be modified","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trigger not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/deliveries/failed":{"get":{"summary":"Get failed webhook deliveries","description":"Retrieve all failed webhook deliveries across the workspace","tags":["Webhooks"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of failed deliveries"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/deliveries/recent":{"get":{"summary":"Get recent webhook deliveries","description":"Retrieve recent webhook deliveries across the workspace","tags":["Webhooks"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of recent deliveries"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/deliveries/{id}/retry":{"post":{"summary":"Replay a webhook delivery","description":"Queue a replay of a previously recorded delivery. A new delivery\nrecord is inserted and picked up by the retry worker on its next\ntick (~1s). The original request payload is reused, so the HMAC\nsignature on the replay matches the original. The response returns\nthe new delivery ID along with `replayedFrom` pointing at the\noriginal delivery.\n","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"Original delivery ID to replay"}],"responses":{"202":{"description":"Replay queued","content":{"application/json":{"schema":{"type":"object","properties":{"deliveryId":{"type":"string","format":"uuid"},"replayedFrom":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["retrying"]}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Delivery not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Original delivery is still in-flight or subscription has been deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/deliveries/{id}/cancel":{"post":{"summary":"Cancel a pending webhook delivery retry","description":"Stop retrying a delivery that is currently in `retrying` status. Flips\nthe row to `failed` with a distinctive `lastError` (\"Cancelled by user\")\nso the delivery log can render cancelled rows separately from real HTTP\nfailures. After cancel, Replay becomes available immediately.\n\nRace semantics: the cancel UPDATE uses `FOR UPDATE SKIP LOCKED`. If the\nretry worker has already claimed the row and started an HTTP dispatch,\nthe cancel may win the UPDATE only to have the dispatch result\noverwrite it. In the inverse (row locked mid-claim), the endpoint\nreturns 409 and the next tick makes cancel work again.\n","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"},"description":"Delivery ID to cancel"}],"responses":{"200":{"description":"Retry cancelled","content":{"application/json":{"schema":{"type":"object","properties":{"deliveryId":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["failed"]},"lastError":{"type":"string"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Delivery not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Delivery is not in retrying status, or a retry is mid-dispatch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/deliveries/dlq":{"get":{"summary":"List DLQ'd webhook deliveries","description":"Workspace-level dead-letter inbox. Returns deliveries that exhausted\ntheir retry policy or hit the subscription's `retryWindowMs` ceiling.\nDefault list excludes deliveries an operator has already discarded.\nEach row carries a `dlqReason` ('max_attempts' or 'retry_window') so\nthe console can render a reason badge.\n","tags":["Webhooks"],"parameters":[{"in":"query","name":"limit","schema":{"type":"integer","default":50}},{"in":"query","name":"offset","schema":{"type":"integer","default":0}},{"in":"query","name":"subscriptionId","schema":{"type":"string","format":"uuid"},"description":"Restrict to a single subscription"},{"in":"query","name":"since","schema":{"type":"string","format":"date-time"}},{"in":"query","name":"until","schema":{"type":"string","format":"date-time"}},{"in":"query","name":"includeDiscarded","schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"DLQ'd deliveries"},"400":{"description":"Invalid filter value"}}}},"/webhook-subscriptions/deliveries/{id}/discard":{"post":{"summary":"Discard a DLQ'd webhook delivery","description":"Mark a DLQ'd delivery as discarded by the current operator. Sets\n`discardedAt`/`discardedBy` so the row drops out of the default DLQ\ninbox while remaining in the table for audit. Idempotent — repeating a\ndiscard returns 409.\n","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Delivery discarded"},"404":{"description":"Delivery not found"},"409":{"description":"Delivery is not in the DLQ, or has already been discarded"}}}},"/webhook-subscriptions/stats/workspace":{"get":{"summary":"Get workspace webhook statistics","description":"Retrieve aggregated webhook delivery statistics for the workspace","tags":["Webhooks"],"responses":{"200":{"description":"Webhook statistics","content":{"application/json":{"schema":{"type":"object","properties":{"total_deliveries":{"type":"integer"},"successful_deliveries":{"type":"integer"},"failed_deliveries":{"type":"integer"},"success_rate":{"type":"number"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/payload-versions":{"get":{"summary":"List outbound payload versions","description":"Return the outbound payload versions a subscription can be pinned to.\nEach subscription's `payloadVersion` selects the shape its deliveries\nare projected into; subscribers upgrade on their own timeline. The\n`latest` value is what a subscription created without an explicit\nversion is frozen to.\n","tags":["Webhooks"],"responses":{"200":{"description":"Known payload versions","content":{"application/json":{"schema":{"type":"object","properties":{"versions":{"type":"array","items":{"type":"string"},"description":"Known versions, oldest first"},"latest":{"type":"string"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions":{"get":{"summary":"List webhook subscriptions","description":"Retrieve all webhook subscriptions in the workspace","tags":["Webhooks"],"parameters":[{"in":"query","name":"page","schema":{"type":"integer","default":1}},{"in":"query","name":"limit","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"List of webhook subscriptions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create a webhook subscription","description":"Create a new webhook subscription to receive event notifications","tags":["Webhooks"],"parameters":[{"in":"header","name":"Idempotency-Key","schema":{"type":"string"},"description":"Optional idempotency key for safe retries"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","url","events"],"properties":{"name":{"type":"string","description":"Display name for the subscription"},"url":{"type":"string","format":"uri","description":"URL to receive webhook payloads"},"events":{"type":"array","items":{"type":"string"},"description":"Events to subscribe to (e.g., record.created, record.updated)"},"secret":{"type":"string","description":"Shared secret for payload signing"},"active":{"type":"boolean","default":true},"payloadVersion":{"type":"string","description":"Outbound payload version to pin the subscription to. Omit\nto freeze to the latest version at creation time.\n"}}}}}},"responses":{"201":{"description":"Webhook subscription created","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/WebhookSubscription"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/{id}":{"get":{"summary":"Get a webhook subscription","description":"Retrieve a webhook subscription by ID","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The webhook subscription","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/WebhookSubscription"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"summary":"Update a webhook subscription","description":"Update editable fields on a webhook subscription. The signing secret\nis server-managed and cannot be set here — use\n`POST /webhook-subscriptions/{id}/rotate-secret` to regenerate it.\n","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"url":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string"}},"recordSlugs":{"type":"array","items":{"type":"string"}},"active":{"type":"boolean"},"payloadVersion":{"type":"string","description":"Outbound payload version to pin the subscription to."}}}}}},"responses":{"200":{"description":"Updated webhook subscription","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookSubscription"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete a webhook subscription","description":"Delete a webhook subscription","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Subscription deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/{id}/rotate-secret":{"post":{"summary":"Rotate the signing secret","description":"Regenerate the `whsec_` signing secret with a 24h grace window. The\nprevious secret is moved to `previousSecret` and the dispatcher signs\nevery outbound delivery with BOTH the new and previous secrets\n(space-separated, per the Standard Webhooks multi-sig spec) until\n`previousSecretValidUntil` elapses. This lets receivers roll their\nverifying code over without dropping deliveries. The new secret is\nreturned in the response body; it is the caller's responsibility to\ncopy it before closing the response.\n","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Rotated webhook subscription (includes new secret)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookSubscription"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/{id}/test":{"post":{"summary":"Send a synthetic test event","description":"Dispatch a synthetic event through the production delivery pipeline so\na customer can verify their receiver before going live. The event\ncarries a top-level `isTest: true` flag, which the dispatcher surfaces\nas the `Centrali-Test-Event: true` header. Behaves identically to a\nreal event with respect to signing, retries, and the circuit breaker,\nand is recorded in the delivery log.\n","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"event":{"type":"string","description":"Event name (defaults to the subscription's first event)"},"payload":{"type":"object","description":"Arbitrary fields used as the event's `data` body"}}}}}},"responses":{"201":{"description":"Test delivery created (status reflects the receiver's response)"},"400":{"description":"Subscription inactive or has no events configured"},"404":{"description":"Subscription not found"}}}},"/webhook-subscriptions/{id}/health":{"get":{"summary":"Endpoint health summary","description":"Returns customer-facing endpoint health: windowed success rates (1h\nand 24h) and the most recent failure context. The in-process circuit\nbreaker is per-pod and intentionally not surfaced here — render any\nhealthy/degraded indicator from `successRate1h` directly.\n","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Health summary","content":{"application/json":{"schema":{"type":"object","properties":{"successRate1h":{"type":"number"},"successRate24h":{"type":"number"},"totalDeliveries1h":{"type":"integer"},"totalDeliveries24h":{"type":"integer"},"lastFailureAt":{"type":"string","format":"date-time","nullable":true},"lastFailureError":{"type":"string","nullable":true}}}}}},"404":{"description":"Subscription not found"}}}},"/webhook-subscriptions/{id}/deliveries":{"get":{"summary":"Get deliveries for a subscription","description":"Retrieve delivery history for a specific webhook subscription. Response rows\nomit `requestPayload` and `responseBody`; fetch a single delivery via\n`GET /webhook-subscriptions/{id}/deliveries/{deliveryId}` for the full payload and response.\n","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"query","name":"limit","schema":{"type":"integer","default":50}},{"in":"query","name":"offset","schema":{"type":"integer","default":0}},{"in":"query","name":"status","schema":{"type":"string","enum":["success","failed","retrying"]},"description":"Filter deliveries by status"},{"in":"query","name":"since","schema":{"type":"string","format":"date-time"},"description":"Only include deliveries created at or after this ISO 8601 timestamp"},{"in":"query","name":"until","schema":{"type":"string","format":"date-time"},"description":"Only include deliveries created at or before this ISO 8601 timestamp"}],"responses":{"200":{"description":"Delivery history (trimmed rows, no payload or response body)"},"400":{"description":"Invalid filter value","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/{id}/deliveries/{deliveryId}":{"get":{"summary":"Get a single webhook delivery","description":"Retrieve a single webhook delivery including the full request payload and response body.","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"path","name":"deliveryId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The webhook delivery"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Delivery not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-subscriptions/{id}/stats":{"get":{"summary":"Get delivery stats for a subscription","description":"Retrieve delivery statistics for a specific webhook subscription","tags":["Webhooks"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Delivery statistics","content":{"application/json":{"schema":{"type":"object","properties":{"total_deliveries":{"type":"integer"},"successful_deliveries":{"type":"integer"},"failed_deliveries":{"type":"integer"},"avg_response_time_ms":{"type":"number"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}