Mutations
Create, update, and delete data in your CloudCart store using GraphQL mutations.
Mutations modify data through the Admin API. Every write — creating a product, updating an order, deleting a customer — is a mutation. Mutation names are verb-first: createProduct, updateProduct, deleteProduct.
Endpoint
Mutations use the same endpoint as queries:
POST /api/gql HTTP/1.1
Host: {shop}.cloudcart.com
Authorization: Bearer cc_pat_xxxxxxxxxxxxx
Content-Type: application/jsonInput fields are snake_case
Selections in the response are camelCase (pricing { from }), but input fields keep snake_case names: url_handle, category_id, seo_title. Mixing these up is the #1 mutation error.
Creating a resource
mutation {
createProduct(input: {
name: "Wireless Headphones"
price: 129.99
sku: "WH-100"
active: yes
}) {
id
name
pricing { from }
}
}The response returns the fields you selected from the newly created object:
{
"data": {
"createProduct": {
"id": "1204",
"name": "Wireless Headphones",
"pricing": { "from": 129.99 }
}
}
}CreateProductInput accepts much more — description, seo_title, category_ids, tag_ids, variants, draft, publish_date… Discover the full input with cloudcart app schema --search CreateProductInput.
Updating a resource
Pass the id plus only the fields you're changing:
mutation {
updateProduct(id: 42, input: {
name: "Wireless Headphones Pro"
active: yes
}) {
id
name
flags { active }
}
}Prices are updated on variants or in bulk
UpdateProductInput intentionally has no price field — prices live on variants. To change prices, update the variant, or use the bulk mutation below for many products at once.
Deleting a resource
mutation {
deleteProduct(id: 42)
}Variables
Same pattern as queries — keep dynamic data out of the query string:
mutation CreateProduct($input: CreateProductInput!) {
createProduct(input: $input) {
id
name
}
}{
"query": "mutation CreateProduct($input: CreateProductInput!) { createProduct(input: $input) { id name } }",
"variables": { "input": { "name": "Cotton T-Shirt", "price": 24.99, "active": "yes" } }
}Bulk operations
For mass changes (prices, discounts, categories, status flags across many products) don't loop single mutations — use the async productsBulk* family:
mutation {
productsBulkAdjustPrice(
selector: { categoryId: 5 }
change: { op: PERCENT_DELTA, value: -10 }
) {
jobId
queuedCount
}
}The mutation returns immediately with a jobId; poll bulkOperationStatus(jobId) until the job completes. Selectors target productIds, a categoryId, a vendorId, or a tagName — the server resolves the scope in one pass, far faster than any client-side loop.
Validate before you write
Mutations change real store data. Preflight them:
cloudcart app validate --query '...'— schema check without executing (CLI docs)- The Dev MCP server validates every mutation your AI assistant writes
- Test against a staging store before pointing automation at production