Andrew Mercer
on this page

The example throughout is calling an Elasticsearch cluster with an API key. The same pattern works for any REST API.

Create a collection

  1. Click the Bruno logo (the dog) at the top left, or the ⋯ menu, and choose Create Collection.
  2. Name the collection and choose a location. Bruno creates a directory with that name, holding a bruno.json and one .bru file per request.
  3. Click Create.

To share the collection or keep it under version control, put that directory in a Git repo.

Create an environment and variables

Variables keep URLs and credentials out of individual requests, and let you switch between clusters, such as dev and prod, by changing the environment.

  1. Use the environment dropdown at the top right: Configure → Create, then name the environment (for example dev).
  2. Add the variables:
Name Value Secret
URL https://<elasticsearch-endpoint>:9200 no
API_KEY ApiKey <encoded-api-key> yes
  1. Click Save, and select the environment in the dropdown.

Tick Secret for any credential. Secret values are encrypted and stored locally by Bruno, not written into the collection's environment file, so they don't end up in Git. Values that aren't marked secret are saved in plain text under environments/<name>.bru in the collection directory.

Set headers once, for the whole collection

You don't have to add the same headers to every request. Headers set on the collection are inherited by every request in it, including requests you create later.

  1. Open the collection's Settings (click the collection name, or ⋯ → Settings).
  2. In the Headers tab, add: * Authorization: {{API_KEY}} * Content-Type: application/json
  3. Save.

Alternatively, put the API key in the collection's Auth tab (mode API Key, header name Authorization, value {{API_KEY}}) and leave only Content-Type in Headers.

In both cases, each request's Auth tab should be set to Inherit, which is the default for new requests.

Create a request

  1. Right-click the collection (or ⋯) and choose New Request.
  2. Give it a name (for example license) and enter the URL using the variable: {{URL}}/_license
  3. Click Create.

Hover over {{URL}} in the URL bar to see the value it resolves to in the selected environment. A variable shown in red isn't defined in the current environment.

Check the Headers tab. The collection headers are inherited, so there's nothing to add here unless this request needs something extra.

Send and save

  • Click the → arrow (or press Ctrl + Enter) to send the request.
  • Press Ctrl + S (or click the save icon) to save it to its .bru file.