BigCommerce
Store Operations
Catalog and Inventory
GraphQL Admin API
Product URL

Product URL

Using the Catalog features of the Admin API, you can set and query product URLs for a store or a locale within a storefront channel.

Perform the following:

For a full schema, see the GraphQL Admin API reference (opens in a new tab).

Input fields

Setting or removing information requires that you specify ID fields in the input. For more information on how to specify ID fields, see Input fields.

Set product URL at the global level

The following example sets a product's URL for a store, from which channels inherit by default.

Example mutation: Set product URL at the global level
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
mutation ($input: SetProductUrlPathInput!) {
  product {
    setProductUrlPath (input: $input) {
      product {
        id
        urlPath {
          path
        }
      }
    }
  }
}
GraphQL variables
{
  "input": {
    "productId": "bc/store/product/111",
    "data" {
      "path": "/global-product-111"
    }
  }
}

Set product URL for a locale

The following example sets a product's URL for the locale within a storefront channel. These settings override global store information.

Example mutation: Set product URL for a locale
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
mutation ($input: SetProductUrlPathInput!) {
  product {
    setProductUrlPath (input: $input) {
      product {
        id
        overridesForLocale (localeContext: { channelId: "bc/store/channel/2", locale: "uk" }) {
          urlPath {
            path
          }
        }
      }
    }
  }
}
GraphQL variables
{
  "input": {
    "productId": "bc/store/product/111",
    "localeContext": {
      "channelId": "bc/store/channel/2",
      "locale": "uk"
    },
    "data" {
      "path": "/overrides-product-111"
    }
  }
}

Remove product URL for a locale

The following example removes the overrides for a product's URL. This mutation removes the overrides for the locale within the storefront channel, and the product URL defaults to its global store value.

Example mutation: Remove product URL for a locale
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
mutation ($input: RemoveProductUrlPathOverrideInput!) {
  product {
    removeProductUrlPathOverride (input: $input) {
      product {
        id
        urlPath {
          path
        }
      }
    }
  }
}
GraphQL variables
{
  "input": {
    "productId": "b/store/product/111",
    "localeContext": {
      "channelId": "bc/store/channel/2",
      "locale": "uk"
    }
  }
}

Query product URL

The following example retrieves a product's URL. You can retrieve global information for the store and overrides for a locale within a storefront channel.

Example query: Get product URL for a product
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
query {
  store {
    product (id: "bc/store/product/111") {
      id
      urlPath {
        path
      }
      overridesForLocale (localeContext: { channelId: "bc/store/channel/2", locale: "uk" }) {
        urlPath {
          path
        }
      }
    }
  }
}
Did you find what you were looking for?