The default endpoint is the global endpoint: "pubsub.googleapis.com".
In some cases, you may need to point the client and a regional or locational endpoint, typically designated by some prefix applied to the service name (e.g. "europe-central2-pubsub.googleapis.com". This can be accomplished by using the MakePublisherConnection overload which accepts a location parameter.
In rare cases, you may need to override the global endpoint used by the client library. This typically occurs in testing or Private Google Access cases. Use the google::cloud::EndpointOption when initializing the client library to change this default. For example, this will override the default endpoint for google::cloud::pubsub::Publisher:
namespace pubsub = ::google::cloud::pubsub;
using ::google::cloud::Options;
[](std::string const& project_id, std::string const& topic_id) {
// This service supports specifying a regional or locational endpoint prefix
// when creating the SubscriptionAdminConnection.
// For example, to connect to "europe-central2-pubsub.googleapis.com":
auto pub = pubsub::Publisher(pubsub::MakePublisherConnection(
"europe-central2", pubsub::Topic(project_id, topic_id)));
// This configuration is common with Private Google Access:
// https://cloud.google.com/vpc/docs/private-google-access
auto vpc_pub = pubsub::Publisher(pubsub::MakePublisherConnection(
pubsub::Topic(project_id, topic_id),
Options{}.set<google::cloud::EndpointOption>(
"private.googleapis.com")));
}
Follow these links to find examples for other *Client classes:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThe latest version available is 2.37.0-rc, with a range of previous versions accessible, down to 2.11.0.\u003c/p\u003e\n"],["\u003cp\u003eThe webpage provides documentation and examples for various \u003ccode\u003e*Client\u003c/code\u003e classes, including \u003ccode\u003eSubscriber\u003c/code\u003e, \u003ccode\u003eBlockingPublisher\u003c/code\u003e, \u003ccode\u003eTopicAdminClient\u003c/code\u003e, \u003ccode\u003eSubscriptionAdminClient\u003c/code\u003e, \u003ccode\u003eSchemaServiceClient\u003c/code\u003e, and \u003ccode\u003ePublisher\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can override the default endpoint used by the client library by using the \u003ccode\u003egoogle::cloud::EndpointOption\u003c/code\u003e when initializing, as demonstrated for \u003ccode\u003egoogle::cloud::pubsub::Publisher\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach version listed in the documentation has a link to its respective \u003ccode\u003epubsub-endpoint-example\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,[]]