Api client hardened

From faberlens/hardened-skills · View interactive version

Api client hardened is an AI agent skill from the GitHub repository faberlens/hardened-skills. API lifecycle management through Postman. Discover collections, run tests, monitor APIs, validate schemas, and publish documentation across the complete API development workflow.

How to use this skill

Skill file

Postman Agent Skill

Version: 1.1.0 (Phase 1 - Core API Compatibility)

API Support: Postman v10+ (with v9 graceful degradation)

๐Ÿš€ Quick Start

When you first use this skill, Claude will automatically:

  1. โœ… Validate your API key and connection
  2. ๐Ÿ“ Check your workspace configuration
  3. ๐Ÿ“Š Count your collections and resources
  4. ๐Ÿ’ก Suggest next steps if setup is incomplete

First time setup validation:

# Claude will run this automatically on first use
python scripts/validate_setup.py

Common first questions that work immediately:

๐Ÿค– Note for Claude: On first use of this skill in a conversation, ALWAYS run:

python scripts/validate_setup.py

This provides immediate diagnostics and context before proceeding with the user's request.

โœ… Network Compatibility

This skill works across multiple Claude environments with proper proxy configuration.

Where This Skill Works

| Environment | Status | Notes |

|------------|--------|-------|

| Claude Web Interface | โœ… Fully Supported | Works with configured proxy |

| Claude API (Code Execution) | โœ… Fully Supported | No network restrictions |

| Local Python Scripts | โœ… Fully Supported | Direct execution on your machine |

| Claude Desktop | โš ๏ธ Limited | Requires api.getpostman.com in network allowlist |

Proxy Configuration

The skill is designed to work with proxy environments:

How to Use This Skill

Option 1: Claude Web Interface (Recommended)

Use the skill directly in Claude web interface. The proxy is pre-configured and handles all network requests automatically.

Option 2: Claude API with Code Execution

Use the skill through the Anthropic API with code execution enabled. This has no network restrictions.

Option 3: Local Python Scripts

Run the scripts directly on your machine:

python scripts/list_collections.py
python scripts/manage_collections.py --list

Overview

This skill gives Claude the ability to interact with the Postman API to manage the complete API lifecycle. It enables discovery of workspace resources, execution of test collections, monitoring analysis, and more.

What's New in v1.1 (Phase 1)

โœจ Enhanced Error Handling: Custom exception classes with helpful resolution guidance

๐Ÿ”€ Git-like Workflows: Fork collections, create pull requests, and merge changes

๐Ÿ” Auto-Secret Detection: Automatically protects sensitive environment variables

๐Ÿ”„ Smart Duplication: Copy collections and environments with full fidelity

๐Ÿ“ก API Version Detection: Automatic detection with compatibility warnings

๐ŸŽฏ Improved Developer Experience: Simplified APIs and better error messages

Capabilities

When to Use This Skill

Claude should use this skill when you:

Prerequisites

This skill requires a .env file with your Postman API key. The .env file should be included in the skill package and is automatically loaded when any script runs.

Important: If the skill is asking for an API key, it means the .env file is either:

To fix: Ensure the skill package includes a .env file with:

POSTMAN_API_KEY=PMAK-your-key-here

Optional configuration in .env:

POSTMAN_WORKSPACE_ID=your-workspace-id
POSTMAN_RATE_LIMIT_DELAY=60
POSTMAN_MAX_RETRIES=3
POSTMAN_TIMEOUT=30
# POSTMAN_USE_PROXY=false  # Keep this false to bypass proxies (default)

Proxy Configuration (Important for Corporate Networks)

By default, the skill bypasses all proxy servers to avoid "403 Forbidden" proxy errors that commonly occur in Claude Desktop.

If you see errors like:

The skill automatically handles this - no action needed. The latest version bypasses proxies by default.

If you're in a corporate environment and need to use a proxy:

  1. Add POSTMAN_USE_PROXY=true to your .env file
  2. Ensure your proxy allows connections to api.getpostman.com

