Give each key one store
An API key created under Settings > AI tools > Access keys carries the selected store and its organization. Bily limits discovery responses to that scope and rejects requests for another store or organization. Create a separate key when a workload needs another store. Never reuse one customer key as a multi-store credential. Bily rejects an older settings-generated fallback key that lacks organization and store scope. Select the intended store and regenerate the key before using the customer API or MCP.Confirm the available scope
CallGET /context without an organization parameter when you use a standard store-scoped key. Bily returns the authenticated user and a scoped organizations array. Each visible store appears under its organization.
Use the optional organizationId query only when an identity can access multiple organizations and the request deliberately selects one. The organization must remain inside the credential’s allowed scope.
Make an organization-scoped request
GET /stores uses the organization recorded on a scoped key or selected in a session. When neither supplies an organization, send this header:
GET /context or GET /organizations. Bily confirms that the authenticated identity belongs to the supplied organization.
Make a store-scoped request
Store-scoped paths include{storeUrl} or the canonical {resourceUrl} used by analytics and platform endpoints. Copy the exact url from GET /context or GET /stores. Encode it as a URL path segment when necessary.
x-bily-organization-id. Its value must match the store’s organization.
Match the resource type
Analytics and platform endpoints identify a resource by its canonical hostname. Website resources support acquisition reporting. Shopify resources also support commerce reporting. Product metrics, product metadata, customer lifetime value, cohorts, and commerce-only query datasets require a Shopify resource. Website requests for these operations or product filters return400 with code resource_type_mismatch. Changing a stored label does not change the hostname’s resource type.
Resolve scope errors
To protect privacy, Bily may return
404 instead of revealing that a store exists under another organization.
Store scope with every job
For scheduled and multi-tenant jobs, store these values together:GET /context again after a membership or connection changes. Never copy identifiers between customer accounts.