mutation
Crystallize Mutation Skill
Create, update, and manage data in Crystallize using GraphQL mutations. This skill covers all write operations across the Core API (admin/content management) and Shop API (cart/checkout).
Consultation Approach
Before writing mutations, understand the context. Ask clarifying questions:
- What are you trying to create or update? Products, documents, folders, customers, orders?
- Do you have the tenant identifier and access tokens? Mutations require authentication.
- Where in the flow are you? Content/catalog management → Core API. Cart/checkout/orders → Shop API.
- Do you need to update individual fields or create items from scratch?
updateComponentfor fields,createfor new items. - Should changes be published immediately? Creating an item doesn't publish it — that's a separate step.
- Are you doing a one-off change or a bulk import? Single mutations vs mass operations.
Decision Tree
What do you need to do?
│
├─ Create/update catalogue items (products, documents, folders)
│ ├─ Create new item → Core API: product/document/folder.create
│ ├─ Update a field on an item → Core API: item.updateComponent
│ ├─ Add/update product variants → Core API: product.setVariants
│ ├─ Publish/unpublish → Core API: item.publish / item.unpublish
│ └─ Delete an item → Core API: item.delete
│
├─ Manage customers
│ ├─ Create individual → Core API: customer.createIndividual
│ ├─ Create organization → Core API: customer.createOrganization
│ └─ Update customer → Core API: customer.update
│
├─ Manage orders
│ ├─ Create order from cart → Shop API /order: createFromCart
│ ├─ Create order directly (POS, import) → Shop API /order: create
│ ├─ Add/update payments → Shop API /order: addPayments / setPayments
│ ├─ Track order through pipeline → Shop API /order: addToStage
│ └─ Update order metadata → Shop API /order: setMeta (or Core API: order.update)
│
├─ Cart & checkout (storefront)
│ ├─ Create/hydrate a cart → Shop API: hydrate
│ ├─ Modify cart items → Shop API: addItems / removeItems / setCartItem
│ ├─ Set customer & addresses → Shop API: setCustomer / setAddresses
│ └─ Convert cart to order → Shop API: cartAsOrderIntent
│
└─ Bulk operations
└─ Use mass operation JSON via the content-model skill's output format
API Selection
| Use Case | API | Why |
|---|---|---|
| Creating/editing items, shapes, customers | Core API | Full read/write, admin-level access |
| Cart management, checkout | Shop API /cart |
Edge-distributed cart lifecycle |
| Order creation, payments, pipelines | Shop API /order |
Full order CRUD after checkout |
| Bulk shape + item creation | Core API via mass operations | Ordered multi-step creation |
API Endpoints & Authentication
| API | Endpoint | Auth Required | Use For |
|---|---|---|---|
| Core | https://api.crystallize.com/@{tenant} |
Yes | Items, shapes, customers |
| Shop /cart | https://shop-api.crystallize.com/{tenant}/cart |
Yes (JWT) | Cart management, checkout |
| Shop /order | https://shop-api.crystallize.com/{tenant}/order |
Yes (JWT) | Order CRUD, payments |
Core API
POST https://api.crystallize.com/@{tenant-identifier}
Note the @ prefix before the tenant identifier.
curl -X POST 'https://api.crystallize.com/@your-tenant' \
-H 'Content-Type: application/json' \
-H 'X-Crystallize-Access-Token-Id: YOUR_TOKEN_ID' \
-H 'X-Crystallize-Access-Token-Secret: YOUR_TOKEN_SECRET' \
-d '{"query": "mutation { ... }"}'
Generate access tokens in the Crystallize App under Settings > Access Tokens. See the permissions skill for scoping tokens.
Shop API
POST https://shop-api.crystallize.com/{tenant-identifier}/cart
Authorization: Bearer YOUR_JWT_TOKEN
No @ prefix for the Shop API endpoint.
Common Workflow Patterns
Create a product end-to-end
- Create the product with shape and parent folder
- Set variants with SKU, pricing, stock, and images
- Update components (description, specs, media)
- Publish the item
See Core API Reference for each mutation.
Update content on an existing item
- Query the item to confirm its ID and current state (use the query skill)
- Call
item.updateComponentfor each field you need to change - Publish if the item should go live immediately
Each updateComponent call targets a single component by componentId. You can update multiple components by sending multiple mutations.
Checkout flow (storefront)
- Hydrate a cart with product SKUs and quantities
- Add/remove items as the customer shops
- Set customer info and addresses
- Place the cart to lock it for payment
- Create the order from the placed cart
See Shop API Cart Mutations for steps 1-4, and Shop API Order Mutations for step 5.
Bulk import / mass operations
For creating many items at once, use the mass operations JSON format produced by the content-model skill. Mass operations follow a 4-phase ordering:
- Pieces (dependencies first)
- Shapes
- Topic maps
- Items
Error Handling
The Core API uses union return types. Always include error fragments in your mutations:
mutation {
product {
create(input: { ... }) {
... on Product {
id
name
}
... on BasicError {
errorName
message
}
}
}
}
Common error types: BasicError, UnauthorizedError, ItemNotFoundError, OrderDoesNotBelongToTenantError.
Using the JS API Client
For JavaScript/TypeScript projects, use @crystallize/js-api-client instead of raw HTTP calls. It provides typed helpers for all mutations. See the js-api-client skill for setup and usage.
import { createClient } from "@crystallize/js-api-client";
const api = createClient({
tenantIdentifier: "your-tenant",
accessTokenId: "...",
accessTokenSecret: "...",
});
// Use pimApi for Core API mutations
const result = await api.pimApi(mutationString, variables);
Output Format
When generating mutations for the user, produce:
- GraphQL mutations with clear variable placeholders (e.g.,
"your-tenant-id","item-id") - Variable definitions when the mutation uses GraphQL variables
- Expected response shape so the user knows what to look for
If the user is working in a JS/TS project, prefer generating code using @crystallize/js-api-client helpers.
References
- Core API Mutations - Item CRUD, variants, components, customers, publish/unpublish, delete, media uploads
- Shop API Cart Mutations - Cart hydration, item management, checkout flow, cart lifecycle
- Shop API Order Mutations - Order creation (from cart or direct), payments, pipelines, metadata
More from crystallizeapi/ai
pricing
Design and implement pricing strategies in Crystallize using Price Variants, Price Lists, Promotions, and Markets. Use when recommending pricing structures, setting up multi-currency support, configuring B2B/B2C pricing, planning promotional campaigns, defining markets, or advising on pricing architecture for commerce projects. Also use when the user asks about currencies, multi-market setup, was/now pricing, strikethrough prices, wholesale pricing, coupon codes, discount campaigns, tiered pricing, cart discounts, tax-inclusive/exclusive pricing, or any question about how prices work in Crystallize — even if they don't explicitly mention "pricing".
15query
Query Crystallize APIs for product data, content, and commerce information. Use this skill when fetching product catalogs, listing items, searching products, filtering by attributes, browsing categories, building storefronts, retrieving cart data, reading orders or customers, building admin dashboards, getting item details by path or ID, implementing faceted navigation, paginating results, or reading any data from Crystallize. Covers Core API, Discovery API, Catalogue API, and Shop API queries. Also use when the user asks about GraphQL queries against Crystallize, reading product variants, getting component data, checking stock levels, or any read operation — even if they don't explicitly say "query".
13content-model
Design content models in Crystallize using Shapes, Pieces, Components, Topic Maps, and Grids. Create product structures, define document types, build taxonomies, organize catalogue items, design relationships between items, implement classification bridges, configure item relations with shape restrictions, and architect scalable data models. Use when modeling content, creating shapes, defining components, building taxonomies, designing relationship patterns, implementing semantic bridges, configuring product variants, or structuring catalogue hierarchies.
13information-architecture
Design folder hierarchies and navigation structures in Crystallize. Create category trees, organize products and content, plan URL structures, and build scalable information architectures. Use when designing storefront navigation, category pages, collection structures, content organization, mega menus, or site maps. Also use when the user mentions organizing their catalog, planning their store structure, restructuring navigation, or asks how to organize products or content in Crystallize — even if they don't explicitly say "information architecture.
13js-api-client
Use the @crystallize/js-api-client package to interact with Crystallize APIs in JavaScript/TypeScript. Use when setting up the Crystallize API client, configuring credentials, calling catalogueApi/discoveryApi/pimApi/shopCartApi, working with high-level helpers for catalogue fetching, cart management, orders, customers, subscriptions, navigation, or using any helper from the @crystallize/js-api-client npm package.
12permissions
Manage user roles, permissions, and access control in Crystallize. Use when configuring field-level permissions (read-only or hidden fields for specific roles), managing user roles and team access, setting up access tokens with specific scopes, controlling who can view/edit specific content areas or component fields, designing role-based access for multi-team tenants, or planning permission strategies for content workflows.
11