Announcements
Why Use SCAPI
Base URL and Request Formation
Quick Start
Promotion Types and Requirements
Agentic MCP Shopper Tools Quick Start (Pilot)
URL Mapping
SCAPI Specifications
B2C Commerce Release Notes
Ask the Community
The getUrlMapping endpoint allows headless storefronts to support localized, user-friendly URLs based on URL rules and URL redirects set up in Business Manager. This endpoint helps you to increase your site traffic and improve site navigation.
For example, you identify “new arrivals” as a valuable search term and you add a route (URL: www.example.com/new-arrivals) to your storefront. You can use a rule in Business Manager to map that URL to a category list page for new arrivals. Then you can use the getUrlMapping endpoint to apply the rule when a shopper:
www.example.com/new-arrivalsBefore you use the getUrlMapping endpoint:
sfcc.shopper-seo scope to a SLAS API Client.In this example, we use a cURL command to call the getUrlMapping endpoint to resolve this URL that a shopper clicked or typed in: www.example.com/blue/new-arrivals/tops.
1curl "https://$CODE.api.commercecloud.salesforce.com/site/shopper-seo/v1/organizations/$ORG/url-mapping' \
2 --get \
3 --header "Authorization: Bearer $TOKEN" \
4 --data "siteId=$SITE" \
5 --data "locale=en-GB" \
6 --data-urlencode "urlSegment=blue/new-arrivals/tops"The URL’s path without a leading slash is passed as the urlSegment parameter.
As shown in the response, the URL is mapped to a category called new-arrivals-tops:
1{
2 "refinements": {
3 "refinementColor": "Blue"
4 }
5 "resourceId": "new-arrivals-tops",
6 "resourceType": "category"
7}You can also use the getUrlMapping endpoint to apply URL redirects that you set up in Business Manager. This helps you to carry out temporary product launches or seasonal campaigns and improve shopper experience.
For more information, see:
In this example, we use a cURL command to call the getUrlMapping endpoint to redirect this URL that a shopper clicked or typed in: www.example.com/cyber-monday. For instance, you had a campaign for a past Cyber Monday. That page accumulated significant SEO rank that you want to keep. You set up a redirect to temporarily send shoppers from the old Cyber Monday URL to a new campaign page you’re launching until your new Cyber Monday page is available.
1curl "https://$CODE.api.commercecloud.salesforce.com/site/shopper-seo/v1/organizations/$ORG/url-mapping' \
2 --get \
3 --header "Authorization: Bearer $TOKEN" \
4 --data "siteId=$SITE" \
5 --data "locale=en-GB" \
6 --data-urlencode "urlSegment=cyber-monday"In this sample response, the urlSegment redirects to a category called sales. The statusCode 302 tells you that it’s a temporary redirect and the destinationUrl field tells you where to redirect the shopper. Since copySourceParams is set to true (Yes in Business Manager), the additionalUrlParams value set to utm_source=newsletter is added to the end of the destinationUrl. In this example, we use UTM (Urchin Tracking Module) parameters to track marketing efforts and indicate that traffic came from a newsletter.
1{
2 "additionalUrlParams": "utm_source=newsletter",
3 "copySourceParams": true,
4 "destinationUrl": "/sales?lang=en_GB&utm_source=newsletter",
5 "resourceId": "sales",
6 "resourceType": "category",
7 "statusCode": "302"
8}resourceId and resourceType will refer to the Commerce Cloud object (product, category, or content asset) and destination type that you configured in Business Manager.additionalUrlParams, copySourceParams, destinationUrl, and statusCode. The presence of these fields means that a redirect is configured for the requested path. For more details, see the getUrlMapping API reference.resourceId and resourceTypeare null.destinationUrl is based on your configuration in Business Manager: it’s either a calculated value indicating the Commerce object (product, category, or content asset) URL or your specified URI. Note that an object’s path may not necessarily match your headless storefront URLs but can be used as a reference for calculating your desired redirect path.These best practices apply to integrating getUrlMapping into a headless site:
To resolve URL conflicts for generated URLs, see:
You can customize the behavior of the getUrlMapping endpoint by using these hooks:
dw.shop.seo.url_mapping.beforeGETdw.shop.seo.url_mapping.modifyGETResponseSee Customization with Hooks and the hooks for getUrlMapping in the Hook List.