Hey team, I try to create a subtenant under my te...
# ask-a-descoper
n
Hey team, I try to create a subtenant under my tenant, but it creates me a tenant and not a subtenant const customAttributes = { parentTenantId: parentId // parentId is string }; const createResponse = await managementClient.management.tenant.create( tenantName, // new subtenant name as string [], customAttributes ); What am I missing?
m
@Karin Zano any chance you can help to priorities this for us please?
k
Hey, I saw some answers to this in the #C07P7AN1EQH channel. Was that not helpful? will check internally too
m
it's not helpfull it says there is no such support in the SDK can you please confirm if this is the case?
k
checking
r
Hey Niv, checking
m
Hi Reuven, we are looking to understand if there is the option via the SDK to create sub tenant by a spedific parent tenant_id or to get all sub_tenants per parent tenant_id
r
i see that it's available in the API. will add it to the SDK
just to make sure you are using the node SDK?
n
yes
m
what would be the ETA for that ? @Reuven Zabirov
r
we merged the changes, install
@descope/node-sdk@next
a version will follow in the next few days or weeks.
🙌 1
You can with this version pass parent to the create, and parentTenantId to the searchAll
m
do you mind to put here a simple example for the both usecases please?
r
create
Copy code
const parentTenantId = "id";

      // Test 2: Create a child tenant with parent reference
      console.log('\n2️⃣ Creating a child tenant with parent reference...');
      const childTenant = await descopeClient.management.tenant.create(
        'Child Department',
        ['<http://child.example.com|child.example.com>'],
        { department: 'Engineering' },
        false, // enforceSSO
        false, // disabled
        parentTenantId // parent tenant ID
      );
search
Copy code
const searchResults = await descopeClient.management.tenant.searchAll(
          undefined, // ids
          undefined, // names
          undefined, // selfProvisioningDomains
          undefined, // customAttributes
          parentTenantId // parentTenantId
        );
❤️ 1
m
Thx for the fast resolution and support. much appreciated !
🙏 2