> ## Documentation Index
> Fetch the complete documentation index at: https://weaverse.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Weaverse component configuration uses `settings`. `inspector` is deprecated; never generate it.
> Weaverse Hydrogen themes use React Router v7: import from `react-router`, never `react-router-dom` or `@remix-run/*`.
> Before using any code sample, read `@weaverse/hydrogen` in the project's `package.json`: 6.x and 5.x import from different entries and use different type names, so code for one does not build on the other.
> `@weaverse/hydrogen` 6 (Shopify Hydrogen 2026.10 and later, the version these docs show) imports from `@weaverse/hydrogen/react-router` and uses `Weaverse*` types such as `WeaverseComponentProps`, `WeaverseComponentLoaderArgs` and `WeaverseComponentSchema`; the root `@weaverse/hydrogen` entry only exports `createSchema()`, data helpers and types.
> `@weaverse/hydrogen` 5.x (Hydrogen 2026.4 and earlier) imports everything from `@weaverse/hydrogen` and uses `HydrogenComponentProps`, `ComponentLoaderArgs` and `HydrogenComponentSchema`. On a 5.x project, convert samples to these names. Upgrade to 6 only when asked (`npx @weaverse/cli@latest migrate v6`, plus the Hydrogen 2026.10 upgrade). Do not mix major versions.
> Next.js themes use `@weaverse/hydrogen` 6.2.0 or later: import client and shared code from `@weaverse/hydrogen/next` and server-only code from `@weaverse/hydrogen/next/server`. `@weaverse/next` is deprecated; never install or import it.
> For live project data (pages, theme settings, translations), use the Weaverse MCP server: https://weaverse.io/docs/developer-tools/weaverse-mcp

# Shopify Admin API Proxy

> Call Shopify Admin GraphQL through Weaverse with shop-scoped keys, installed app scopes, rate limits, and safe mutation checks.

# Shopify Admin API Proxy

The Admin API Proxy forwards a Shopify Admin GraphQL query or mutation through Weaverse to the Shopify shop associated with the key. Weaverse uses the connected app installation's OAuth access token; it does not transform or cache the GraphQL response.

Use it only from a trusted server for shop-scoped reads or reviewed automation. Never expose the key in browser code.

## Authentication and Authority

Send a bearer token to:

```text theme={null}
POST https://studio.weaverse.io/api/admin-graphql
```

The route accepts Weaverse token types `shopify` and `content_api`. It rejects `agent_cli` and other narrower token types.

A valid key identifies one Weaverse shop. Shopify authority comes from the connected Weaverse app installation's currently granted Admin API scopes—not from an unrestricted capability on the key. Manage those scopes in **Weaverse Dashboard → Settings → Shopify Admin API Proxy → Manage Scopes**.

> [!WARNING]
>
> A successful token lookup proves neither the expected shop nor the scope required by a specific GraphQL field. Read the shop identity and installed scopes before planning a mutation.

## Protect the Key

Keep `WEAVERSE_API_KEY` in a dedicated, untracked server environment file with owner-only `0600` permissions. Load it through the server runtime. Never print the value or paste it into a prompt, command line, documentation, diff, client bundle, or log.

```typescript theme={null}
const ADMIN_GRAPHQL_URL = "https://studio.weaverse.io/api/admin-graphql";
const apiKey = process.env.WEAVERSE_API_KEY;

if (!apiKey) {
  throw new Error("WEAVERSE_API_KEY is not configured");
}

async function adminGraphql<T>(query: string, variables = {}) {
  const response = await fetch(ADMIN_GRAPHQL_URL, {
    method: "POST",
    headers: {
      Authorization: ["Bearer", apiKey].join(" "),
      "Content-Type": "application/json",
    },
    body: JSON.stringify({query, variables}),
  });
  const data = await response.json();

  if (!response.ok) {
    throw new Error(`Admin API Proxy failed with HTTP ${response.status}`);
  }

  return data as T;
}
```

Do not include the key in a URL. The proxy accepts it only through the `Authorization` header.

## Verify Shop and Installed Scopes

Make this harmless read before other operations:

```graphql theme={null}
query VerifyProxyAuthority {
  shop {
    name
    primaryDomain {
      url
    }
  }
  currentAppInstallation {
    accessScopes {
      handle
    }
  }
}
```

Confirm that the returned shop is the intended target and that `accessScopes` contains the minimum scope required by the proposed operation. Re-read after a merchant changes scopes.

## Request Format

Send JSON with a required `query` string and optional `variables` object:

