Anchor to companyContactCreatecompany
companyContactCreate
mutation
Requires access scope or
access scope. Also: The API client must be installed on a Shopify Plus store.
Creates a company contact and the associated customer.
Anchor to Arguments
Arguments
- Anchor to companyIdcompany•
Id ID!required The ID of the company that the company contact belongs to.
- Anchor to inputinput•Company
Contact requiredInput! The fields to use to create the company contact.
Was this section helpful?
Anchor to CompanyContactCreatePayload returnsCompanyContactCreatePayload returns
- Anchor to companyContactcompany•
Contact The created company contact.
- Anchor to userErrorsuser•
Errors [BusinessCustomer non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Create a company contact
- companyContactCreate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CompanyContactCreate($companyId: ID!, $input: CompanyContactInput!) {
companyContactCreate(companyId: $companyId, input: $input) {
companyContact {
id
company {
id
name
}
customer {
id
firstName
lastName
email
}
}
userErrors {
field
message
code
}
}
}`,
{
variables: {
"companyId": "gid://shopify/Company/426793626",
mutation CompanyContactCreate($companyId: ID!, $input: CompanyContactInput!) {
companyContactCreate(companyId: $companyId, input: $input) {
companyContact {
id
company {
id
name
}
customer {
id
firstName
lastName
email
}
}
userErrors {
field
message
code
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation CompanyContactCreate($companyId: ID!, $input: CompanyContactInput!) { companyContactCreate(companyId: $companyId, input: $input) { companyContact { id company { id name } customer { id firstName lastName email } } userErrors { field message code } } }",
"variables": {
"companyId": "gid://shopify/Company/426793626",
"input": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CompanyContactCreate($companyId: ID!, $input: CompanyContactInput!) {
companyContactCreate(companyId: $companyId, input: $input) {
companyContact {
id
company {
id
name
}
customer {
id
firstName
lastName
email
}
}
userErrors {
field
message
code
}
}
}`,
{
variables: {
"companyId": "gid://shopify/Company/426793626",
"input": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation CompanyContactCreate($companyId: ID!, $input: CompanyContactInput!) {
companyContactCreate(companyId: $companyId, input: $input) {
companyContact {
id
company {
id
name
}
customer {
id
firstName
lastName
email
}
}
userErrors {
field
message
code
}
}
}`,
"variables": {
"companyId": "gid://shopify/Company/426793626",
"input": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation CompanyContactCreate($companyId: ID!, $input: CompanyContactInput!) {
companyContactCreate(companyId: $companyId, input: $input) {
companyContact {
id
company {
id
name
}
customer {
id
firstName
lastName
email
}
}
userErrors {
field
message
code
}
}
}
QUERY
variables = {
"companyId": "gid://shopify/Company/426793626",
"input": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"companyId": "gid://shopify/Company/426793626",
"input": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
}
Response
JSON{
"companyContactCreate": {
"companyContact": {
"id": "gid://shopify/CompanyContact/1059341859",
"company": {
"id": "gid://shopify/Company/426793626",
"name": "Fancy Pants Inc."
},
"customer": {
"id": "gid://shopify/Customer/1073339480",
"firstName": "Avery",
"lastName": "Brown",
"email": "avery.brown@example.com"
}
},
"userErrors": []
}
}