REGEXVAULTv2.0
Security/API Keys & Tokens
Verified Safe

Shopify Access Token Regex for JavaScript

/^shpat_[a-fA-F0-9]{32}$|^shpca_[a-fA-F0-9]{32}$|^shppa_[a-fA-F0-9]{32}$|^shpss_[a-fA-F0-9]{32}$/

What this pattern does

This page provides a comprehensive, battle-tested regular expression for matching shopify access token, ported and verified for JavaScript. In security-sensitive code, using an unverified regex can open the door to both false positives and denial-of-service attacks. The snippet below is ready to drop into your JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.

Javascript Implementation

Javascript
// Shopify Access Token
// ReDoS-safe | RegexVault — Security > API Keys & Tokens

const shopifyAccessTokenRegex = /^shpat_[a-fA-F0-9]{32}$|^shpca_[a-fA-F0-9]{32}$|^shppa_[a-fA-F0-9]{32}$|^shpss_[a-fA-F0-9]{32}$/;

function validateShopifyAccessToken(input: string): boolean {
  return shopifyAccessTokenRegex.test(input);
}

// Example
console.log(validateShopifyAccessToken("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")); // true

Test Cases

Matches (Valid)
Rejects (Invalid)
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shpat_short
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SHPAT_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
shpat_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d

When to use this pattern

This pattern is drawn from the Security > API Keys & Tokens category and carries a ReDoS-safe certification. That matters for JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

Shopify tokens are store-scoped. A leaked token only affects the specific store it was issued for. Rotate immediately and review audit logs in Shopify Partners dashboard.

Technical Notes

Shopify token prefixes: shpat_=access token, shpca_=custom app token, shppa_=partner app token, shpss_=shared secret. All are 32 hex chars after the prefix. Each is scoped to a specific store.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern