{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Class: ApiKeyManager"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/readme"},"children":["PERS SDK - v2.3.26"]}," / ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/modules"},"children":["Exports"]}," / ApiKeyManager"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"class-apikeymanager","__idx":0},"children":["Class: ApiKeyManager"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["API Key Manager"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Provides high-level API key management operations for tenant admins."," ","Handles JWT token creation, API key listing, and revocation with proper error handling."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Admin Access Required"]},": All operations require tenant admin authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Create JWT token for tenant\nconst jwtToken = await sdk.apiKeys.createJwtToken('Frontend App');\nconsole.log('Store this JWT securely:', jwtToken.key);\n\n// List all tenant API keys\nconst apiKeys = await sdk.apiKeys.listApiKeys();\napiKeys.forEach(key => {\n  console.log(`${key.name} (${key.type}) - Active: ${key.isActive}`);\n});\n\n// Revoke an API key\nawait sdk.apiKeys.revokeApiKey('key-id-to-revoke');\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"table-of-contents","__idx":1},"children":["Table of contents"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"constructors","__idx":2},"children":["Constructors"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/apikeymanager#constructor"},"children":["constructor"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"methods","__idx":3},"children":["Methods"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/apikeymanager#listapikeys"},"children":["listApiKeys"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/apikeymanager#createapikey"},"children":["createApiKey"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/apikeymanager#revokeapikey"},"children":["revokeApiKey"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"constructors-1","__idx":4},"children":["Constructors"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"constructor","__idx":5},"children":["constructor"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["• ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["new ApiKeyManager"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apiClient"]},"): ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/apikeymanager"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyManager"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters","__idx":6},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apiClient"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/persapiclient"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PersApiClient"]}]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns","__idx":7},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/apikeymanager"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyManager"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in","__idx":8},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/api-key-manager.ts#L41"},"children":["managers/api-key-manager.ts:41"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"methods-1","__idx":9},"children":["Methods"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"listapikeys","__idx":10},"children":["listApiKeys"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["▸ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["listApiKeys"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["type?"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["includeRevoked?"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["options?"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PaginatedResponseDTO"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyDTO"]},">>"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get all API keys for the current tenant with pagination"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Admin Only"]},": Requires tenant admin authentication"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-1","__idx":11},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Default value"},"children":["Default value"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["type?"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["IntegrationApiKeyType"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["undefined"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Optional filter by integration API key type (database-stored tokens)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["includeRevoked"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Include revoked API keys in results (default: false)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["options?"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PaginationOptions"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["undefined"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["-"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-1","__idx":12},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PaginatedResponseDTO"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyDTO"]},">>"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Paginated API keys with metadata (excludes actual key values)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Get all active API keys\nconst { data: allKeys } = await sdk.apiKeys.listApiKeys();\n\n// Get only active JWT tokens\nconst { data: jwtKeys } = await sdk.apiKeys.listApiKeys('TENANT_SYSTEM_JWT');\n\n// Get all JWT tokens including revoked ones\nconst { data: allJwtKeys } = await sdk.apiKeys.listApiKeys('TENANT_SYSTEM_JWT', true);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in-1","__idx":13},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/api-key-manager.ts#L70"},"children":["managers/api-key-manager.ts:70"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"createapikey","__idx":14},"children":["createApiKey"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["▸ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["createApiKey"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["req"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyCreatedDTO"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create a new API key with specified type"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Admin Only"]},": Requires tenant admin authentication"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Security Warning"]},": The returned API key is only shown once - store it securely"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-2","__idx":15},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["req"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyRequestDTO"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["API key creation request containing type, name, and optional configuration"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-2","__idx":16},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyCreatedDTO"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Created API key with the actual key value"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Create a JWT token\nconst jwtKey = await sdk.apiKeys.createApiKey('TENANT_SYSTEM_JWT', 'Frontend App');\nconsole.log('Store this JWT securely:', jwtKey.privateKey);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in-2","__idx":17},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/api-key-manager.ts#L95"},"children":["managers/api-key-manager.ts:95"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"revokeapikey","__idx":18},"children":["revokeApiKey"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["▸ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["revokeApiKey"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apiKeyId"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyVerificationDTO"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Permanently revoke an API key"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Admin Only"]},": Requires tenant admin authentication"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Warning"]},": This operation cannot be undone. The API key will be permanently disabled."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-3","__idx":19},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apiKeyId"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Unique identifier of the API key to revoke"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-3","__idx":20},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiKeyVerificationDTO"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["API key verification details with revocation status"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"try {\n  // List keys to find the one to revoke\n  const apiKeys = await sdk.apiKeys.listApiKeys();\n  const oldKey = apiKeys.find(key => key.name === 'Old Frontend App');\n  \n  if (oldKey) {\n    const result = await sdk.apiKeys.revokeApiKey(oldKey.id);\n    console.log('Revocation successful:', result.success);\n    if (result.apiKey) {\n      console.log('Revoked key:', result.apiKey.name);\n    }\n  }\n} catch (error) {\n  console.error('Failed to revoke API key:', error.message);\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in-3","__idx":21},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/api-key-manager.ts#L133"},"children":["managers/api-key-manager.ts:133"]}]}]},"headings":[{"value":"Class: ApiKeyManager","id":"class-apikeymanager","depth":1},{"value":"Table of contents","id":"table-of-contents","depth":2},{"value":"Constructors","id":"constructors","depth":3},{"value":"Methods","id":"methods","depth":3},{"value":"Constructors","id":"constructors-1","depth":2},{"value":"constructor","id":"constructor","depth":3},{"value":"Parameters","id":"parameters","depth":4},{"value":"Returns","id":"returns","depth":4},{"value":"Defined in","id":"defined-in","depth":4},{"value":"Methods","id":"methods-1","depth":2},{"value":"listApiKeys","id":"listapikeys","depth":3},{"value":"Parameters","id":"parameters-1","depth":4},{"value":"Returns","id":"returns-1","depth":4},{"value":"Defined in","id":"defined-in-1","depth":4},{"value":"createApiKey","id":"createapikey","depth":3},{"value":"Parameters","id":"parameters-2","depth":4},{"value":"Returns","id":"returns-2","depth":4},{"value":"Defined in","id":"defined-in-2","depth":4},{"value":"revokeApiKey","id":"revokeapikey","depth":3},{"value":"Parameters","id":"parameters-3","depth":4},{"value":"Returns","id":"returns-3","depth":4},{"value":"Defined in","id":"defined-in-3","depth":4}],"frontmatter":{"seo":{"title":"Class: ApiKeyManager"}},"lastModified":"2026-08-21T18:40:55.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/sdk-reference/classes/apikeymanager","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}