Create professional Bruno REST API endpoint configurations with proper authentication, environment setup, and documentation. Use when setting up API testing with Bruno, creating new endpoints, or configuring collection-level authentication. Triggers on "create Bruno endpoint", "Bruno API testing", "set up Bruno collection".
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Create professional Bruno REST API endpoint configurations with proper authentication, environment setup, and documentation. Use when setting up API testing with Bruno, creating new endpoints, or configuring collection-level authentication. Triggers on "create Bruno endpoint", "Bruno API testing", "set up Bruno collection".
disable-model-invocation
true
Bruno REST API Endpoint Creation Command
Expert REST API Endpoint Configuration for Bruno
As a REST API expert, when creating Bruno endpoints, follow these proven patterns for professional API testing and documentation:
1. Environment Configuration Best Practices
Development Environment (Local.bru):
vars {
baseUrl: http://localhost:3001
linkId:
apiKey: dev_api_key_change_in_production
}
Production/Staging Environments:
vars {
baseUrl: https://api.yourdomain.com
linkId:
}
vars:secret [
apiKey
]
Key Principles:
Use plain text variables for development (easier debugging)
Use vars:secret for sensitive data in production/staging
Never hardcode sensitive values in production configs
Use descriptive variable names that match your API's naming conventions
2. RESTful Endpoint Structure
Standard CRUD Operations Pattern:
GET /api/v1/resources # List all resources
GET /api/v1/resources/:id # Get specific resource
POST /api/v1/resources # Create new resource
PATCH /api/v1/resources/:id # Update specific resource
PUT /api/v1/resources/:id # Replace specific resource
DELETE /api/v1/resources/:id # Delete specific resource
3. Authentication Configuration
Collection-Level Authentication (Recommended):
Set authentication once at the collection level in collection.bru:
Use bru.setVar() to store values in runtime variables for use across requests in the same run:
script:post-response {
// After creating a resource, store its ID in runtime variableif (res.status === 201 && res.body && res.body.id) {
bru.setVar("resourceId", res.body.id);
bru.setVar("lastCreatedAt", res.body.created_at);
}
// After listing resources, extract the first ID for subsequent operationsif (res.status === 200 && res.body && res.body.length > 0) {
bru.setVar("resourceId", res.body[0].id);
}
}
Key Difference:
bru.setEnvVar() - Stores in environment variables (persists across requests, visible in Environment tab)
bru.setVar() - Stores in runtime variables (temporary, available during current collection run)
Best Practice: Use bru.setVar() for runtime variables to avoid cluttering your environment variables with ephemeral values like extracted IDs from test runs.
script:post-response {
// Validate response structureif (res.status === 200) {
if (!res.body || typeof res.body !== 'object') {
thrownewError('Expected JSON response body');
}
if (res.body.id && typeof res.body.id !== 'string') {
thrownewError('Expected string ID in response');
}
}
}
7. Documentation Standards
Comprehensive Endpoint Documentation:
docs {
Create a new resource in the system.
**Required Fields:**
- field1: Description of required field
- field2: Another required field description
**Optional Fields:**
- optional_field: Description of optional field
**Validation Rules:**
- field1 must be between 3-50 characters
- field2 must be a valid email format
**Response:**
- 201 Created: Returns the created resource with ID
- 422 Unprocessable Entity: Returns validation errors
- 401 Unauthorized: Invalid or missing authentication
**Example Usage:**
This endpoint is typically called after user authentication
to create new resources in the system.
}
script:post-response {
if (res.timings.duration > 5000) {
console.warn('Request took longer than 5 seconds');
}
}
This comprehensive approach ensures your Bruno collections are professional, maintainable, and follow REST API best practices while providing excellent developer experience and thorough testing coverage.