> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Connect

Connect a Shopify account with the Zernio API, every step with code.

Connect a merchant's Shopify store to a Zernio profile through Shopify's OAuth install. The [connecting accounts guide](/guides/connecting-accounts#shopify) covers the flow and [scopes](/guides/connecting-accounts#scopes) in general.

## Send the merchant to Shopify

Call `GET /v1/connect/shopify` with `profileId` and `shop` on [Get Shopify OAuth connect URL](/connect/get-shopify-connect-url). Send the merchant to the returned `authUrl`.

After they approve the install, Shopify calls Zernio's callback and the account is created on your profile.

The browser lands on your `redirect_url` with `connected`, `profileId`, `accountId` and `username` (the store's `myshopify.com` domain) added. Keep the `accountId`: the merchant may approve a different store than the one in `shop`.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data: connect } = await zernio.connect.getShopifyConnectUrl({
  query: {
    profileId: '66a1f0c2a4b9d3e8f1a2b3c4',
    shop: 'your-store.myshopify.com',
    redirect_url: 'https://myapp.com/connected'
  }
});
// Send the merchant's browser to connect.authUrl
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

connect = client.connect.get_shopify_connect_url(
    profile_id="66a1f0c2a4b9d3e8f1a2b3c4",
    shop="your-store.myshopify.com",
    redirect_url="https://myapp.com/connected"
)
# Send the merchant's browser to connect["authUrl"]
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/connect/shopify?profileId=66a1f0c2a4b9d3e8f1a2b3c4&shop=your-store.myshopify.com&redirect_url=https://myapp.com/connected" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "authUrl": "https://your-store.myshopify.com/admin/oauth/authorize?client_id=...",
  "state": "..."
}
```

`shop` accepts the full domain or the bare `your-store` prefix.

`redirect_url` must be an absolute http(s) URL or an app scheme such as `myapp://callback`. A relative path is rejected with `400 INVALID_REDIRECT_URL`.

Connecting the same profile to the same store again refreshes the stored token in place instead of creating a second account.

## Custom-app Admin token

To skip the browser flow, the merchant creates a custom app in their Shopify admin (Settings, then Apps and sales channels, then Develop apps).

The app needs the `read_content`, `write_content`, `read_products` and `write_products` scopes. The merchant hands you its Admin API access token, which starts with `shpat_`.

Exchange it with [Connect a Shopify store with a custom-app Admin token](/connect/connect-shopify-with-token):

```bash
curl -X POST "https://zernio.com/api/v1/connect/shopify/token" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "profileId": "66a1f0c2a4b9d3e8f1a2b3c4",
    "shop": "your-store.myshopify.com",
    "accessToken": "shpat_..."
  }'
```

Response (`200`):

```json
{
  "account": {
    "_id": "66b2e19d8c3f5a7e9d0b1c2d",
    "platform": "shopify",
    "username": "your-store.myshopify.com",
    "displayName": "Your Store",
    "profileId": "66a1f0c2a4b9d3e8f1a2b3c4"
  }
}
```

`shop` is required here too: an Admin token does not identify its own store.

Zernio validates the token against the store before saving anything, and custom-app tokens do not expire.

## OAuth scopes

| Scope | What it enables |
|-------|-----------------|
| `read_content` | Read the store's blogs and articles |
| `write_content` | Create, update and delete blogs and articles |
| `read_products` | List and read products, variants and images |
| `write_products` | Edit product fields and variant prices |
| `write_pixels` | Install [tracking pixels](/platforms/shopify/tracking-pixels) on the storefront |
| `read_customer_events` | Let those pixels receive the store's customer events |

Zernio requests no access to customers or payments at install.

Commerce features such as stock, discounts, markets or orders use optional scopes that the merchant approves separately (see [Commerce](/platforms/shopify/commerce#commerce)). Orders take `read_orders` and `read_all_orders` (see [Read orders](/platforms/shopify/commerce#read-orders)).

**Older stores.** Stores connected before 16 September 2026 hold a content-only grant.

On those, every Products endpoint answers `403 insufficient_permissions` until the merchant goes through the [connect](/platforms/shopify/connect) flow again. The consent screen shows the two product scopes, and the existing account keeps its id.

## When the merchant uninstalls

Shopify invalidates its own token the moment the app is uninstalled and sends Zernio the `app/uninstalled` webhook. There is nothing to revoke and nothing to call.

Zernio deactivates that store's account. It stops appearing in `GET /v1/accounts` as active, and any request naming its `accountId` fails.

Scheduled articles on the account are held through the disconnect grace period rather than deleted at once. A reinstall inside that window brings them back with the account.

Reinstalling runs the same [connect](/platforms/shopify/connect) flow and issues a fresh token.