Version: unstable
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } }\",\n \"variables\": {\n \"input\": {\n \"company\": {\n \"name\": \"Postal Cards Inc\",\n \"externalId\": \"01456606-0001\"\n },\n \"companyLocation\": {\n \"name\": \"Ottawa Postal Cards\",\n \"shippingAddress\": {\n \"firstName\": \"Avery\",\n \"lastName\": \"Brown\",\n \"address1\": \"150 Elgin Street\",\n \"address2\": \"8th Floor\",\n \"city\": \"Ottawa\",\n \"zoneCode\": \"ON\",\n \"zip\": \"K2P 1L4\",\n \"countryCode\": \"CA\"\n },\n \"billingSameAsShipping\": true\n },\n \"companyContact\": {\n \"email\": \"avery.brown@example.com\",\n \"firstName\": \"Avery\",\n \"lastName\": \"Brown\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n externalId\n mainContact {\n id\n customer {\n id\n email\n firstName\n lastName\n }\n }\n contacts(first: 5) {\n edges {\n node {\n id\n customer {\n email\n firstName\n lastName\n }\n }\n }\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"company\": {\n \"name\": \"Postal Cards Inc\",\n \"externalId\": \"01456606-0001\"\n },\n \"companyLocation\": {\n \"name\": \"Ottawa Postal Cards\",\n \"shippingAddress\": {\n \"firstName\": \"Avery\",\n \"lastName\": \"Brown\",\n \"address1\": \"150 Elgin Street\",\n \"address2\": \"8th Floor\",\n \"city\": \"Ottawa\",\n \"zoneCode\": \"ON\",\n \"zip\": \"K2P 1L4\",\n \"countryCode\": \"CA\"\n },\n \"billingSameAsShipping\": true\n },\n \"companyContact\": {\n \"email\": \"avery.brown@example.com\",\n \"firstName\": \"Avery\",\n \"lastName\": \"Brown\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n externalId\n mainContact {\n id\n customer {\n id\n email\n firstName\n lastName\n }\n }\n contacts(first: 5) {\n edges {\n node {\n id\n customer {\n email\n firstName\n lastName\n }\n }\n }\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"company\": {\n \"name\": \"Postal Cards Inc\",\n \"externalId\": \"01456606-0001\"\n },\n \"companyLocation\": {\n \"name\": \"Ottawa Postal Cards\",\n \"shippingAddress\": {\n \"firstName\": \"Avery\",\n \"lastName\": \"Brown\",\n \"address1\": \"150 Elgin Street\",\n \"address2\": \"8th Floor\",\n \"city\": \"Ottawa\",\n \"zoneCode\": \"ON\",\n \"zip\": \"K2P 1L4\",\n \"countryCode\": \"CA\"\n },\n \"billingSameAsShipping\": true\n },\n \"companyContact\": {\n \"email\": \"avery.brown@example.com\",\n \"firstName\": \"Avery\",\n \"lastName\": \"Brown\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n externalId\n mainContact {\n id\n customer {\n id\n email\n firstName\n lastName\n }\n }\n contacts(first: 5) {\n edges {\n node {\n id\n customer {\n email\n firstName\n lastName\n }\n }\n }\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"company\" => [\n \"name\" => \"Postal Cards Inc\",\n \"externalId\" => \"01456606-0001\",\n ],\n \"companyLocation\" => [\n \"name\" => \"Ottawa Postal Cards\",\n \"shippingAddress\" => [\n \"firstName\" => \"Avery\",\n \"lastName\" => \"Brown\",\n \"address1\" => \"150 Elgin Street\",\n \"address2\" => \"8th Floor\",\n \"city\" => \"Ottawa\",\n \"zoneCode\" => \"ON\",\n \"zip\" => \"K2P 1L4\",\n \"countryCode\" => \"CA\",\n ],\n \"billingSameAsShipping\" => true,\n ],\n \"companyContact\" => [\n \"email\" => \"avery.brown@example.com\",\n \"firstName\" => \"Avery\",\n \"lastName\" => \"Brown\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n externalId\n mainContact {\n id\n customer {\n id\n email\n firstName\n lastName\n }\n }\n contacts(first: 5) {\n edges {\n node {\n id\n customer {\n email\n firstName\n lastName\n }\n }\n }\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"company\": {\n \"name\": \"Postal Cards Inc\",\n \"externalId\": \"01456606-0001\"\n },\n \"companyLocation\": {\n \"name\": \"Ottawa Postal Cards\",\n \"shippingAddress\": {\n \"firstName\": \"Avery\",\n \"lastName\": \"Brown\",\n \"address1\": \"150 Elgin Street\",\n \"address2\": \"8th Floor\",\n \"city\": \"Ottawa\",\n \"zoneCode\": \"ON\",\n \"zip\": \"K2P 1L4\",\n \"countryCode\": \"CA\"\n },\n \"billingSameAsShipping\": true\n },\n \"companyContact\": {\n \"email\": \"avery.brown@example.com\",\n \"firstName\": \"Avery\",\n \"lastName\": \"Brown\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n externalId\n mainContact {\n id\n customer {\n id\n email\n firstName\n lastName\n }\n }\n contacts(first: 5) {\n edges {\n node {\n id\n customer {\n email\n firstName\n lastName\n }\n }\n }\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}"
input: { "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: { "data": { "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", "lastName": "Brown" } } } ] }, "contactRoles": { "edges": [ { "node": { "id": "gid://shopify/CompanyContactRole/1007033458", "name": "Location admin" } }, { "node": { "id": "gid://shopify/CompanyContactRole/1007033459", "name": "Ordering only" } } ] }, "locations": { "edges": [ { "node": { "id": "gid://shopify/CompanyLocation/966871284", "name": "Ottawa Postal Cards", "shippingAddress": { "firstName": "Avery", "lastName": "Brown", "address1": "150 Elgin Street", "city": "Ottawa", "province": "Ontario", "zip": "K2P 1L4", "country": "Canada" } } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CompanyCreate($input: CompanyCreateInput!) { companyCreate(input: $input) { company { id name mainContact { id } 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 } } }\",\n \"variables\": {\n \"input\": {\n \"company\": {\n \"name\": \"Postal Cards Inc\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"company\": {\n \"name\": \"Postal Cards Inc\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"company\": {\n \"name\": \"Postal Cards Inc\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"company\" => [\n \"name\" => \"Postal Cards Inc\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"company\": {\n \"name\": \"Postal Cards Inc\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}"
input: { "input": { "company": { "name": "Postal Cards Inc" } } }
response: { "data": { "companyCreate": { "company": { "id": "gid://shopify/Company/1059559574", "name": "Postal Cards Inc", "mainContact": null, "contactRoles": { "edges": [ { "node": { "id": "gid://shopify/CompanyContactRole/1007033456", "name": "Location admin" } }, { "node": { "id": "gid://shopify/CompanyContactRole/1007033457", "name": "Ordering only" } } ] }, "locations": { "edges": [ { "node": { "id": "gid://shopify/CompanyLocation/966871283", "name": "Postal Cards Inc", "shippingAddress": null } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CompanyCreate($input: CompanyCreateInput!) { companyCreate(input: $input) { company { id name mainContact { id } 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 } } }\",\n \"variables\": {\n \"input\": {\n \"company\": {\n \"externalId\": \"123\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"company\": {\n \"externalId\": \"123\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"company\": {\n \"externalId\": \"123\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"company\" => [\n \"externalId\" => \"123\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"company\": {\n \"externalId\": \"123\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CompanyCreate($input: CompanyCreateInput!) {\n companyCreate(input: $input) {\n company {\n id\n name\n mainContact {\n id\n }\n contactRoles(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n locations(first: 5) {\n edges {\n node {\n id\n name\n shippingAddress {\n firstName\n lastName\n address1\n city\n province\n zip\n country\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}"
input: { "input": { "company": { "externalId": "123" } } }
response: { "data": { "companyCreate": { "company": null, "userErrors": [ { "field": [ "input", "company", "name" ], "message": "Name must exist", "code": "REQUIRED" } ] } } }