arazzo: 1.0.1
info:
title: Shopify Upsert Customer Then Place Order
summary: Find or create a customer by email, then place an order for that customer.
description: >-
A resilient checkout-capture flow. The workflow searches for a customer by
email and branches: an existing customer is reused as-is while a missing one
is created. Either path converges on placing an order tied to that customer
email and reading the order back. This avoids duplicate customers when the
same buyer returns. Every step spells out its request inline so the flow can
be read and executed without opening the underlying OpenAPI description.
version: 1.0.0
x-realizes-capability-ids:
- BC-420.10
- BC-520.40
x-capability-derivation:
method: 'deterministic join: sourceDescriptions -> per-tag OpenAPI -> tag/capability edge. No classification at this step.'
min_confidence: 0.7
sources:
- capability_id: BC-420.10
capability_name: Customer Data Management
spec: shopify-customers-api-openapi.yml
confidence: 0.85
- capability_id: BC-520.40
capability_name: Order Fulfilment Management
spec: shopify-orders-api-openapi.yml
confidence: 0.78
model: Turbo EA Capabilities by Vincent Verdet — Turbo EA, https://github.com/vincentmakes/turbo-ea-capabilities, CC BY 4.0
sourceDescriptions:
- name: customersApi
url: ../openapi/shopify-customers-api-openapi.yml
type: openapi
- name: ordersApi
url: ../openapi/shopify-orders-api-openapi.yml
type: openapi
workflows:
- workflowId: upsert-customer-then-order
summary: Reuse or create a customer by email, then place and confirm an order.
description: >-
Resolves the customer by email (reusing or creating), places an order for
that email, and reads the order back.
inputs:
type: object
required:
- email
- variantId
- quantity
properties:
email:
type: string
description: Customer email used to resolve the customer and stamp the order.
firstName:
type: string
description: First name used when creating a new customer.
lastName:
type: string
description: Last name used when creating a new customer.
variantId:
type: integer
description: The product variant ID to order.
quantity:
type: integer
description: Quantity of the variant.
steps:
- stepId: findCustomer
description: Search for an existing customer by email, returning at most one match.
operationId: searchCustomers
parameters:
- name: query
in: query
value: "email:$inputs.email"
- name: limit
in: query
value: 1
successCriteria:
- condition: $statusCode == 200
outputs:
matchedCustomerId: $response.body#/customers/0/id
onSuccess:
- name: customerExists
type: goto
stepId: placeOrder
criteria:
- context: $response.body
condition: $.customers.length > 0
type: jsonpath
- name: customerMissing
type: goto
stepId: createCustomer
criteria:
- context: $response.body
condition: $.customers.length == 0
type: jsonpath
- stepId: createCustomer
description: Create a new customer when no existing one matched the email.
operationId: createCustomer
requestBody:
contentType: application/json
payload:
customer:
email: $inputs.email
first_name: $inputs.firstName
last_name: $inputs.lastName
successCriteria:
- condition: $statusCode == 201
outputs:
customerId: $response.body#/customer/id
- stepId: placeOrder
description: >-
Place an order tied to the resolved customer email containing the variant
line item.
operationId: createOrder
requestBody:
contentType: application/json
payload:
order:
email: $inputs.email
financial_status: pending
line_items:
- variant_id: $inputs.variantId
quantity: $inputs.quantity
successCriteria:
- condition: $statusCode == 201
outputs:
orderId: $response.body#/order/id
orderName: $response.body#/order/name
- stepId: getOrder
description: Read the order back to confirm it was placed.
operationId: getOrder
parameters:
- name: order_id
in: path
value: $steps.placeOrder.outputs.orderId
successCriteria:
- condition: $statusCode == 200
outputs:
order: $response.body#/order
outputs:
orderId: $steps.placeOrder.outputs.orderId
orderName: $steps.placeOrder.outputs.orderName
order: $steps.getOrder.outputs.order
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. See our Privacy Policy and
Terms.