createCollectionRequest
Add a new HTTP request to a Postman collection or folder by specifying method, URL, headers, and body parameters.
Instructions
Creates a request in a collection. Recommended to pass 'name' property. See Postman Collection Format docs for full properties.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collectionId | Yes | The collection's ID | |
| folderId | No | Folder ID (optional, creates at collection level if omitted) | |
| name | No | Request name | |
| method | No | HTTP method (GET, POST, etc.) | |
| url | No | Request URL | |
| description | No | Request description | |
| auth | No | Authentication information | |
| headerData | No | Request headers | |
| queryParams | No | Query parameters | |
| dataMode | No | Request body data mode | |
| data | No | Form data | |
| rawModeData | No | Raw mode data | |
| graphqlModeData | No | GraphQL mode data | |
| dataOptions | No | Data mode options | |
| events | No | Script events |
Implementation Reference
- tools/postman_tools.py:339-422 (handler)The CreateCollectionRequestTool class defines the 'createCollectionRequest' tool. It extends ToolHandler and implements the run_tool method that makes a POST request to /collections/{collection_id}/requests to create a request within a collection.
class CreateCollectionRequestTool(ToolHandler): """Create a request in a collection""" def __init__(self): super().__init__("createCollectionRequest") def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Creates a request in a collection. Recommended to pass 'name' property. See Postman Collection Format docs for full properties.", inputSchema={ "type": "object", "properties": { "collectionId": { "type": "string", "description": "The collection's ID" }, "folderId": { "type": "string", "description": "Folder ID (optional, creates at collection level if omitted)" }, "name": { "type": "string", "description": "Request name" }, "method": { "type": "string", "description": "HTTP method (GET, POST, etc.)" }, "url": { "type": "string", "description": "Request URL" }, "description": { "type": "string", "description": "Request description" }, "auth": { "type": "string", "description": "Authentication information" }, "headerData": { "type": "array", "description": "Request headers" }, "queryParams": { "type": "array", "description": "Query parameters" }, "dataMode": { "type": "string", "description": "Request body data mode" }, "data": { "type": "string", "description": "Form data" }, "rawModeData": { "type": "string", "description": "Raw mode data" }, "graphqlModeData": { "type": "string", "description": "GraphQL mode data" }, "dataOptions": { "type": "string", "description": "Data mode options" }, "events": { "type": "string", "description": "Script events" } }, "required": ["collectionId"] }, ) async def run_tool(self, args: dict) -> list[TextContent]: collection_id = args.pop("collectionId") body = {k: v for k, v in args.items() if v is not None} result = await postman_api_call("POST", f"/collections/{collection_id}/requests", body=body) return [TextContent(type="text", text=json.dumps(result, indent=2))] - tools/postman_tools.py:345-414 (schema)The inputSchema within get_tool_description defines the expected parameters for the createCollectionRequest tool, including collectionId (required), folderId, name, method, url, description, auth, headerData, queryParams, dataMode, data, rawModeData, graphqlModeData, dataOptions, and events.
def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Creates a request in a collection. Recommended to pass 'name' property. See Postman Collection Format docs for full properties.", inputSchema={ "type": "object", "properties": { "collectionId": { "type": "string", "description": "The collection's ID" }, "folderId": { "type": "string", "description": "Folder ID (optional, creates at collection level if omitted)" }, "name": { "type": "string", "description": "Request name" }, "method": { "type": "string", "description": "HTTP method (GET, POST, etc.)" }, "url": { "type": "string", "description": "Request URL" }, "description": { "type": "string", "description": "Request description" }, "auth": { "type": "string", "description": "Authentication information" }, "headerData": { "type": "array", "description": "Request headers" }, "queryParams": { "type": "array", "description": "Query parameters" }, "dataMode": { "type": "string", "description": "Request body data mode" }, "data": { "type": "string", "description": "Form data" }, "rawModeData": { "type": "string", "description": "Raw mode data" }, "graphqlModeData": { "type": "string", "description": "GraphQL mode data" }, "dataOptions": { "type": "string", "description": "Data mode options" }, "events": { "type": "string", "description": "Script events" } }, "required": ["collectionId"] }, - tools/postman_tools.py:1831-1849 (registration)The register_all_tools() function registers CreateCollectionRequestTool() alongside all other tool handlers, making it available at index position for 'Requests/Responses'.
def register_all_tools() -> list[ToolHandler]: """Register all Postman tool handlers""" return [ # User Info GetAuthenticatedUserTool(), GetEnabledToolsTool(), # Collections CreateCollectionTool(), GetCollectionTool(), GetCollectionsTool(), PutCollectionTool(), DuplicateCollectionTool(), GetDuplicateCollectionTaskStatusTool(), # Requests/Responses CreateCollectionRequestTool(), UpdateCollectionRequestTool(), CreateCollectionResponseTool(), - tests/test_postman.py:59-59 (registration)Test file includes 'createCollectionRequest' in the expected tool names list, verifying the tool is properly registered.
"createCollectionRequest", - tools/postman_tools.py:21-67 (helper)The postman_api_call helper function is used by the handler to make HTTP requests to the Postman API.
async def postman_api_call( method: str, endpoint: str, body: dict | None = None, params: dict | None = None, headers: dict | None = None ) -> dict: """Make an API call to Postman API""" if not POSTMAN_API_KEY: raise RuntimeError("POSTMAN_API_KEY environment variable is not set") url = f"{POSTMAN_BASE_URL}{endpoint}" # Prepare headers request_headers = { "X-Api-Key": POSTMAN_API_KEY, "Content-Type": "application/json", } if headers: request_headers.update(headers) async with httpx.AsyncClient(timeout=30.0) as client: try: response = await client.request( method=method, url=url, json=body, params=params, headers=request_headers ) response.raise_for_status() if response.status_code == 204: return {"success": True, "message": "Operation completed successfully"} return response.json() if response.content else {"success": True} except httpx.HTTPStatusError as e: error_detail = e.response.text try: error_json = e.response.json() error_detail = json.dumps(error_json, indent=2) except: pass raise RuntimeError(f"Postman API error ({e.response.status_code}): {error_detail}") except Exception as e: raise RuntimeError(f"Request failed: {str(e)}")