For example, ifprojects/*/locations/*/catalogs/*/branches/1is set as default, settingSearchRequest.branchtoprojects/*/locations/*/catalogs/*/branches/default_branchis equivalent to settingSearchRequest.branchtoprojects/*/locations/*/catalogs/*/branches/1.
Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping usingprojects/*/locations/*/catalogs/*/branches/default_branchasSearchRequest.branchto route the traffic to this staging branch.
CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one.
More specifically:
PredictionService will only return product IDs from branch {newBranch}.
SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set).
UserEventService will only join events with products from branch {newBranch}.
HTTP request
POST https://retail.googleapis.com/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-24 UTC."],[],[],null,["# Method: projects.locations.catalogs.setDefaultBranch\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [IAM Permissions](#body.aspect_1)\n- [Try it!](#try-it)\n\nSet a specified branch id as default branch. API methods such as [SearchService.Search](/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/search#google.cloud.retail.v2.SearchService.Search), [ProductService.GetProduct](/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products/get#google.cloud.retail.v2.ProductService.GetProduct), [ProductService.ListProducts](/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products/list#google.cloud.retail.v2.ProductService.ListProducts) will treat requests using \"default_branch\" to the actual branch id set as default.\n\nFor example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch](/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/search#body.request_body.FIELDS.branch) to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch](/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/search#body.request_body.FIELDS.branch) to `projects/*/locations/*/catalogs/*/branches/1`.\n\nUsing multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch](/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/search#body.request_body.FIELDS.branch) to route the traffic to this staging branch.\n\nCAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one.\n\nMore specifically:\n\n- PredictionService will only return product IDs from branch {newBranch}.\n- SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set).\n- UserEventService will only join events with products from branch {newBranch}.\n\n### HTTP request\n\n`POST https://retail.googleapis.com/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n### Request body\n\nThe request body contains data with the following structure:\n\n### Response body\n\nIf successful, the response body is an empty JSON object.\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/cloud-platform`\n\nFor more information, see the [Authentication Overview](/docs/authentication#authorization-gcp).\n\n### IAM Permissions\n\nRequires the following [IAM](https://cloud.google.com/iam/docs) permission on the `catalog` resource:\n\n- `retail.catalogs.update`\n\nFor more information, see the [IAM documentation](https://cloud.google.com/iam/docs)."]]