Repository navigation
Description
A Spin Service would be a way to hide external service configuration (auth, most notably) from guest code. It would be nice to represent these as named wasi:http/client imports (or similar), but for compatibility these services could be accessed via outbound HTTP, addressed via magic hostname, e.g. <service-name>.svc.spin.internal.
[variables]
github_token = { required = true, secret = true }
[service.github-api]
url = "https://api.github.com"
headers = { user-agent = "My-Github-App" }
[service.github.authentication]
type = "bearer"
value = "{{ github_token }}"
[component.github-client]
source = "github-client.wasm"
services = { github = "github-api" }
# Implied:
# allowed_outbound_hosts = ["https://github.svc.spin.internal"]The above service would be invoked as https://github.svc.spin.internal/<path>, which would be translated to https://api.github.com/<path> with auth / headers injected.
The authentication section could be an open enum, with some baked-in types:
[service.ye-olde-service.authentication]
type = "basic"
username = "ye-olde-user"
password = "{{ ye_olde_password }}"
[service.never-heard-of-bearer-tokens.authentication]
type = "header"
header_name = "X-Api-Key"
value = "{{ api_key }}"Other auth types could be supported directly by embedders with custom types or via middleware (below).
Extensions
While the initial design is driven mostly by common HTTP service auth patterns, services could be extended in a number of directions:
Middleware
More complex auth types (and other functionality) could be provided by outbound service middleware:
[service.uses-oauth]
url = "https://api.uses-oauth.com"
middleware = [{ component = "oauth-middleware" }]
[component.oauth-middleware]
source = "oauth-middleware.wasm"
variables = { client_id = "...", client_secret = "..." }We might want to support only a single middleware component until dependency isolation lands.
Typed HTTP Services
External services could be associated with schema definitions to drive generation of service bindings:
Very rough sketch!
[service.openapi-service]
url = "https://api.openapi-service.com"
schema = { type = "openapi", path = "openapi_service.yaml" }
[service.grpc-service]
url = "https://api.grpc-service.com"
schema = { type = "grpc", path = "grpc_service.proto" }
[component.api-client]
source = "api-client.wasm"
services = ["openapi-service", "grpc-service"]
[component.api-client.dependencies]
"openapi-service:client" = { service_bindings = "openapi-service" }
"grpc-service:client" = { service_bindings = "grpc-service" }And More...
- Non-HTTP services; intercept
wasi:socketsinstead ofwasi:http - Remote component-backed services; generated RPC bindings for inter-component calls
Activity
radu-matei commentedon Nov 25, 2026
I'm very aligned with this direction; we've wanted something like this for a while, thank you for the proposal.
I'd like to explore if we can use services as a starting point for unifying how we treat and describe internal application concerns with external application concerns:
spin.toml), or functionality that Spin itself provides (configured per-component inspin.toml). This includes the Wasm components defined inspin.tomltoday, together with all the built-in capabilities of Spin: application variables, KV stores, SQLite databases, AI models, and their consumption by Wasm components.spin.tomlin the current directory). This could be origins, external APIs, databases, storage buckets, AI models provided by external APIs that are used, depended on, or consumed by one or more components of the application, and are usually expressed and passed to components as opaque variables.While it is possible and we have evidence of developers building self-contained Spin applications (where the entirety of a particular workload is built and deployed as one Spin application), my experience indicates that the majority of developers build Spin applications that are part of a larger system, and components of the Spin application must almost always interact with the rest of the system.
To me, this is an important reason to consider external application concerns (following the categorization above) and whether we have the opportunity to improve how these applications are built, configured, deployed, or inspected.
Today, the interaction between internal and external concerns is implicit in component code and configuration. We can pass a component an endpoint and credentials, then allow outbound access, but the application definition tells us relatively little about what the dependency represents, or how it fits into the application.
I think services could make these dependencies an explicit part of the application definition. They could give developers a way to describe parts of the surrounding system their application needs, and give Spin (and deployment platforms) enough information to help configure, connect, validate, or inspect those relationships.
Declaring an external service would describe how an application consumes it; it would not imply that Spin becomes responsible for deploying or managing it.
I would also like to explore whether the same model could describe functionality supplied within the application or Spin itself. We already have ways to configure and grant access to things like KV stores or SQLite databases, but each has its own convention. A service abstraction seems like an opportunity to bring these into a consistent model for describing what functionality is available, how it's configured, and which components consume it.
Over time, this would give us a path to unify existing functionality and make it easier for platforms to introduce new capabilities.
Rough sketch along the lines of the example you have above. Take this example conceptually, and consider the declaration / binding / configuration pattern rather than the actual syntax:
In this sketch,
github-clientwould call https://my-github-api.svc.spin.internal/... and openmy-kv-cachethrough the existing KV API. The bindings give the component access to the declared services under those local names. The external HTTP dependency and the built-in KV capability follow the same declaration and access model, while retaining their respective interfaces.HTTP seems like a great first candidate. It would make sense to keep the initial implementation focused on HTTP while considering the broader changes.
lann commentedon Nov 25, 2026
One of my goals here is to keep scope under control for a first revision, but I agree that we should keep an eye on the opportunity to unify different service types (perhaps in a v3 manifest format?).
Some thoughts on generalized services:
For the above sketch you can think of each
serviceas having an implicittype = "http". That may even be a reasonable default in the long term but we would have the option to maketypemandatory in a v3 manifest. Different flavors of service types:Abstractly, a service can represent a plain-name instance import, e.g.
(import "my-service" (implements "some:package/interface") ...)<name>.svc.spin.internalas one common convention.wasi:keyvalue,spin:sqlite), service names would map directly to those names."Middleware" is somewhat HTTP-specific; another way to frame it would be as an optional reference to a single
adapter(?) component, which would export the service's interface, implemented in terms of host imports.