Intents API
The Intents API lets you invoke built-in customer account workflows like updating payment methods on subscription contracts. Use this API to trigger standard Shopify actions from your extension without rebuilding complex flows from scratch.
Intents can be invoked using either a structured object or a string query format. Both approaches return an activity handle that you can await to track the workflow's completion.
The Intents API currently supports a single resource: opening the payment method replacement flow for subscription contracts. See Supported resources for details.
The Intents API currently supports a single resource: opening the payment method replacement flow for subscription contracts. See Supported resources for details.
Anchor to Use casesUse cases
- Update subscription payment methods: Open the built-in payment method replacement flow for a subscription contract, letting customers swap their vaulted card without leaving the extension.
- Trigger standard account workflows: Invoke Shopify-managed experiences for common tasks instead of building custom UI for each one.
- Track workflow outcomes: Await the result of
shopify.intents.invoke()to detect when a workflow completes and update your extension's UI accordingly.
Supported targets
- customer-account.
footer. render-after - customer-account.
order-index. announcement. render - customer-account.
order-index. block. render - customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. action. menu-item. render - customer-account.
order. action. render - customer-account.
order. page. render - customer-account.
page. render - customer-account.
profile. addresses. render-after - customer-account.
profile. announcement. render - customer-account.
profile. block. render - customer-account.
profile. company-details. render-after - customer-account.
profile. company-location-addresses. render-after - customer-account.
profile. company-location-payment. render-after - customer-account.
profile. company-location-staff. render-after - customer-account.
profile. payment. render-after
Supported targets
- customer-account.
footer. render-after - customer-account.
order-index. announcement. render - customer-account.
order-index. block. render - customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. action. menu-item. render - customer-account.
order. action. render - customer-account.
order. page. render - customer-account.
page. render - customer-account.
profile. addresses. render-after - customer-account.
profile. announcement. render - customer-account.
profile. block. render - customer-account.
profile. company-details. render-after - customer-account.
profile. company-location-addresses. render-after - customer-account.
profile. company-location-payment. render-after - customer-account.
profile. company-location-staff. render-after - customer-account.
profile. payment. render-after
Anchor to invoke methodinvoke method
The invoke method opens a Shopify-managed workflow for managing resources. The method returns a promise that resolves to an activity handle you can await to get the workflow result.
The method accepts either:
- String query:
${action}:${type},${value}with optional second parameter () - Object: Properties for
action,type,value, anddata
IntentQueryOptions parameters
Optional parameters for the invoke method when using the string query format:
value(string): The resource identifier (for example,). Required when opening existing resources.data({ [key: string]: unknown }): Additional context required by specific resource types. For example, subscription contracts require.
- Anchor to invokeinvokeinvoke{ (query: IntentQuery): Promise<IntentActivity>; (intentURL: string, options?: IntentQueryOptions): Promise<IntentActivity>; }{ (query: IntentQuery): Promise<IntentActivity>; (intentURL: string, options?: IntentQueryOptions): Promise<IntentActivity>; }requiredrequired
Triggers a built-in Shopify workflow by passing a structured intent object. Specify an
action(such as'open'), a resourcetype, and an optionalvalueidentifying the resource. Returns a promise that resolves to anyou can use to track completion.Triggers a built-in Shopify workflow using a URL string in the format
action:type[,value][?params]. Use this overload when composing intents from dynamic strings rather than structured objects.
IntentQuery
Structured description of an intent to invoke. Use this object form when programmatically composing an intent at runtime. It pairs an action (verb) with a resource type and optional inputs.
- action
Verb describing the operation to perform on the target resource. Common values include `create` and `open`. The set of allowed verbs is intent-specific; unknown verbs will fail validation.
IntentAction - data
Optional input payload passed to the intent. Used to seed forms or supply parameters. The accepted shape is intent-specific. For example, replacing a payment method on a subscription contract requires `{ field: 'paymentMethod' }`.
Record<string, unknown> - type
The resource type (such as `shopify/SubscriptionContract`).
string - value
The resource identifier for edit actions (such as `gid://shopify/SubscriptionContract/123`).
string
IntentAction
Allowed actions that can be performed by an intent. Common actions include: - `'create'`: Initiate creation of a new resource. - `'open'`: Modify an existing resource.
'create' | 'open' | stringIntentActivity
Activity handle for tracking intent workflow progress.
- complete
A Promise that resolves when the intent workflow completes, returning the response.
Promise<IntentResponse>
IntentResponse
Result of an intent activity. Discriminated union representing all possible completion outcomes for an invoked intent.
SuccessIntentResponse | ErrorIntentResponse | ClosedIntentResponseSuccessIntentResponse
Successful intent completion. - `code` is always `'ok'` - `data` contains the output payload
- code
Always `'ok'` for a successful response.
'ok' - data
Validated output payload produced by the workflow. The shape is intent-specific. Consumers should narrow by `code === 'ok'` before accessing.
Record<string, unknown>
ErrorIntentResponse
Failed intent completion. - `code` is always `'error'` - `message` summarizes the failure - `issues` optionally provides structured details for validation or field-specific problems following the Standard Schema convention
- code
Set to `'error'` when present. This property is optional.
'error' - issues
Structured details for validation or field-specific problems, following the Standard Schema convention.
{ path?: string[]; message?: string; }[] - message
A human-readable summary of the failure.
string
ClosedIntentResponse
User dismissed or closed the workflow without completing it. Distinct from `error`: no failure occurred, the activity was simply abandoned by the user.
- code
Always `'closed'` when the user dismissed the workflow without completing it.
'closed'
IntentQueryOptions
Options for URL-based invocations. When invoking via URL syntax, `action` and `type` are parsed from the string. This companion type captures the remaining optional fields that can be provided alongside the URL.
- data
Optional input payload passed to the intent. Used to seed forms or supply parameters. The accepted shape is intent-specific. For example, replacing a payment method on a subscription contract requires `{ field: 'paymentMethod' }`.
Record<string, unknown> - value
The resource identifier for edit actions (such as `gid://shopify/SubscriptionContract/123`).
string
Anchor to Supported resourcesSupported resources
The following table shows which resource types you can open and what values you need to pass for value and data.
Anchor to Subscription contractSubscription contract
Subscription contracts represent recurring billing agreements. Use this to open the payment method replacement flow for an active subscription.
| Action | Type | Value | Data |
|---|---|---|---|
open | shopify/SubscriptionContract | gid://shopify/SubscriptionContract/{id} | { field: 'paymentMethod' } |
Anchor to IntentResponseIntent Response
The result returned when an intent workflow completes. Check the code property to determine the outcome:
'ok': The customer completed the workflow successfully.'error': The workflow failed due to validation or other errors.'closed': The customer cancelled without completing.
SuccessIntentResponse | ErrorIntentResponse | ClosedIntentResponseSuccessIntentResponse | ErrorIntentResponse | ClosedIntentResponseClosedIntentResponse
- Anchor to codecodecode'closed''closed'requiredrequired
Always
'closed'when the user dismissed the workflow without completing it.
ErrorIntentResponse
- Anchor to codecodecode'error''error'
Set to
'error'when present. This property is optional.- Anchor to issuesissuesissues{ path?: string[]; message?: string; }[]{ path?: string[]; message?: string; }[]
Structured details for validation or field-specific problems, following the Standard Schema convention.
- Anchor to messagemessagemessagestringstring
A human-readable summary of the failure.
SuccessIntentResponse
- Anchor to codecodecode'ok''ok'requiredrequired
Always
'ok'for a successful response.- Anchor to datadatadataRecord<string, unknown>Record<string, unknown>requiredrequired
Validated output payload produced by the workflow.
The shape is intent-specific. Consumers should narrow by
code === 'ok'before accessing.
Anchor to Best practicesBest practices
- Prefer object syntax for dynamic intents: When building the intent parameters programmatically from variables, use the structured object format. It's easier to read and less error-prone than string interpolation.
- Use string syntax for static intents: When the action, type, and value are known at write time, the compact string format keeps your code concise.
- Always await the activity handle: Call
await activity.completeto detect when the workflow finishes. This lets you refresh data or update UI in response to the customer's action. - Check the response code before acting on results: Verify that
response.codeis'ok'before usingresponse.data. The workflow may be cancelled or fail, and your extension should handle those cases gracefully.
Anchor to LimitationsLimitations
- Intent workflows pause your extension until completion. You can't run other operations while an intent is open.
- The workflow UI can't be customized. Field order, labels, and validation messages are controlled by Shopify and can't be modified.