bruno-endpoint-creation
Bruno Endpoint Creation
Bruno-specific patterns for creating .bru endpoint files. Assumes familiarity with REST conventions.
Environment Configuration
Development (Local.bru):
vars {
baseUrl: http://localhost:3001
linkId:
apiKey: dev_api_key_change_in_production
}
Production/Staging — use vars:secret for sensitive data:
vars {
baseUrl: https://api.yourdomain.com
linkId:
}
vars:secret [
apiKey
]
Collection-Level Authentication
Set auth once in collection.bru, then inherit in all endpoints:
auth {
mode: bearer
}
auth:bearer {
token: {{apiKey}}
}
Individual endpoints inherit with auth: inherit:
post {
url: {{baseUrl}}/api/v1/resources
body: json
auth: inherit
}
Override per-endpoint only when auth differs from the collection.
Request Structure
meta {
name: "Create Resource"
type: http
seq: 1
}
post {
url: {{baseUrl}}/api/v1/resources
body: json
auth: inherit
}
body:json {
{
"resource": {
"field1": "value1",
"field2": "value2"
}
}
}
params:path {
id: {{resourceId}}
}
params:query {
page: 1
limit: 20
sort: created_at
order: desc
}
Scripting API
Post-response — extract data for subsequent requests:
script:post-response {
if (res.status === 201 && res.body && res.body.id) {
bru.setVar("resourceId", res.body.id);
}
}
Pre-request — generate dynamic data:
script:pre-request {
const timestamp = Date.now();
bru.setVar("uniqueEmail", `test-${timestamp}@example.com`);
}
Key difference:
bru.setVar()— runtime variables (temporary, current collection run only)bru.setEnvVar()— environment variables (persists, visible in Environment tab)
Use bru.setVar() for ephemeral values like extracted IDs from test runs.
Documentation Block
docs {
Create a new resource in the system.
**Required Fields:**
- field1: Description
- field2: Description
**Optional Fields:**
- optional_field: Description
}
Collection Folder Structure
Bruno Collection/
├── Environments/
│ ├── Local.bru
│ ├── Staging.bru
│ └── Production.bru
├── Authentication/
│ ├── Login.bru
│ └── Refresh Token.bru
├── Resources/
│ ├── List Resources.bru
│ ├── Get Resource.bru
│ ├── Create Resource.bru
│ ├── Update Resource.bru
│ └── Delete Resource.bru
└── Health/
└── Health Check.bru
More from steveclarke/dotfiles
md-to-pdf
Convert markdown files to PDF using Chrome. Use when user wants to render markdown to PDF, print a document, or create a shareable PDF from markdown. Triggers on "markdown to pdf", "render to pdf", "pdf from markdown", "print this markdown".
75readme-writer
Write and revise READMEs and technical documentation for software projects. Scores readability with Flesch-Kincaid and vocabulary profiling. Use when writing, revising, or reviewing a README, README.md, or project documentation. Triggers on "write readme", "improve readme", "readme review", "documentation writing".
56time-tracking
Manage time tracking with Toggl or Clockify. Use when user asks about time tracking, timers, timesheets, logging hours, starting/stopping work, checking what's running, viewing time entries, or creating manual entries. Triggers on "toggl", "clockify", "time tracking", "timer", "timesheet", "log time", "track time", "hours worked".
52feature-spec
Creates concise technical specification documents through guided architectural decisions, system contracts, and technical design. Produces a spec.md covering API design, data models, frontend architecture, and integration points without implementation details.
49feature-requirements
Creates structured requirements documents through guided discovery, practical scoping, and consolidated output. Produces a single requirements.md with entities, workflows, constraints, and acceptance criteria following the established feature development process.
491password
Fetch secrets and create/manage 1Password items via CLI. Use when needing API keys, tokens, or credentials, or when storing new secrets. Ask user for the 1Password secret reference (op://Vault/Item/field format) rather than the actual secret.
49