Create and update companies (v3)

A Company resource in the Cloud Talent Solution API represents a single company. Any job belonging to that company refers to a job posting that is created for an open position in that company. It contains information such as the company name and address, as well as internal fields that tie the resource in the Cloud Talent Solution service back to your internal databases.

Create a company

To create a Company, send a POST request to the companies endpoint, specifying at least the two required fields. Refer to the Quickstart: Create companies and jobs page for details on how to create a company.

Java

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/** Create a company. */
public static Company createCompany(Company companyToBeCreated) throws IOException {
  try {
    CreateCompanyRequest createCompanyRequest =
        new CreateCompanyRequest().setCompany(companyToBeCreated);
    Company companyCreated =
        talentSolutionClient
            .projects()
            .companies()
            .create(DEFAULT_PROJECT_ID, createCompanyRequest)
            .execute();
    System.out.println("Company created: " + companyCreated);
    return companyCreated;
  } catch (IOException e) {
    System.out.println("Got exception while creating company");
    throw e;
  }
}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

def create_company(client_service, company_to_be_created):
    try:
        request = {'company': company_to_be_created}
        company_created = client_service.projects().companies().create(
            parent=parent, body=request).execute()
        print('Company created: %s' % company_created)
        return company_created
    except Error as e:
        print('Got exception while creating company')
        raise e

C#

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


public static Company CreateCompany(Company companyToBeCreated)
{
    try
    {
        CreateCompanyRequest createCompanyRequest = new CreateCompanyRequest();
        createCompanyRequest.Company = companyToBeCreated;
        Company companyCreated = jobServiceClient.Projects.Companies.Create(createCompanyRequest, parent).Execute();
        Console.WriteLine("Created company: " + ToJsonString(companyCreated));
        return companyCreated;
    }
    catch (Exception e)
    {
        Console.WriteLine("Got exception while creating company");
        throw e;
    }
}

Go

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


// createCompany creates a company as given.
func createCompany(w io.Writer, projectID string, companyToCreate *talent.Company) (*talent.Company, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %v", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %v", err)
	}

	parent := "projects/" + projectID
	req := &talent.CreateCompanyRequest{
		Company: companyToCreate,
	}
	company, err := service.Projects.Companies.Create(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to create company %q: %v", companyToCreate.DisplayName, err)
	}

	return company, nil
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/**
 * Create a company.
 */
const createCompany = async (jobServiceClient, companyToBeCreated) => {
  try {
    const request = {
      parent: `projects/${PROJECT_ID}`,
      resource: {
        company: companyToBeCreated,
      },
    };

    const companyCreated = await jobServiceClient.projects.companies.create(
      request
    );

    console.log(`Company created: ${JSON.stringify(companyCreated.data)}`);
    return companyCreated.data;
  } catch (e) {
    console.error(`Failed to create company! ${e}`);
    throw e;
  }
};

Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

# project_id              = "Id of the project"
# company_to_be_created   = "Company to be created"

require "google/apis/jobs_v3"

jobs = Google::Apis::JobsV3
talent_solution_client = jobs::CloudTalentSolutionService.new
# @see
# https://developers.google.com/identity/protocols/application-default-credentials#callingruby
talent_solution_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/jobs"
)

begin
  create_company_request = jobs::CreateCompanyRequest.new company: company_to_be_created
  company_created = talent_solution_client.create_company project_id, create_company_request
  puts "Company created: #{company_created.to_json}"
  return company_created
rescue StandardError => e
  puts "Exception occurred while creating company: #{e}"
end

Required fields

The following fields are required in create/update requests:

  • displayName: The name of the employer displayed with the job, for example, "Google LLC".

  • externalId: Your internal ID for this company. This field allows you to map your internal identifiers to the company in Google's system. If the company doesn't have a separate internal identifier, set this field to the same value as displayName.

Commonly used fields

  • headquartersAddress: The street address of the company's main headquarters, which may be different from the job location. Cloud Talent Solution only accepts a single HQ location per company. The service attempts to geolocate the address, and populates a more specific location when possible in derivedInfo.headquartersLocation (which is output only).

  • size: A bucket value representing the size of the company in terms of number of employees, from MINI to GIANT. See the size reference for enums and their definitions.

  • eeoText: A string containing the Equal Employment Opportunity legal disclaimer text to be associated with all jobs for this company.

  • keywordSearchableJobCustomAttributes: Specifies which customAttributes on this company's jobs should be indexed and searchable by general keyword search.

