agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/tools/postman/SKILL.md

postman

Skill15 starsChanged 42 days agoMITView on GitHub

Expert Postman assistance covering API collection design, pre-request scripts, Newman CI/CD test automation, mock servers, and environment variable management. Use when creating automated API test suites, running collections via Newman CLI, managing environment secrets, or generating API documentation.

  • Reads credentials
  • Installs packages

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run collections via Newman in CI/CD workflows to prevent regressions before deployment.

    line 148
  2. Distinctive:

    Commit environment files containing active production API keys to public repositories.

    line 154

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Postman

Postman is an API platform for building and using APIs, providing automated collection testing, mock servers, environment management, and Newman CLI integration for CI/CD.

When to Use

  • REST, GraphQL, & gRPC API Testing: Designing requests, inspecting headers, and verifying streaming payloads.
  • Automated CI/CD API Regression Suites: Running Postman Collections in automated pipelines using the Newman CLI.
  • Dynamic Authentication Handling: Scripting OAuth 2.0 token refreshes, HMAC signatures, and AWS SigV4 in Pre-request scripts.
  • Mock Servers & API Documentation: Creating instant mock endpoints and publishing interactive team API documentation.

Quick Start

1. Test Script in Postman

// Tests tab in Postman Request
pm.test("Status code is 200 OK", function () {
  pm.response.to.have.status(200);
});

pm.test("Response time is under 400ms", function () {
  pm.expect(pm.response.responseTime).to.be.below(400);
});

pm.test("Token returned and set in environment", function () {
  const jsonData = pm.response.json();
  pm.expect(jsonData.access_token).to.be.a("string");
  pm.environment.set("AUTH_TOKEN", jsonData.access_token);
});

2. Run via Newman CLI

npm install -g newman
newman run collection.json -e environment.json --reporters cli,junit

Core Concepts

Pre-Request Script: Automated JWT / HMAC Signature

Generating dynamic cryptographic signatures and injecting timestamps before request execution:

// Pre-request Script (PM API)
const timestamp = Math.floor(Date.now() / 1000).toString();
const apiKey = pm.environment.get("API_KEY");
const apiSecret = pm.environment.get("API_SECRET");
const requestBody = pm.request.body.raw || "";

// Generate SHA256 HMAC
const message = `${pm.request.method}\n${pm.request.url.getPath()}\n${timestamp}\n${requestBody}`;
const signature = CryptoJS.HmacSHA256(message, apiSecret).toString(
  CryptoJS.enc.Hex,
);

pm.request.headers.add({ key: "X-Auth-Key", value: apiKey });
pm.request.headers.add({ key: "X-Auth-Timestamp", value: timestamp });
pm.request.headers.add({ key: "X-Auth-Signature", value: signature });

Automated Response Assertions & Variable Extraction

Validating HTTP response code, schema, and saving output for downstream requests:

// Tests Script
pm.test("Status code is 200 OK", function () {
  pm.response.to.have.status(200);
});

pm.test("Response contains valid user session", function () {
  const json = pm.response.json();
  pm.expect(json).to.have.property("access_token");
  pm.expect(json.expires_in).to.be.above(0);

  // Propagate access token to active environment
  pm.environment.set("AUTH_TOKEN", json.access_token);
});

pm.test("Response time is under 300ms", function () {
  pm.expect(pm.response.responseTime).to.be.below(300);
});

Newman CLI Execution in CI/CD Pipeline

Executing collection tests headlessly and generating JUnit reports:

# Run Postman collection with environment and HTML/JUnit reports
npx newman run ./collections/auth-api-tests.json \
  -e ./environments/staging.postman_environment.json \
  --reporters cli,junit \
  --reporter-junit-export ./reports/newman-results.xml \
  --bail \
  --env-var "BASE_URL=https://staging-api.example.com"

Common Patterns

Pre-Request HMAC Signature Generation

Problem: API requests require timestamp and SHA-256 HMAC signature headers calculated per request.
Solution: Generate headers dynamically in the Pre-request Script tab.

const secret = pm.environment.get("API_SECRET");
const timestamp = Math.floor(Date.now() / 1000).toString();
const payload = pm.request.body.raw || "";

const message = `${timestamp}.${pm.request.method}.${payload}`;
const signature = CryptoJS.HmacSHA256(message, secret).toString();

pm.request.headers.add({ key: "X-Timestamp", value: timestamp });
pm.request.headers.add({ key: "X-Signature", value: signature });

Chained API Testing (Login -> Create -> Delete)

Problem: Execute multi-step end-to-end user workflows using dynamically extracted identifiers.
Solution: Set variables in pm.collectionVariables and trigger conditional next requests via postman.setNextRequest().

// Step 1: Capture created resource ID
const res = pm.response.json();
pm.collectionVariables.set("ITEM_ID", res.id);

// Conditionally skip to cleanup on error
if (pm.response.code !== 201) {
  postman.setNextRequest("Cleanup Endpoint");
}

Best Practices

Do:

  • Parameterize environment URLs, tenant IDs, and credentials using {{base_url}} variables.
  • Store sensitive credentials in Environment variables with type Secret to mask values from UI and exports.
  • Run collections via Newman in CI/CD workflows to prevent regressions before deployment.
  • Organize collections by domain resource with clear folder-level authorization inheritance.

Don't:

  • Hardcode raw JWT tokens or passwords directly in request headers or body payloads.
  • Commit environment files containing active production API keys to public repositories.
  • Duplicate authentication headers manually; configure Auth at the Collection level.

Troubleshooting

ErrorCauseSolution
SSL Error: Self-signed certificate in certificate chainTarget endpoint uses local dev or untrusted SSL certificateTurn off SSL certificate verification in Postman Settings > General, or pass --insecure to Newman.
Variable not substituting ({{API_URL}} remains literal)Active environment not selected in dropdown or variable misspelledEnsure environment dropdown in top-right is selected and scope matches (environment vs collectionVariables).
Newman exit code failure in CI pipelineAssertion failed in collection runCheck test summary output; run Newman with --bail to stop on first failure or inspect JUnit XML report.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.