Adminobject
Contains functions for authenticating and interacting with the Admin API.
This function can handle requests for apps embedded in the Admin, Admin extensions, or non-embedded apps.
Authenticates requests coming from the Shopify admin.
The shape of the returned object changes depending on the config.
Anchor to authenticate.admin-parametersParameters
Authenticate, run API mutation, and redirect
/app/routes/**.ts
Anchor to examplesExamples
Anchor to example-sessiontokensessionToken
Anchor to example-using-the-decoded-session-tokenUsing the decoded session token
Get user-specific data using the object.
Using the decoded session token
Anchor to example-redirectredirect
Anchor to example-redirecting-to-an-app-routeRedirecting to an app route
Use the redirect
helper to safely redirect between pages.
Anchor to example-redirecting-outside-of-shopify-adminRedirecting outside of Shopify admin
Pass in a target
option of _top
or _parent
to go to an external URL.
Redirecting to an app route
/app/routes/admin/my-route.ts
Anchor to example-sessionsession
Anchor to example-using-offline-sessionsUsing offline sessions
Get your app's shop-specific data using an offline session.
Anchor to example-using-online-sessionsUsing online sessions
Get your app's user-specific data using an online session.
Using offline sessions
Anchor to example-setting-cors-headers-for-a-admin-requestSetting CORS headers for a admin request
Use the cors
helper to ensure your app can respond to requests from admin extensions.
Setting CORS headers for a admin request
/app/routes/admin/my-route.ts
Anchor to example-using-rest-resourcesUsing REST resources
Getting the number of orders in a store using REST resources. Visit the Admin REST API references for examples on using each resource.
Anchor to example-performing-a-get-request-to-the-rest-apiPerforming a GET request to the REST API
Use admin.rest.get
to make custom requests to make a request to to the endpoint
Anchor to example-performing-a-post-request-to-the-rest-apiPerforming a POST request to the REST API
Use admin.rest.post
to make custom requests to make a request to to the customers.json
endpoint to send a welcome email
Using REST resources
Anchor to example-graphqlgraphql
Anchor to example-querying-the-graphql-apiQuerying the GraphQL API
Use admin.graphql
to make query / mutation requests.
Anchor to example-handling-graphql-errorsHandling GraphQL errors
Catch errors to see error messages from the API.
Querying the GraphQL API
Anchor to example-requirerequire
Anchor to example-requesting-billing-right-awayRequesting billing right away
Call billing.request
in the callback to immediately redirect to the Shopify page to request payment.
Anchor to example-redirect-to-a-plan-selection-pageRedirect to a plan selection page
When the app has multiple plans, create a page in your App that allows the merchant to select a plan. If a merchant does not have the required plan you can redirect them to page in your app to select one.
Anchor to example-requesting-billing-with-line-itemsRequesting billing with line items
Call billing.request
with the future flag enabled
Requesting billing right away
Anchor to example-check-what-billing-plans-a-merchant-is-subscribed-toCheck what billing plans a merchant is subscribed to
Use billing.check if you want to determine which plans are in use. Unlike require
, check
does notthrow an error if no active billing plans are present.
Check what billing plans a merchant is subscribed to
Anchor to example-requestrequest
Anchor to example-using-a-custom-return-urlUsing a custom return URL
Change where the merchant is returned to after approving the purchase using the option.
Using a custom return URL
Anchor to example-cancelcancel
Anchor to example-cancelling-a-subscriptionCancelling a subscription
Use the billing.cancel
function to cancel an active subscription with the id returned from billing.require
.