Anchor to companyCreatecompany
companyCreate
mutation
Requires access scope or
access scope. Also: The API client must be installed on a Shopify Plus store.
Creates a company.
Anchor to Arguments
Arguments
- Anchor to inputinput•Company
Create requiredInput! The fields to use when creating the company.
Was this section helpful?
Anchor to CompanyCreatePayload returnsCompanyCreatePayload returns
- Anchor to companycompany•
The created company.
- Anchor to userErrorsuser•
Errors [BusinessCustomer non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CompanyCreate($input: CompanyCreateInput!) {
companyCreate(input: $input) {
company {
id
name
externalId
mainContact {
id
customer {
id
email
firstName
lastName
}
}
contacts(first: 5) {
edges {
node {
id
customer {
email
firstName
lastName
}
}
}
mutation CompanyCreate($input: CompanyCreateInput!) {
companyCreate(input: $input) {
company {
id
name
externalId
mainContact {
id
customer {
id
email
firstName
lastName
}
}
contacts(first: 5) {
edges {
node {
id
customer {
email
firstName
lastName
}
}
}
}
contactRoles(first: 5) {
edges {
node {
id
name
}
}
}
locations(first: 5) {
edges {
node {
id
name
shippingAddress {
firstName
lastName
address1
city
province
zip
country
}
}
}
}
}
userErrors {
field
message
code
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation CompanyCreate($input: CompanyCreateInput!) { companyCreate(input: $input) { company { id name externalId mainContact { id customer { id email firstName lastName } } contacts(first: 5) { edges { node { id customer { email firstName lastName } } } } contactRoles(first: 5) { edges { node { id name } } } locations(first: 5) { edges { node { id name shippingAddress { firstName lastName address1 city province zip country } } } } } userErrors { field message code } } }",
"variables": {
"input": {
"company": {
"name": "Postal Cards Inc",
"externalId": "01456606-0001"
},
"companyLocation": {
"name": "Ottawa Postal Cards",
"shippingAddress": {
"firstName": "Avery",
"lastName": "Brown",
"address1": "150 Elgin Street",
"address2": "8th Floor",
"city": "Ottawa",
"zoneCode": "ON",
"zip": "K2P 1L4",
"countryCode": "CA"
},
"billingSameAsShipping": true
},
"companyContact": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CompanyCreate($input: CompanyCreateInput!) {
companyCreate(input: $input) {
company {
id
name
externalId
mainContact {
id
customer {
id
email
firstName
lastName
}
}
contacts(first: 5) {
edges {
node {
id
customer {
email
firstName
lastName
}
}
}
}
contactRoles(first: 5) {
edges {
node {
id
name
}
}
}
locations(first: 5) {
edges {
node {
id
name
shippingAddress {
firstName
lastName
address1
city
province
zip
country
}
}
}
}
}
userErrors {
field
message
code
}
}
}`,
{
variables: {
"input": {
"company": {
"name": "Postal Cards Inc",
"externalId": "01456606-0001"
},
"companyLocation": {
"name": "Ottawa Postal Cards",
"shippingAddress": {
"firstName": "Avery",
"lastName": "Brown",
"address1": "150 Elgin Street",
"address2": "8th Floor",
"city": "Ottawa",
"zoneCode": "ON",
"zip": "K2P 1L4",
"countryCode": "CA"
},
"billingSameAsShipping": true
},
"companyContact": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
}
},
},
);
const data = await response.json();
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 CompanyCreate($input: CompanyCreateInput!) {
companyCreate(input: $input) {
company {
id
name
externalId
mainContact {
id
customer {
id
email
firstName
lastName
}
}
contacts(first: 5) {
edges {
node {
id
customer {
email
firstName
lastName
}
}
}
}
contactRoles(first: 5) {
edges {
node {
id
name
}
}
}
locations(first: 5) {
edges {
node {
id
name
shippingAddress {
firstName
lastName
address1
city
province
zip
country
}
}
}
}
}
userErrors {
field
message
code
}
}
}
QUERY
variables = {
"input": {
"company": {
"name": "Postal Cards Inc",
"externalId": "01456606-0001"
},
"companyLocation": {
"name": "Ottawa Postal Cards",
"shippingAddress": {
"firstName": "Avery",
"lastName": "Brown",
"address1": "150 Elgin Street",
"address2": "8th Floor",
"city": "Ottawa",
"zoneCode": "ON",
"zip": "K2P 1L4",
"countryCode": "CA"
},
"billingSameAsShipping": true
},
"companyContact": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
}
}
response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation CompanyCreate($input: CompanyCreateInput!) {
companyCreate(input: $input) {
company {
id
name
externalId
mainContact {
id
customer {
id
email
firstName
lastName
}
}
contacts(first: 5) {
edges {
node {
id
customer {
email
firstName
lastName
}
}
}
}
contactRoles(first: 5) {
edges {
node {
id
name
}
}
}
locations(first: 5) {
edges {
node {
id
name
shippingAddress {
firstName
lastName
address1
city
province
zip
country
}
}
}
}
}
userErrors {
field
message
code
}
}
}`,
"variables": {
"input": {
"company": {
"name": "Postal Cards Inc",
"externalId": "01456606-0001"
},
"companyLocation": {
"name": "Ottawa Postal Cards",
"shippingAddress": {
"firstName": "Avery",
"lastName": "Brown",
"address1": "150 Elgin Street",
"address2": "8th Floor",
"city": "Ottawa",
"zoneCode": "ON",
"zip": "K2P 1L4",
"countryCode": "CA"
},
"billingSameAsShipping": true
},
"companyContact": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
}
},
},
});
Input variables
JSON{
"input": {
"company": {
"name": "Postal Cards Inc",
"externalId": "01456606-0001"
},
"companyLocation": {
"name": "Ottawa Postal Cards",
"shippingAddress": {
"firstName": "Avery",
"lastName": "Brown",
"address1": "150 Elgin Street",
"address2": "8th Floor",
"city": "Ottawa",
"zoneCode": "ON",
"zip": "K2P 1L4",
"countryCode": "CA"
},
"billingSameAsShipping": true
},
"companyContact": {
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
}
}
Response
JSON{
"companyCreate": {
"company": {
"id": "gid://shopify/Company/1059559575",
"name": "Postal Cards Inc",
"externalId": "01456606-0001",
"mainContact": {
"id": "gid://shopify/CompanyContact/1059341835",
"customer": {
"id": "gid://shopify/Customer/1073339466",
"email": "avery.brown@example.com",
"firstName": "Avery",
"lastName": "Brown"
}
},
"contacts": {
"edges": [
{
"node": {
"id": "gid://shopify/CompanyContact/1059341835",
"customer": {
"email": "avery.brown@example.com",
"firstName": "Avery",