Skip to main content

Bruno API Client

MailSlurp API's work well with Bruno API client. You can use MailSlurp email and SMS APIs in Bruno REST client by calling the API endpoints directly at https://api.mailslurp.com.

Authorization

Pass the x-api-key request header set to the value of your MailSlurp API Key with each request.

Tutorial

Parse responses and set variables

When you call an API endpoint, you can parse the response and set variables for use in subsequent requests.

script:post-response {
const data = res.getBody();
bru.setVar('emailAddress', data.emailAddress);
bru.setVar('inboxId', data.id);
}

Running collection

You can store your collection in a file and run it using the Bruno CLI.

For instance this collection creates an inbox and sets the emailAddress and inboxId variables for use in subsequent requests.

meta {
name: Create an inbox
type: http
seq: 2
}

post {
url: https://api.mailslurp.com/inboxes/withDefaults
body: none
auth: apikey
}

auth:apikey {
key: x-api-key
value:
placement: header
}

script:post-response {
const data = res.getBody();
bru.setVar('emailAddress', data.emailAddress);
bru.setVar('inboxId', data.id);
}

We can run it with

cd my-collection
npx @usebruno/cli run