Generate typed client code from Postman collections. Reads your private API definitions and writes production-ready code that matches your project's conventions.
## Prerequisites
The Postman MCP Server must be connected. If MCP tools aren't available, tell the user: "Run `/postman:setup` to configure the Postman MCP Server."
1. Call `searchPostmanElementsInPrivateNetwork` with the API name to find it in the organization's private network.
2. If no results, call `getWorkspaces` to get the user's workspace ID. If multiple workspaces exist, ask which to use. Then use `getCollections` with the `workspace` parameter and `name` filter if the user specified an API name.
3. If still no results, fall back to `searchPostmanElementsInPublicNetwork` to search the public Postman network.
- Error handling based on documented error responses
- Environment-based configuration (base URL from env vars)
- Pagination support if the API uses it
**Code conventions:**
- Match the project's existing style (imports, formatting, naming)
- Include JSDoc/docstrings from collection descriptions
- Use the project's HTTP library if one exists (axios, fetch, requests, etc.)
- Write to a sensible file path (e.g., `src/clients/<api-name>.ts`)
### Step 5: Present
```
Generated: src/clients/users-api.ts
Endpoints covered:
GET /users → getUsers(filters)
GET /users/{id} → getUser(id)
POST /users → createUser(data)
PUT /users/{id} → updateUser(id, data)
DELETE /users/{id} → deleteUser(id)
Types generated:
User, CreateUserRequest, UpdateUserRequest,
UserListResponse, ApiError
Auth: Bearer token (from USERS_API_TOKEN env var)
Base URL: from USERS_API_BASE_URL env var
```
## Error Handling
- **MCP not configured:** "Run `/postman:setup` to configure the Postman MCP Server."
- **Collection not found:** "No collection matching that name. Run `/postman:search` to find available APIs."
- **401 Unauthorized:** "Your Postman API key was rejected. Generate a new one at https://postman.postman.co/settings/me/api-keys and run `/postman:setup`."
- **Empty collection:** "This collection has no requests. Add endpoints in Postman or use `/postman:sync` to push a spec."
- **Language not detected:** Ask the user what language to generate.