Skip to main content
gRPC scripting is in Beta. Open a gRPC request and use the Script (Beta) tab to write hooks with the bru.grpc APIs.
HTTP requests in Bruno already support pre-request scripts, post-response scripts, tests, and assertions. gRPC requests now have the same kind of automation at the request level: four hooks along the call lifecycle, a read-only bru.grpc.* API, and test() / expect() on inbound messages and at the end of the call. This ships for interactive runs in the app. Collection- and folder-level gRPC scripts, Collection Runner, and CLI are out of scope. For usage examples, see gRPC APIs in the JavaScript Reference.

Lifecycle hooks

A gRPC call is a connection that exchanges messages and ends with a status. Bruno runs four hooks: Message lists are always read-only. You cannot add, replace, send, or delete messages from a script. bru.grpc.request.metadata is writable only in Before Call Start. bru.grpc.response.* is read-only and exists only in After Message Receive and After Call End. The usual bru.* helpers (variables, sendRequest, sleep, interpolate, OAuth2 credential helpers, console) work in every hook. bru.cookies.* and bru.runner.* are not available on gRPC requests.

How to add a script

  1. Open a gRPC request.
  2. Go to the Script (Beta) tab.
  3. Choose a hook and write JavaScript using the bru.grpc APIs. Autocomplete and lint cover bru.grpc.*.
  4. Send the request. Tests from After Message Receive and After Call End appear in the Tests tab.

API reference (tables)

All gRPC data lives under bru.grpc.request.* (client) and bru.grpc.response.* (server). A message is { data, timestamp }data is the protobuf payload; timestamp is epoch milliseconds (Bruno-specific). Hook abbreviations: BCS Before Call Start · BMS Before Message Send · AMR After Message Receive · ACE After Call End.

Messages

request.messages is what was transmitted, not what is authored in the UI. It is empty in Before Call Start. Singular hooks (BMS, AMR) always see one message. request.messages has many items for client-streaming and bidi; response.messages has many for server-streaming and bidi.

Metadata

Metadata entries are { key, value }. Keys ending in -bin are binary (values stored as base64). Key matching is case-insensitive. request.metadata is readable in all four hooks and writable only in BCS. response.metadata is server initial metadata. response.trailers is trailing metadata and includes grpc-status / grpc-message.

Call info and tests

What is not included

  • Changing or sending messages from a script (the connect-and-send flow is a later ticket)
  • Collection- and folder-level gRPC hooks (folder/collection scripts still run for HTTP only)
  • Collection Runner and Bruno CLI execution of gRPC scripts
Known gaps: stack traces for errors in Before Message Send / After Message Receive still need polish, and a long-running Before Call Start script has no progress UI before the connection opens.