| Field | Type | Required | Description |
| - | - | - | - |
| `query` | `string` | Yes | A Shopify Admin GraphQL query or mutation |
| `variables` | `object` | No | Variables referenced by the operation |

The proxy passes both fields to Shopify as-is. Validate operations against the current Shopify Admin GraphQL schema; proxy access does not prove that a field or mutation exists.
A successful response is Shopify's `data` object directly, not a `{data, errors}` envelope. The current server client turns top-level GraphQL `errors` into a thrown, sanitized `500` proxy error. Mutation payload `userErrors` remain in the returned data and must be checked by the caller.

## Scope Management

The Manage Scopes screen reads the active scopes from Shopify's `currentAppInstallation.accessScopes` and starts Shopify's scope-grant flow when the merchant requests more access.

The installed app marks these scopes as required:

| Scope | Capability |
| - | - |
| `read_content` | Read Shopify articles, blogs, and pages |
| `read_files` | Read files |
| `write_files` | Upload and manage files |
| `read_metaobject_definitions` | Read metaobject definitions |
| `read_products` | Read products, variants, and collections |
| `read_themes` | Read theme data |
| `write_themes` | Modify theme assets |

Optional scopes include pairs such as `read_orders`/`write_orders`, `read_customers`/`write_customers`, `read_inventory`/`write_inventory`, and `read_shipping`/`write_shipping`. The Dashboard's current Manage Scopes list is authoritative.

Request the minimum scope for the exact operation. Adding scopes changes the connected Shopify app installation and requires merchant authorization.

> [!WARNING]
>
> Do not claim that Shopify Markets country/language/currency settings or Customer Account post-logout URIs are mutable through this proxy until the exact current Shopify Admin GraphQL operation has been schema-verified. If no verified operation exists, stop and hand the step to an authorized Shopify Admin operator.

## Rate and Timeout Limits

The proxy enforces **1,000 requests per hour per token** and a **15-second timeout** for each Shopify GraphQL operation.

Successful responses and `429 Too Many Requests` responses include rate-limit headers:

| Header | Description |
| - | - |
| `X-RateLimit-Limit` | Maximum requests per window (`1000`) |
| `X-RateLimit-Remaining` | Requests remaining in the current window |
| `X-RateLimit-Reset` | Window reset timestamp |
| `Retry-After` | Seconds to wait; present on `429` |

A query that exceeds 15 seconds currently returns the proxy's sanitized server-error response. Reduce the selection or paginate; do not retry an unchanged expensive query in a tight loop.

## Safe Mutation Sequence

**1. Inspect current state**

Run the identity/scope probe, then read the exact Shopify resource that may change. Keep the original identifiers and values for comparison.

**2. Review a minimum mutation**

Validate the mutation against the current Shopify schema, confirm its required installed scope, and prepare only the fields that must change. Prefer an idempotent operation whose repeat execution is a no-op after the desired state exists.

**3. Approve at the point of risk**

Obtain explicit approval immediately before destructive, permission, publication, or other high-impact mutations. A prior read or general request to investigate is not mutation approval.

**4. Inspect every error channel**

Check the HTTP status and proxy error envelope. The proxy maps top-level GraphQL `errors` to a sanitized `500`; do not treat that as a retryable success. For a mutation that returns HTTP 200, inspect its operation-specific `userErrors` before accepting the result.

**5. Read back exact state**

Query the same resource by its stable identifier and compare exact fields with the reviewed target. Only then verify the affected storefront route and behavior.

## Error Handling

| Status or field | Meaning | Action |
| - | - | - |
| `401` | Missing, invalid, expired, or rejected token type | Verify the server-side key; `agent_cli` is not accepted |
| `404` | The associated shop is missing or the app is uninstalled | Stop and verify the intended shop installation |
| `429` | Per-token hourly limit reached | Wait for `Retry-After` |
| `500` | Top-level GraphQL error, sanitized proxy/upstream failure, or timeout | Treat the operation as failed; inspect server diagnostics without exposing secrets |
| Mutation `userErrors` in HTTP 200 data | The mutation payload rejected business input | Treat the mutation as failed; do not infer success from HTTP 200 |

## Storefront Verification

After an approved localization-related change, verify the actual storefront surface: supported and unsupported market routes, Storefront country/language/currency context, `<html lang>` and `dir`, localized links and redirects, cart buyer identity, checkout continuity, canonical URLs, `hreflang`, and sitemap output.

> [card] [Markets and Localization](https://weaverse.io/docs/features/markets-localization.md)
>
> Configure the canonical market contract and production checks.

> [card] [Content API](https://weaverse.io/docs/content-api/overview.md)
>
> Read and update shop-scoped Weaverse project content.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.