Skip to content

RPC v2 CBOR

smithy.protocols#rpcv2Cbor is Smithy’s binary protocol. Messages are encoded as CBOR and carried over HTTP POST requests on a fixed path derived from the service and operation names. Status: Preview.

See Protocol Status for current conformance numbers.

No extra Maven dependency beyond the codegen plugin — smithy.protocols shapes are bundled with the Smithy CLI.

PurposePackages
ClientNSmithy.Client, NSmithy.Codecs.Cbor, NSmithy.Protocols.RpcV2Cbor
Server (ASP.NET Core)NSmithy.Server.AspNetCore, NSmithy.Codecs.Cbor, NSmithy.Protocols.RpcV2Cbor

Apply @rpcv2Cbor to the service. Operations do not carry @http traits — the protocol maps each operation to a fixed POST /service/{Service}/operation/{Operation} path automatically:

$version: "2"
namespace example.weather
use smithy.protocols#rpcv2Cbor
@rpcv2Cbor
service Weather {
version: "2026-01-01"
operations: [GetCity]
}
operation GetCity {
input := {
@required
cityId: String
}
output := {
@required
name: String
}
errors: [NoSuchResource]
}
@error("client")
structure NoSuchResource {
@required
resourceType: String
}

rpcv2Cbor is RPC-style over a fixed path with a CBOR body. The bodies below are shown in CBOR diagnostic notation; on the wire they are binary CBOR (structures are encoded as indefinite-length maps):

POST /service/Weather/operation/GetCity HTTP/1.1
Host: api.example.com
Smithy-Protocol: rpc-v2-cbor
Content-Type: application/cbor
Accept: application/cbor
{"cityId": "123"} # CBOR, diagnostic notation
HTTP/1.1 200 OK
Smithy-Protocol: rpc-v2-cbor
Content-Type: application/cbor
{"name": "Seattle"} # CBOR, diagnostic notation

The path is always /service/{Service}/operation/{Operation} — operations carry no @http traits. Errors carry a __type discriminator in the CBOR body.

The generated handler and client are identical to every other HTTP-JSON/CBOR protocol — see Client & Server Usage. The CBOR codec is wired up automatically; the only thing specific to this protocol is the @rpcv2Cbor trait and the binary wire format on the fixed operation path.

A complete working server+client example is available in examples/rpcv2cbor.