Can't find a way to create companyContactRole through admin graphql

Hi,

i am trying to create a company contact and make him an admin of a specific location.

I already created a company contact and now i’m trying to assign that contact to company location and give him the admin rights.

I’m trying to use this:

https://shopify.dev/api/admin-graphql/2022-10/mutations/companyContactAssignRole

I have both companyContactId and companyLocationId but i’m missing the companyContactRoleId.

I assumed that i need to create the companyContactRole first and then assign it to the location and contact but i’m unable to find any mutation for company contact role creation.

Not sure what i’m missing here, any help would be appreciated.

@Dynamoox thanks but I’m looking for a way to do it via the API. Adding customers through Shopify dashboard is not the issue here.

@Dynamoox can you point out the documentation page which contains it? I would appreciate it :slightly_smiling_face:

I suffered getting this figured out.

Please enjoy the solution.

This is how you get your system generated default Contact Roles graphql ids.

Here is the solution I came up with - BONUS LEVEL - pro tip .

$this_num_company_id = “9686758493”;

$GQLQuery_CompanySelect =

“{ companies(first:10, query:" id:'” . $this_num_company_id . “’ ") { edges { node { contactRoles(first: 5){ nodes{ name id }} } } } }”;

Results in :

[data] => stdClass Object
(
[companies] => stdClass Object
(
[edges] => Array
(
[0] => stdClass Object
(
[node] => stdClass Object
(
[contactRoles] => stdClass Object
(
[nodes] => Array
(
[0] => stdClass Object
(
[name] => Location admin
[id] => gid://shopify/CompanyContactRole/1964564564
)

[1] => stdClass Object
(
[name] => Ordering only
[id] => gid://shopify/CompanyContactRole/1964564532
)

) // end contactRoles nodes

) // end contactRoles

) // end companies edges node[0]

) // end companies edges

) // end companies

) // end data