Skip to content

Registering External Services from code

External Services are usually configured in the Workbench, but the .NET client also exposes a programmatic API on IEventStore:

// An HTTP service with bearer token authentication and a header
await eventStore.ExternalServices.Register("CustomersApi", _ => _
.Http("https://api.example.com")
.WithBearerToken(token)
.WithHeader("X-Tenant", "acme"));
// A PostgreSQL database service
await eventStore.ExternalServices.Register("CustomersDb", _ => _
.PostgreSql("db.example.com", "customers", "postgres", password, port: 5432));

The builder also exposes WithBasicAuth, WithOAuth, MsSql, and WithOption.