Update a company

To update a company, send a PATCH request to the following endpoint:

 PATCH https://jobs.googleapis.com/v3/COMPANY_NAME 

Where COMPANY_NAME is the value of the name field for the company. name is the unique identifier of the company that is returned at creation time and also by company.get and list requests.

The body of the request must contain the entire resource, including fields not being updated. These fields can be set in the updateMask. If fields are set in the updateMask, then only those fields are updated, and updates to other fields are ignored. If the updateMask is not set, then all fields are updated.

Java

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/** Updates a company. */
public static Company updateCompany(String companyName, Company companyToBeUpdated)
    throws IOException {
  try {
    UpdateCompanyRequest updateCompanyRequest =
        new UpdateCompanyRequest().setCompany(companyToBeUpdated);

    Company companyUpdated =
        talentSolutionClient
            .projects()
            .companies()
            .patch(companyName, updateCompanyRequest)
            .execute();

    System.out.println("Company updated: " + companyUpdated);
    return companyUpdated;
  } catch (IOException e) {
    System.out.println("Got exception while updating company");
    throw e;
  }
}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

def update_company(client_service, company_name, company_to_be_updated):
    try:
        request = {'company': company_to_be_updated}
        company_updated = client_service.projects().companies().patch(
            name=company_name, body=request).execute()
        print('Company updated: %s' % company_updated)
        return company_updated
    except Error as e:
        print('Got exception while updating company')
        raise e

C#

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


public static Company UpdateCompany(String companyName, Company companyToBeUpdated)
{
    try
    {
        UpdateCompanyRequest updateCompanyRequest = new UpdateCompanyRequest()
        {
            Company = companyToBeUpdated
        };
        Company companyUpdated = jobServiceClient.Projects.Companies.Patch(updateCompanyRequest, companyName).Execute();
        Console.WriteLine("Company updated: " + ToJsonString(companyUpdated));
        return companyUpdated;
    }
    catch (Exception e)
    {
        Console.WriteLine("Got exception while updating company");
        throw e;
    }
}

Go

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


// updateCompany update a company with all fields.
func updateCompany(w io.Writer, name string, companyToUpdate *talent.Company) (*talent.Company, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %v", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %v", err)
	}

	updateCompanyRequest := &talent.UpdateCompanyRequest{
		Company: companyToUpdate,
	}
	company, err := service.Projects.Companies.Patch(name, updateCompanyRequest).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to update company %q: %v", name, err)
	}

	return company, nil
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/**
 * Updates a company.
 */
const updateCompany = async (
  jobServiceClient,
  companyName,
  companyToBeUpdated
) => {
  try {
    const request = {
      name: companyName,
      resource: {
        company: companyToBeUpdated,
      },
    };

    const companyUpdated = await jobServiceClient.projects.companies.patch(
      request
    );

    console.log(`Company updated: ${JSON.stringify(companyUpdated.data)}`);
    return companyUpdated.data;
  } catch (e) {
    console.error(`Got exception while updating company! ${e}`);
    throw e;
  }
};

Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

# company_name     = "The name of the company you want to update. The format is "projects/{project_id}/companies/{company_id}""
# company_updated  = "The new company object to be updated"

require "google/apis/jobs_v3"

jobs = Google::Apis::JobsV3
talent_solution_client = jobs::CloudTalentSolutionService.new
# @see
# https://developers.google.com/identity/protocols/application-default-credentials#callingruby
talent_solution_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/jobs"
)

begin
  update_company_request = jobs::UpdateCompanyRequest.new company: company_updated
  company_updated = talent_solution_client
                    .patch_project_company(company_name, update_company_request)
  puts "Company updated: #{company_updated.to_json}"
  return company_updated
rescue StandardError => e
  puts "Exception occurred while updating company: #{e}"
end

Update Company with updateMask

