Shopify · Arazzo Workflow

Shopify Upsert Customer Then Place Order

Version 1.0.0

Find or create a customer by email, then place an order for that customer.

1 workflow 1 source API 1 provider
View Spec View on GitHub CommerceEcommercePaymentsRetailShopping CartT1ArazzoWorkflows

Provider

shopify

Workflows

upsert-customer-then-order
Reuse or create a customer by email, then place and confirm an order.
Resolves the customer by email (reusing or creating), places an order for that email, and reads the order back.
4 steps inputs: email, firstName, lastName, quantity, variantId outputs: order, orderId, orderName
1
findCustomer
searchCustomers
Search for an existing customer by email, returning at most one match.
2
createCustomer
createCustomer
Create a new customer when no existing one matched the email.
3
placeOrder
createOrder
Place an order tied to the resolved customer email containing the variant line item.
4
getOrder
getOrder
Read the order back to confirm it was placed.

Source API Descriptions

Arazzo Workflow Specification

shopify-upsert-customer-then-order-workflow.yml Raw ↑
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
sourceDescriptions:
- name: shopifyAdminRestApi
  url: ../openapi/shopify-admin-rest-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