Getting Your Postman API Key

  1. Go to https://web.postman.co/settings/me/api-keys
  2. Click "Generate API Key"
  3. Copy the key (starts with PMAK-)
  4. Add it to the .env file in the skill directory

How to Use This Skill - IMPORTANT

โš ๏ธ CRITICAL: All Postman API calls MUST be made through Python scripts

This skill uses Python scripts to interact with the Postman API. DO NOT attempt to call api.postman.com directly using HTTP requests, as this will fail due to CORS (Cross-Origin Resource Sharing) restrictions in browser environments.

Always use the Python scripts:

# โœ… CORRECT: Use Python scripts
python /path/to/postman-skill/scripts/list_collections.py

# โŒ WRONG: Direct API calls will fail with CORS errors
# fetch('https://api.getpostman.com/collections')  # This will NOT work

Why this matters:

Available Workflows

Discover Resources

File: workflows/test/list_collections.md

List all collections, environments, and monitors in your workspace to understand what resources are available.

Validate API Schema

File: workflows/design/validate_schema.md

Validate API schemas against OpenAPI/Swagger standards. Check schema structure, retrieve API versions, and ensure API definitions are well-formed before deployment.

Compare API Versions

File: workflows/design/version_comparison.md

Compare different versions of an API to identify changes, breaking updates, and migration requirements. Essential for API governance and version management.

Manage API Specifications (Spec Hub)

File: workflows/design/manage_specs.md

Create and manage API specifications using Postman's Spec Hub. This is the modern, recommended approach for managing API definitions.

๐Ÿ†• New Features:

Manage Collections

File: workflows/build/manage_collections.md

Create, update, delete, and duplicate Postman collections. Build new test collections, organize existing ones, and manage collection lifecycle programmatically.

๐Ÿ†• v1.1 Enhanced Features:

Manage Environments

File: workflows/build/manage_environments.md

Create, update, delete, and duplicate Postman environments. Set up environment variables for different stages (dev, staging, production) and manage environment configurations.

๐Ÿ†• v1.1 Enhanced Features:

Run Collection Tests

File: workflows/test/run_collection.md

Execute a collection's test suite using Newman and get formatted results showing passes, failures, and detailed diagnostics. Requires Newman CLI to be installed.

Check Authentication

File: workflows/secure/check_auth.md

Review authentication configuration in collections. Identify auth types, check security settings, and get recommendations for improving API security.

Manage Mock Servers

File: workflows/deploy/manage_mocks.md

Create, update, and manage mock servers for API prototyping and frontend development. Enable testing without backend implementation.

Manage Monitors

File: workflows/observe/manage_monitors.md

Create, update, delete, and analyze Postman monitors for continuous API monitoring. View monitor run history, success rates, and performance metrics to ensure API reliability.

View Documentation

File: workflows/distribute/view_documentation.md

Access and assess API documentation quality. Check documentation completeness, review endpoint descriptions, and get recommendations for improving docs.

Architecture

This skill uses progressive disclosure:

  1. Metadata (always loaded): Skill name and description from YAML frontmatter
  2. SKILL.md (loaded when triggered): This overview document
  3. Workflow files (loaded as needed): Specific step-by-step instructions
  4. Python scripts (executed, not loaded): Actual API interaction code

File Structure