Java

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/** Updates a company. */
public static Company updateCompanyWithFieldMask(
    String companyName, String fieldMask, Company companyToBeUpdated) throws IOException {
  try {
    // String foo = String.format("?updateCompanyFields=%s",fieldMask);
    UpdateCompanyRequest updateCompanyRequest =
        new UpdateCompanyRequest().setUpdateMask(fieldMask).setCompany(companyToBeUpdated);

    Company companyUpdated =
        talentSolutionClient
            .projects()
            .companies()
            .patch(companyName, updateCompanyRequest)
            .execute();

    System.out.println("Company updated: " + companyUpdated);
    return companyUpdated;
  } catch (IOException e) {
    System.out.println("Got exception while updating company");
    throw e;
  }
}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

def update_company_with_field_mask(client_service, company_name,
                                   company_to_be_updated, field_mask):
    try:
        request = {
            'company': company_to_be_updated,
            'update_mask': field_mask
        }
        company_updated = client_service.projects().companies().patch(
            name=company_name,
            body=request).execute()
        print('Company updated: %s' % company_updated)
        return company_updated
    except Error as e:
        print('Got exception while updating company with field mask')
        raise e

C#

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


public static Company UpdateCompanyWithFieldMask(string companyName, string fieldMask, Company companyToBeUpdated)
{
    try
    {
        UpdateCompanyRequest updateCompanyRequest = new UpdateCompanyRequest()
        {
            UpdateMask = fieldMask,
            Company = companyToBeUpdated
        };
        Company companyUpdated = jobServiceClient.Projects.Companies.Patch(updateCompanyRequest, companyName).Execute();
        Console.WriteLine("Company updated with updateMask: " + ToJsonString(companyUpdated));
        return companyUpdated;
    }
    catch (Exception e)
    {
        Console.WriteLine("Got exception while updating company with update mask");
        throw e;
    }
}

Go

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


// updateCompanyWithMask updates a company with specific fields.
// mask is a comma separated list of top-level fields of talent.Company.
func updateCompanyWithMask(w io.Writer, name string, mask string, companyToUpdate *talent.Company) (*talent.Company, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %v", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %v", err)
	}

	req := &talent.UpdateCompanyRequest{
		Company:    companyToUpdate,
		UpdateMask: mask,
	}
	company, err := service.Projects.Companies.Patch(name, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to update company %q with mask %q: %v", name, mask, err)
	}

	return company, nil
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/**
 * Updates a company with field mask.
 */
const updateCompanyWithFieldMask = async (
  jobServiceClient,
  companyName,
  companyToBeUpdated,
  fieldMask
) => {
  try {
    const request = {
      name: companyName,
      resource: {
        company: companyToBeUpdated,
        updateMask: fieldMask,
      },
    };

    const companyUpdated = await jobServiceClient.projects.companies.patch(
      request
    );

    console.log(`Company updated: ${JSON.stringify(companyUpdated.data)}`);
    return companyUpdated.data;
  } catch (e) {
    console.error(`Got exception while updating company with field mask! ${e}`);
    throw e;
  }
};

Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

# company_name     = "The name of the company you want to update. The format is "projects/{project_id}/companies/{company_id}""
# field_mask       = "The field mask you want to update"
# company_updated  = "The new company object to be updated"

require "google/apis/jobs_v3"

jobs = Google::Apis::JobsV3
talent_solution_client = jobs::CloudTalentSolutionService.new
# @see
# https://developers.google.com/identity/protocols/application-default-credentials#callingruby
talent_solution_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/jobs"
)

begin
  update_company_request = jobs::UpdateCompanyRequest.new company:     company_updated,
                                                          update_mask: field_mask
  company_updated = talent_solution_client
                    .patch_project_company(company_name, update_company_request)
  puts "Company updated with filedMask #{update_company_request.update_mask}. "
  puts "Updated company: #{company_updated.to_json}"
  return company_updated
rescue StandardError => e
  puts "Exception occurred while updating company with fieldMask: #{e}"
end

Best practices

Confidential companies

In cases where you want to post a confidential job, we recommend creating a separate company that mimics the company's fields, but obfuscates the displayName, externalId, and any other identifying fields.

In cases where the end employer should be anonymous (for example, the Staffing Agency use case), we recommend setting the externalId and displayName to random but unique values.