mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}
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 createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id } productSetOperation { id status userErrors { code field message } } userErrors { code field message } } }",
"variables": {
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"price": 69.99
}
]
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"price": 69.99
}
]
}
},
},
);
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 createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [{"name"=>"Color", "position"=>1, "values"=>[{"name"=>"Grey"}, {"name"=>"Black"}]}],
"variants": [{"optionValues"=>[{"optionName"=>"Color", "name"=>"Grey"}], "price"=>79.99}, {"optionValues"=>[{"optionName"=>"Color", "name"=>"Black"}], "price"=>69.99}]
}
}
response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}`,
"variables": {
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"price": 69.99
}
]
}
},
},
});
use Shopify\Clients\Graphql;
$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}
QUERY;
$variables = [
"synchronous" => false,
"productSet" => [
"title" => "Winter hat",
"productOptions" => [{"name"=>"Color", "position"=>1, "values"=>[{"name"=>"Grey"}, {"name"=>"Black"}]}],
"variants" => [{"optionValues"=>[{"optionName"=>"Color", "name"=>"Grey"}], "price"=>79.99}, {"optionValues"=>[{"optionName"=>"Color", "name"=>"Black"}], "price"=>69.99}],
],
];
$response = $client->query(["query" => $query, "variables" => $variables]);