postman-skill/
โ”œโ”€โ”€ SKILL.md                      # This file - skill overview
โ”œโ”€โ”€ workflows/
โ”‚   โ”œโ”€โ”€ test/
โ”‚   โ”‚   โ”œโ”€โ”€ list_collections.md   # Discovery workflow
โ”‚   โ”‚   โ””โ”€โ”€ run_collection.md     # Test execution workflow
โ”‚   โ”œโ”€โ”€ design/
โ”‚   โ”‚   โ”œโ”€โ”€ manage_specs.md       # ๐Ÿ†• Spec Hub management workflow (NEW!)
โ”‚   โ”‚   โ”œโ”€โ”€ validate_schema.md    # Schema validation workflow
โ”‚   โ”‚   โ””โ”€โ”€ version_comparison.md # API version comparison workflow
โ”‚   โ”œโ”€โ”€ build/
โ”‚   โ”‚   โ”œโ”€โ”€ manage_collections.md # Collection management workflow
โ”‚   โ”‚   โ””โ”€โ”€ manage_environments.md # Environment management workflow
โ”‚   โ”œโ”€โ”€ secure/
โ”‚   โ”‚   โ””โ”€โ”€ check_auth.md         # Authentication check workflow
โ”‚   โ”œโ”€โ”€ deploy/
โ”‚   โ”‚   โ””โ”€โ”€ manage_mocks.md       # Mock server management workflow
โ”‚   โ”œโ”€โ”€ observe/
โ”‚   โ”‚   โ””โ”€โ”€ manage_monitors.md    # Monitor management workflow
โ”‚   โ””โ”€โ”€ distribute/
โ”‚       โ””โ”€โ”€ view_documentation.md # Documentation access workflow
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ config.py                 # Configuration management
โ”‚   โ”œโ”€โ”€ postman_client.py         # API client with CRUD + Spec Hub operations (now uses curl)
โ”‚   โ”œโ”€โ”€ validate_setup.py         # ๐Ÿ†• Comprehensive setup validation & diagnostics
โ”‚   โ”œโ”€โ”€ list_collections.py       # Collection discovery script (enhanced with context)
โ”‚   โ”œโ”€โ”€ list_workspaces.py        # ๐Ÿ†• Workspace discovery and navigation
โ”‚   โ”œโ”€โ”€ manage_collections.py     # Collection management CLI
โ”‚   โ”œโ”€โ”€ manage_environments.py    # Environment management CLI
โ”‚   โ”œโ”€โ”€ manage_pet_store_spec.py  # ๐Ÿ†• Spec Hub example script (NEW!)
โ”‚   โ”œโ”€โ”€ manage_pet_store_api.py   # Legacy API example (deprecated)
โ”‚   โ”œโ”€โ”€ run_collection.py         # Newman test execution wrapper
โ”‚   โ””โ”€โ”€ manage_monitors.py        # Monitor management CLI
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ retry_handler.py          # Retry logic with backoff
โ”‚   โ”œโ”€โ”€ formatters.py             # Output formatting (collections, monitors, runs)
โ”‚   โ””โ”€โ”€ exceptions.py             # ๐Ÿ†• Custom exception classes with helpful messages
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_phase1_manual.py     # ๐Ÿ†• Phase 1 test suite
โ”‚   โ””โ”€โ”€ README.md                 # ๐Ÿ†• Testing guide
โ””โ”€โ”€ docs/
    โ”œโ”€โ”€ assessment-report.md      # ๐Ÿ†• Current state analysis
    โ”œโ”€โ”€ api-compatibility-matrix.md # ๐Ÿ†• API endpoint coverage
    โ”œโ”€โ”€ gap-analysis.md           # ๐Ÿ†• Implementation roadmap
    โ””โ”€โ”€ compatibility-strategy.md # ๐Ÿ†• v10+ compatibility approach

Example Usage

Basic Operations

List all collections:

python /skills/postman-skill/scripts/list_collections.py

Create a new collection:

python /skills/postman-skill/scripts/manage_collections.py --create --name "My API Tests"

Create an environment with auto-secret detection (v1.1):

from scripts.postman_client import PostmanClient

client = PostmanClient()
env = client.create_environment(
    name="Production",
    values={
        "base_url": "https://api.example.com",
        "api_key": "secret-key-123",      # Auto-detected as secret! ๐Ÿ”
        "bearer_token": "bearer-xyz-456"  # Auto-detected as secret! ๐Ÿ”
    }
)

Spec Hub Workflows (NEW!)

Create an API specification:

import json
from scripts.postman_client import PostmanClient

client = PostmanClient()

# Create OpenAPI 3.0 spec
openapi_spec = {
    "openapi": "3.0.0",
    "info": {"title": "My API", "version": "1.0.0"},
    "paths": {"/users": {"get": {"responses": {"200": {"description": "Success"}}}}}
}

