@@ -76,6 +76,8 @@ Then, you can use that to work with the following functions:
767613 . [ Manage FGA (Fine-grained Authorization)] ( #manage-fga-fine-grained-authorization )
777714 . [ Manage Project] ( #manage-project )
787815 . [ Manage SSO applications] ( #manage-sso-applications )
79+ 16 . [ Manage Management Keys] ( #manage-management-keys )
80+ 17 . [ Manage Descopers] ( #manage-descopers )
7981
8082If you wish to run any of our code samples and play with them, check out our [ Code Examples] ( #code-examples ) section.
8183
@@ -1535,6 +1537,101 @@ await descopeClient.management.inboundApplication.deleteConsents({
15351537});
15361538```
15371539
1540+ ### Manage Management Keys
1541+
1542+ You can create, update, delete, load, or search management keys:
1543+
1544+ ``` typescript
1545+ // Create a new management key.
1546+ // The name is required, other fields are optional.
1547+ // expiresIn is the expiration time in seconds (0 for no expiration).
1548+ // permittedIps is an optional list of IP addresses or CIDR ranges that are allowed to use this key.
1549+ // reBac specifies the role-based access control configuration for the key.
1550+ const createRes = await descopeClient .management .managementKey .create (
1551+ ' my-key-name' ,
1552+ ' Optional description' ,
1553+ 3600 , // expires in 1 hour
1554+ [' 10.0.0.1/24' ], // optional permitted IPs
1555+ { companyRoles: [' Admin' ] }, // optional reBac configuration
1556+ );
1557+ console .log (' Created key:' , createRes .data .key );
1558+ console .log (' Key secret (save this!):' , createRes .data .cleartext );
1559+
1560+ // Load a management key by ID
1561+ const loadRes = await descopeClient .management .managementKey .load (' key-id' );
1562+ console .log (' Loaded key:' , loadRes .data .key );
1563+
1564+ // Search all management keys
1565+ const searchRes = await descopeClient .management .managementKey .search ();
1566+ searchRes .data .keys .forEach ((key ) => {
1567+ // do something
1568+ });
1569+
1570+ // Update an existing management key.
1571+ // IMPORTANT: All parameters will override whatever values are currently set in the existing key.
1572+ await descopeClient .management .managementKey .update (
1573+ ' key-id' ,
1574+ ' updated-key-name' ,
1575+ ' Updated description' ,
1576+ [' 1.2.3.4' ], // updated permitted IPs
1577+ ' active' , // status: 'active' or 'inactive'
1578+ );
1579+
1580+ // Delete management keys by IDs.
1581+ // IMPORTANT: This action is irreversible. Use carefully.
1582+ await descopeClient .management .managementKey .delete ([' key-id-1' , ' key-id-2' ]);
1583+ ```
1584+
1585+ ### Manage Descopers
1586+
1587+ You can create, update, delete, or load descopers (Descope console users):
1588+
1589+ ``` typescript
1590+ // Create descopers. Each descoper must have a loginId.
1591+ // Optionally set attributes (displayName, email, phone) and RBAC configuration.
1592+ // sendInvite can be set to true to send an invitation email.
1593+ await descopeClient .management .descoper .create ([
1594+ {
1595+ 1596+ attributes: {
1597+ displayName: ' Test User' ,
1598+ 1599+ phone: ' +1234567890' ,
1600+ },
1601+ sendInvite: true ,
1602+ rbac: {
1603+ // exactly one of isCompanyAdmin, projects or tags
1604+ projects: [
1605+ {
1606+ projectIds: [' project-id-1' ],
1607+ role: ' admin' , // 'admin' | 'developer' | 'support' | 'auditor'
1608+ },
1609+ ],
1610+ },
1611+ },
1612+ ]);
1613+
1614+ // Load a specific descoper by ID
1615+ const descoperRes = await descopeClient .management .descoper .load (' descoper-id' );
1616+ console .log (' Loaded descoper:' , descoperRes .data );
1617+
1618+ // Load all descopers
1619+ const descopersRes = await descopeClient .management .descoper .loadAll ();
1620+ descopersRes .data .descopers .forEach ((descoper ) => {
1621+ // do something
1622+ });
1623+
1624+ // Update a descoper's attributes and/or RBAC configuration
1625+ await descopeClient .management .descoper .update (
1626+ ' descoper-id' ,
1627+ { displayName: ' Updated Name' }, // attributes (optional)
1628+ { isCompanyAdmin: true }, // rbac (optional)
1629+ );
1630+
1631+ // Descoper deletion cannot be undone. Use carefully.
1632+ await descopeClient .management .descoper .delete (' descoper-id' );
1633+ ```
1634+
15381635### Utils for your end to end (e2e) tests and integration tests
15391636
15401637To ease your e2e tests, we exposed dedicated management methods,
0 commit comments