{"openapi":"3.0.0","info":{"title":"Document Hub API","version":"1.0.0","description":"API for managing documents with client authentication"},"servers":[{"url":"https:\/\/document-hub-api-xp.wake.tech\/api","description":"API Server"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"paths":{"\/v1\/client\/{client}\/{environment}\/context\/{context}\/type\/{type}\/{key}":{"get":{"summary":"Get a document by key","description":"Retrieve a specific document by its key. Supports filtering on model fields (created_at, updated_at, expires_at, version) and JSON data fields. Requires document:read scope.","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}},{"name":"deleted","in":"query","required":false,"schema":{"type":"boolean"},"description":"Include soft-deleted documents"},{"name":"filter","in":"query","required":false,"style":"deepObject","explode":true,"schema":{"type":"object","additionalProperties":{"type":"string"}},"description":"Filter by fields. Supports operators: _gt, _gte, _lt, _lte, _like, _neq (e.g., filter[price_gt]=100)"}],"responses":{"200":{"description":"Document found"},"403":{"description":"Forbidden: Missing document:read scope"},"404":{"description":"Not found"}}},"put":{"summary":"Update a document","description":"Update an existing document. Route parameters must match payload values.","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["environment","context","type","key","data"],"properties":{"environment":{"type":"string","description":"Must match path parameter"},"context":{"type":"string","description":"Must match path parameter"},"type":{"type":"string","description":"Must match path parameter"},"key":{"type":"string","description":"Must match path parameter"},"data":{"type":"object","description":"Document data"},"expires_at":{"type":"string","format":"date-time","description":"Expiration date (optional)"},"ttl":{"type":"integer","description":"Time to live in seconds (alternative to expires_at)"}}}}}},"responses":{"200":{"description":"Document updated"},"400":{"description":"Bad request: route parameters do not match payload"},"404":{"description":"Not found"},"422":{"description":"Schema validation failed"}}},"post":{"summary":"Create a document","description":"Create a new document. Route parameters must match payload values.","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["environment","context","type","key","data"],"properties":{"environment":{"type":"string","description":"Must match path parameter"},"context":{"type":"string","description":"Must match path parameter"},"type":{"type":"string","description":"Must match path parameter"},"key":{"type":"string","description":"Must match path parameter"},"data":{"type":"object","description":"Document data"},"expires_at":{"type":"string","format":"date-time","description":"Expiration date (optional)"},"ttl":{"type":"integer","description":"Time to live in seconds (alternative to expires_at)"}}}}}},"responses":{"201":{"description":"Document created"},"400":{"description":"Bad request: route parameters do not match payload"},"409":{"description":"Conflict: Document already exists"},"422":{"description":"Schema validation failed"}}},"delete":{"summary":"Delete a document","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Document deleted"},"404":{"description":"Not found"}}}},"\/v1\/client\/{client}\/{environment}\/context\/{context}\/type\/{type}":{"get":{"summary":"List documents paginated","description":"List all documents of a specific type with pagination. Supports filtering on model fields (created_at, updated_at, expires_at, version) and JSON data fields. Requires document:list scope.","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"deleted","in":"query","required":false,"schema":{"type":"boolean"},"description":"Include soft-deleted documents"},{"name":"filter","in":"query","required":false,"style":"deepObject","explode":true,"schema":{"type":"object","additionalProperties":{"type":"string"}},"description":"Filter by fields. Supports operators: _gt, _gte, _lt, _lte, _like, _neq (e.g., filter[price_gt]=100)"}],"responses":{"200":{"description":"Paginated documents list"},"403":{"description":"Forbidden: Missing document:list scope"}}}},"\/v1\/client\/{client}\/{environment}\/context\/{context}\/type\/{type}\/bulk":{"post":{"summary":"Bulk create or update documents","description":"Create or update multiple documents in a single transaction. For each document: if it does not exist, it will be created; if it exists and data has changed, it will be updated with version increment. Requires both document:create and document:update scopes.","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["documents"],"properties":{"documents":{"type":"array","description":"Array of documents to create or update","items":{"type":"object","required":["key","data"],"properties":{"key":{"type":"string","description":"Document key"},"data":{"type":"object","description":"Document data object"}}}}}},"example":{"documents":[{"key":"doc1","data":{"field1":"value1","field2":"value2"}},{"key":"doc2","data":{"field1":"value3","field2":"value4"}}]}}}},"responses":{"200":{"description":"Documents created or updated successfully. Returns an array of all processed documents."},"400":{"description":"Bad request: Invalid document structure or schema validation failed"},"403":{"description":"Forbidden: Missing document:create or document:update scope"}}}},"\/v1\/client\/{client}\/{environment}\/context\/{context}\/type\/{type}\/{key}\/history":{"get":{"summary":"Get document history","description":"Retrieve paginated version history for a specific document. Requires document:read scope.","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Paginated document history, ordered by version descending"},"403":{"description":"Forbidden: Missing document:read scope"}}}},"\/v1\/client\/{client}\/{environment}\/context\/{context}\/type\/{type}\/{key}\/history\/{historyId}":{"get":{"summary":"Get a specific document version","description":"Retrieve a specific version of a document from its history by history ID. Requires document:read scope.","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}},{"name":"historyId","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"History record ID"}],"responses":{"200":{"description":"Specific document version found","content":{"application\/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"History record ID"},"client_id":{"type":"string","format":"uuid"},"environment":{"type":"string"},"context":{"type":"string"},"type":{"type":"string"},"key":{"type":"string"},"data":{"type":"object","description":"Document data at this version"},"version":{"type":"integer","description":"Version number"},"expires_at":{"type":"string","format":"date-time","nullable":true},"created_at":{"type":"string","format":"date-time","description":"When this version was created"}}}}}},"403":{"description":"Forbidden: Missing document:read scope"},"404":{"description":"Version not found or does not belong to this document"}}}},"\/v1\/client\/{client}\/{environment}\/context\/{context}\/type\/{type}\/{key}\/history\/{history}\/restore":{"post":{"summary":"Restore document from history","description":"Restore a document to a previous version from its history. Current version is saved to history before restoration. A new version number is assigned. Requires document:update scope.","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}},{"name":"history","in":"path","required":true,"schema":{"type":"integer"},"description":"History record ID to restore from"}],"responses":{"200":{"description":"Document restored successfully. Returns the updated document with new version."},"403":{"description":"Forbidden: Missing document:update scope"},"404":{"description":"Document or history record not found"}}}},"\/v1\/client\/{client}\/schemas":{"get":{"summary":"List all schemas for a client","description":"List all document schemas for the authenticated client with optional filters. Requires schema:manage scope.","tags":["Schemas"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by environment"},{"name":"context","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by context"},{"name":"type","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by document type"},{"name":"per_page","in":"query","required":false,"schema":{"type":"integer","default":15},"description":"Items per page"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","default":1},"description":"Page number"}],"responses":{"200":{"description":"List of schemas with pagination","content":{"application\/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"client_id":{"type":"string","format":"uuid"},"environment":{"type":"string"},"context":{"type":"string"},"type":{"type":"string"},"schema":{"type":"object"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}}},"pagination":{"type":"object","properties":{"current_page":{"type":"integer"},"per_page":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"},"from":{"type":"integer","nullable":true},"to":{"type":"integer","nullable":true}}}}}}}},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden: Missing schema:manage scope"}}}},"\/v1\/client\/{client}\/{environment}\/context\/{context}\/type\/{type}\/schema":{"post":{"summary":"Create or update a document schema","description":"Create or update a JSON Schema for document validation. If schema exists, it will be updated; otherwise, a new one is created. Requires schema:manage scope.","tags":["Schemas"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["schema"],"properties":{"schema":{"type":"object","description":"JSON Schema definition (must be a valid JSON Schema object)"}}}}}},"responses":{"200":{"description":"Schema updated successfully"},"201":{"description":"Schema created successfully"},"403":{"description":"Forbidden: Missing schema:manage scope"},"422":{"description":"Validation error: schema field is required and must be an object"}}},"get":{"summary":"Get document schema","description":"Retrieve the JSON Schema for a specific document type.","tags":["Schemas"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Schema found"},"404":{"description":"Schema not found"}}},"delete":{"summary":"Delete document schema","description":"Delete the JSON Schema for a specific document type. Requires schema:manage scope.","tags":["Schemas"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"context","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Schema deleted successfully"},"403":{"description":"Forbidden: Missing schema:manage scope"},"404":{"description":"Schema not found"}}}},"\/v1\/client\/{client}\/webhooks":{"get":{"summary":"List webhooks","tags":["Webhooks"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of webhooks"}}},"post":{"summary":"Create a webhook","description":"Create a new webhook to receive event notifications. Authentication configuration is required when auth_type is not \"none\".","tags":["Webhooks"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["url","events"],"properties":{"url":{"type":"string","format":"uri","description":"Webhook destination URL (must be unique for this client)"},"events":{"type":"array","items":{"type":"string","enum":["document.created","document.updated","document.deleted","document.read"]},"description":"Events to listen to (required, must not be empty)"},"status":{"type":"string","enum":["active","inactive"],"default":"active","description":"Webhook status (optional, defaults to active)"},"auth_type":{"type":"string","enum":["none","bearer","basic","api_key","custom_headers"],"default":"none","description":"Authentication type (optional, defaults to none)"},"auth_config":{"type":"object","description":"Authentication configuration - REQUIRED when auth_type is not \"none\". Structure varies by auth_type.","oneOf":[{"description":"Bearer token authentication (for auth_type: bearer)","type":"object","required":["token"],"properties":{"token":{"type":"string","description":"Bearer token"}}},{"description":"Basic authentication (for auth_type: basic)","type":"object","required":["username","password"],"properties":{"username":{"type":"string","description":"Basic auth username"},"password":{"type":"string","description":"Basic auth password"}}},{"description":"API Key in custom header (for auth_type: api_key)","type":"object","required":["header_name","header_value"],"properties":{"header_name":{"type":"string","description":"Header name for API key"},"header_value":{"type":"string","description":"API key value"}}},{"description":"Custom headers (for auth_type: custom_headers)","type":"object","required":["headers"],"properties":{"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"Object with custom headers"}}}]}}}}}},"responses":{"201":{"description":"Webhook created successfully"},"422":{"description":"Validation error (e.g., duplicate URL, invalid auth_config)"}}}},"\/v1\/client\/{client}\/webhooks\/{webhook}":{"get":{"summary":"Get a specific webhook","tags":["Webhooks"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"webhook","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Webhook details"},"404":{"description":"Not found"}}},"put":{"summary":"Update a webhook","description":"Update an existing webhook. All fields are optional - only provided fields will be updated. If auth_type is provided and not \"none\", auth_config is required.","tags":["Webhooks"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"webhook","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"Webhook destination URL (optional, must be unique for this client)"},"events":{"type":"array","items":{"type":"string","enum":["document.created","document.updated","document.deleted","document.read"]},"description":"Events to listen to (optional)"},"status":{"type":"string","enum":["active","inactive"],"description":"Webhook status (optional)"},"auth_type":{"type":"string","enum":["none","bearer","basic","api_key","custom_headers"],"description":"Authentication type (optional). If set to \"none\", auth_config is cleared."},"auth_config":{"type":"object","description":"Authentication configuration - REQUIRED when auth_type is provided and not \"none\". Structure varies by auth_type.","oneOf":[{"description":"Bearer token (for auth_type: bearer)","type":"object","required":["token"],"properties":{"token":{"type":"string"}}},{"description":"Basic auth (for auth_type: basic)","type":"object","required":["username","password"],"properties":{"username":{"type":"string"},"password":{"type":"string"}}},{"description":"API Key (for auth_type: api_key)","type":"object","required":["header_name","header_value"],"properties":{"header_name":{"type":"string"},"header_value":{"type":"string"}}},{"description":"Custom headers (for auth_type: custom_headers)","type":"object","required":["headers"],"properties":{"headers":{"type":"object","additionalProperties":{"type":"string"}}}}]}}}}}},"responses":{"200":{"description":"Webhook updated successfully"},"404":{"description":"Webhook not found"},"422":{"description":"Validation error"}}},"delete":{"summary":"Delete a webhook","tags":["Webhooks"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"webhook","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"204":{"description":"Webhook deleted"},"404":{"description":"Not found"}}}},"\/v1\/client\/{client}\/documents\/types":{"get":{"summary":"List document types with counts and permissions","description":"Returns all document types (environment, context, type combinations) for a client with document counts and permission information for the current token","tags":["Documents"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"environment","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by environment"},{"name":"context","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by context"},{"name":"include_deleted","in":"query","required":false,"schema":{"type":"boolean"},"description":"Include soft-deleted documents in counts"},{"name":"per_page","in":"query","required":false,"schema":{"type":"integer","default":15},"description":"Items per page"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","default":1},"description":"Page number"}],"responses":{"200":{"description":"List of document types with counts and permissions","content":{"application\/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"environment":{"type":"string"},"context":{"type":"string"},"type":{"type":"string"},"document_count":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_create":{"type":"boolean"},"can_update":{"type":"boolean"},"can_delete":{"type":"boolean"}}}}}},"summary":{"type":"object","properties":{"total_types":{"type":"integer"},"total_documents":{"type":"integer"}}},"pagination":{"type":"object","properties":{"current_page":{"type":"integer"},"per_page":{"type":"integer"},"total_pages":{"type":"integer"},"total_items":{"type":"integer"}}}}}}}},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden - Missing required scope"}}}},"\/v1\/client\/{client}\/tokens":{"get":{"summary":"List access tokens","tags":["Tokens"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of access tokens"}}},"post":{"summary":"Create an access token","description":"Create a new access token with permissions and optional document-specific rules. The plain-text token is only shown once in the response.","tags":["Tokens"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["name","scopes"],"properties":{"name":{"type":"string","maxLength":255,"description":"Token name"},"scopes":{"type":"object","required":["permissions","document_rules"],"description":"Token scopes defining permissions","properties":{"permissions":{"type":"array","items":{"type":"string","enum":["document:create","document:read","document:update","document:delete","document:list","schema:manage","webhook:manage","token:manage"]},"description":"General permissions array"},"document_rules":{"type":"array","description":"Document-specific permission rules","items":{"type":"object","required":["type","context","environment","permissions"],"properties":{"type":{"type":"string","description":"Document type"},"context":{"type":"string","description":"Document context"},"environment":{"type":"string","description":"Document environment"},"permissions":{"type":"array","items":{"type":"string","enum":["document:create","document:read","document:update","document:delete","document:list","schema:manage","webhook:manage","token:manage"]},"description":"Permissions for this specific document type"}}}}}},"expires_at":{"type":"string","format":"date-time","description":"Token expiration date (optional, must be in the future)"}}}}}},"responses":{"201":{"description":"Token created successfully. Response includes the plain-text token (only shown once) and token details."},"422":{"description":"Validation error"}}}},"\/v1\/client\/{client}\/tokens\/{tokenId}":{"get":{"summary":"Get a specific token by ID","description":"Retrieve details of a specific access token. Requires token:manage permission. Does not expose the token hash.","tags":["Tokens"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"tokenId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Token details","content":{"application\/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Token ID"},"client_id":{"type":"string","format":"uuid","description":"Client ID"},"name":{"type":"string","description":"Token name"},"scopes":{"type":"object","description":"Token scopes and permissions","properties":{"permissions":{"type":"array","items":{"type":"string"},"description":"General permissions"},"document_rules":{"type":"array","description":"Document-specific rules","items":{"type":"object"}}}},"status":{"type":"string","enum":["active","inactive"],"description":"Token status"},"expires_at":{"type":"string","format":"date-time","nullable":true,"description":"Token expiration date"},"last_used_at":{"type":"string","format":"date-time","nullable":true,"description":"Last time token was used"},"created_at":{"type":"string","format":"date-time","description":"Token creation date"},"updated_at":{"type":"string","format":"date-time","description":"Last update date"}}}}}},"403":{"description":"Forbidden: Missing token:manage scope"},"404":{"description":"Token not found or does not belong to this client"}}},"put":{"summary":"Update an access token","description":"Update token name, scopes, or status. All fields are optional - only provided fields will be updated.","tags":["Tokens"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"tokenId","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","properties":{"name":{"type":"string","maxLength":255,"description":"Token name (optional)"},"scopes":{"type":"object","description":"Token scopes (optional)","properties":{"permissions":{"type":"array","items":{"type":"string","enum":["document:create","document:read","document:update","document:delete","document:list","schema:manage","webhook:manage","token:manage"]},"description":"General permissions array"},"document_rules":{"type":"array","description":"Document-specific permission rules","items":{"type":"object","required":["type","context","environment","permissions"],"properties":{"type":{"type":"string","description":"Document type"},"context":{"type":"string","description":"Document context"},"environment":{"type":"string","description":"Document environment"},"permissions":{"type":"array","items":{"type":"string","enum":["document:create","document:read","document:update","document:delete","document:list","schema:manage","webhook:manage","token:manage"]},"description":"Permissions for this specific document type"}}}}}},"status":{"type":"string","enum":["active","inactive"],"description":"Token status (optional)"}}}}}},"responses":{"200":{"description":"Token updated successfully"},"404":{"description":"Token not found"},"422":{"description":"Validation error"}}},"delete":{"summary":"Delete an access token","tags":["Tokens"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"tokenId","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"204":{"description":"Token deleted"},"404":{"description":"Not found"}}}},"\/v1\/client\/{client}\/tokens\/whoami":{"get":{"summary":"Get current token information (whoami)","description":"Returns information about the currently authenticated token (self-introspection). Does not require token:manage permission.","tags":["Tokens"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Current token information","content":{"application\/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Token ID"},"name":{"type":"string","description":"Token name"},"scopes":{"type":"object","description":"Token scopes and permissions","properties":{"permissions":{"type":"array","items":{"type":"string"},"description":"General permissions"},"document_rules":{"type":"array","description":"Document-specific rules","items":{"type":"object"}}}},"status":{"type":"string","enum":["active","inactive"],"description":"Token status"},"expires_at":{"type":"string","format":"date-time","nullable":true,"description":"Token expiration date"},"last_used_at":{"type":"string","format":"date-time","nullable":true,"description":"Last time token was used"},"created_at":{"type":"string","format":"date-time","description":"Token creation date"}}}}}},"401":{"description":"Not authenticated"},"403":{"description":"Token does not belong to this client"}}}}}}