Create tenant (v4beta1)

Create tenant.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample


const talent = require('@google-cloud/talent').v4;

/** Create Tenant for scoping resources, e.g. companies and jobs */
function sampleCreateTenant(projectId, externalId) {
  const client = new talent.TenantServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const externalId = 'Your Unique Identifier for Tenant';
  const formattedParent = client.projectPath(projectId);
  const tenant = {
    externalId: externalId,
  const request = {
    parent: formattedParent,
    tenant: tenant,
    .then(responses => {
      const response = responses[0];
      console.log('Created Tenant');
      console.log(`Name: ${}`);
      console.log(`External ID: ${response.externalId}`);
    .catch(err => {


from import talent
import six

def create_tenant(project_id, external_id):
    """Create Tenant for scoping resources, e.g. companies and jobs"""

    client = talent.TenantServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # external_id = 'Your Unique Identifier for Tenant'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(external_id, six.binary_type):
        external_id = external_id.decode("utf-8")
    parent = f"projects/{project_id}"
    tenant = talent.Tenant(external_id=external_id)

    response = client.create_tenant(parent=parent, tenant=tenant)
    print("Created Tenant")
    print(f"Name: {}")
    print(f"External ID: {response.external_id}")

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.