Data model & scopes

What CODGuard stores, and which Shopify permissions each capability needs.

Access scopes

read_customers · read_orders · read_themes · unauthenticated_read_product_listings · unauthenticated_write_checkouts · write_delivery_customizations · write_discounts · write_draft_orders · write_inventory · write_order_edits · write_orders · write_payment_customizations · write_products

Each maps to a capability you can point at. Draft orders and order edits exist for partial payments; discounts for prepaid incentives; payment and delivery customizations for rule enforcement at checkout.

Stored entities

All records are keyed by the shop's myshopify domain.

ModelPurpose
ShopConfigOne row per shop. OTP settings, payment modes, COD rules, RTO thresholds, plan, Function IDs.
CodRuleFine-grained COD rules evaluated in priority order.
OtpVerificationEach OTP issued — hashed code, attempts, expiry, verified flag.
VerifiedCustomerPhone numbers that have cleared an OTP. Powers the returning-customer skip.
WebhookReceiptIdempotency lock, claimed before processing a webhook.
PaymentModeSelectionThe mode a shopper chose, linked to the resulting order.
MessageTemplateEditable message body per event and channel.
MessageLogEvery message sent, with delivery status and the rate billed at send time.
CodVerificationWhatsApp COD-confirmation links.
AddressCorrectionRequestAddress-correction magic-link flow and its status.
RtoRiskScorePer-order score, band, signal breakdown and action taken.
PaymentDiscountShopify discount and fee resources created per shop.
AbandonedCheckoutCheckouts that started OTP but never converted.
CustomerListPer-shop blacklist and whitelist by phone or email.
UsageRecordMonthly usage counters per billing month.
DailyAnalyticsDaily roll-up for the dashboard.
AppEventLogImmutable audit trail of every business event.
ErrorLogStructured log of every caught exception and API failure.
ModalSettingsThe storefront modal's styling and copy.
PartialOrderDeposit-paid orders and the real cart items to swap in.

Phone numbers are stored in E.164, encrypted at rest, and masked throughout the admin UI.