spec = client.create_spec({
    "name": "My API",
    "description": "A sample API",
    "files": [{
        "path": "openapi.json",
        "content": json.dumps(openapi_spec),
        "root": True
    }]
})
print(f"Created spec: {spec['id']}")

Generate collection from spec:

# Automatically create a collection from your spec
result = client.generate_collection_from_spec(
    spec_id,
    collection_name="My API Collection"
)

Generate spec from collection:

# Create a spec from an existing collection
result = client.generate_spec_from_collection(
    collection_id="collection-12345",
    spec_name="Generated API Spec"
)

Run the complete example:

python scripts/manage_pet_store_spec.py

Version Control Workflows (v1.1 - v10+ Required)

Fork a collection:

# Create a fork for independent development
fork = client.fork_collection(
    collection_uid="12345-abcde",
    label="feature-new-tests"
)
print(f"Forked collection: {fork['uid']}")

Create a pull request:

# Propose merging your changes
pr = client.create_pull_request(
    collection_uid="12345-abcde",      # Parent collection
    source_collection_uid=fork['uid'], # Your fork
    title="Add authentication tests",
    description="This PR adds comprehensive auth test coverage"
)

Merge a pull request:

# Merge approved changes
client.merge_pull_request("12345-abcde", pr['id'])

Duplicate a collection:

# Create a standalone copy (not a fork)
backup = client.duplicate_collection(
    collection_uid="12345-abcde",
    name="My Collection Backup"
)

Validate API schema:

# See: workflows/design/validate_schema.md
from scripts.postman_client import PostmanClient
client = PostmanClient()
schemas = client.get_api_schema(api_id="<api-id>", version_id="<version-id>")

Check authentication configuration:

# See: workflows/secure/check_auth.md
collection = client.get_collection(collection_uid="<collection-id>")
auth_type = collection.get('auth', {}).get('type', 'No auth')

Create a mock server:

# See: workflows/deploy/manage_mocks.md
mock_data = {"name": "API Mock", "collection": "<collection-uid>"}
mock = client.create_mock(mock_data)
print(f"Mock URL: {mock['mockUrl']}")

Run a specific collection:

python /skills/postman-skill/scripts/run_collection.py --collection="My API Tests"

List all monitors:

python /skills/postman-skill/scripts/manage_monitors.py --list

Analyze monitor run history:

python /skills/postman-skill/scripts/manage_monitors.py --analyze <monitor-id> --limit 20

Error Handling (Enhanced in v1.1)

All scripts include:

Error Message Example

Before (v1.0):

Exception: API request failed with status 404: Resource not found

After (v1.1):

ResourceNotFoundError: Collection with ID '12345' was not found.

Possible reasons:
- The resource was deleted
- The ID is incorrect
- You don't have permission to access it
- The resource is in a different workspace

Security (Enhanced in v1.1)

Limitations

API Version Compatibility

This skill is optimized for Postman v10+ APIs but maintains graceful degradation:

| Feature | v9 API | v10+ API |

|---------|--------|----------|

| Collections CRUD | โœ… Best Effort | โœ… Full Support |

| Collection Forking | โŒ Not Available | โœ… Full Support |

| Pull Requests | โŒ Not Available | โœ… Full Support |

| Environments CRUD | โœ… Best Effort | โœ… Full Support |

| Secret Variables | โš ๏ธ Limited | โœ… Full Support |

| Custom Exceptions | โœ… Full Support | โœ… Full Support |

| Version Detection | โœ… Full Support | โœ… Full Support |

The client automatically detects your API version and will show warnings if v10+ features are unavailable.

Next Steps

After loading this skill (Claude Instructions):

  1. ALWAYS run setup validation first: python scripts/validate_setup.py
  1. If validation fails:
  1. For "How many collections?" queries:
  1. Execute specific workflows based on user requests

Helpful diagnostic commands:

Related Resources

Security Guardrails

<!-- Armored by Faberlens | 6 default guardrails applied ยท 9 configurable at faberlens.ai/explore/api-client -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.