V1 Dev API - Postman Collection

September 8, 2025 ยท View on GitHub

A comprehensive Postman collection for the V1 Dev platform APIs with OAuth setup, CSRF protection, and all endpoints properly documented.

๐Ÿ“‹ Overview

This collection includes 100+ API endpoints organized into logical groups:

  • ๐Ÿ” Authentication - OAuth, email auth, session management (16 endpoints)
  • ๐Ÿค– Agent & Code Generation - AI-powered webapp creation (5 endpoints)
  • ๐Ÿ“ฑ Apps Management - CRUD operations, public feed, favorites (10 endpoints)
  • ๐Ÿ‘ค User Management - Profile, apps with pagination (2 endpoints)
  • ๐Ÿ“Š Analytics & Stats - User stats, AI Gateway analytics (4 endpoints)
  • ๐Ÿค– Model Configuration - AI model settings, BYOK providers (8 endpoints)
  • ๐Ÿข Custom Model Providers - OpenAI-compatible API management (6 endpoints)
  • ๐Ÿ” Secrets Management - API keys, credentials with templates (5 endpoints)
  • ๐Ÿ™ GitHub Integration - Repository export, OAuth (2 endpoints)

๐Ÿš€ Quick Setup

1. Import Collection & Environment

  1. Import Collection:

    • Open Postman โ†’ Import โ†’ Upload v1dev-api-collection.postman_collection.json
  2. Import Environment:

    • Import โ†’ Upload v1dev-environment.postman_environment.json
  3. Select Environment:

    • Choose "V1 Dev Environment" from the environment dropdown

2. Configure Base URL

Update the baseUrl environment variable:

  • Production: https://your-production-domain.com
  • Local Development: http://localhost:8787 (Wrangler dev server)

3. OAuth Setup in Postman

โš ๏ธ IMPORTANT: OAuth endpoints redirect to external providers (Google/GitHub) and cannot be tested directly in Postman.

  1. Use the OAuth Helper requests:

    • Run "๐ŸŒ OAuth Helper - Get Google URL"
    • Check the Console tab in Postman for the OAuth URL
    • Copy the URL and open it in your browser
  2. Complete authentication in browser:

    • Follow the OAuth flow in your browser
    • After successful auth, you'll be redirected back to your app
    • Session cookies are now set for your domain
  3. Return to Postman:

    • Session cookies will work automatically for same-domain requests
    • Test with "Get User Profile" to verify authentication

Alternative: Manual URL Construction

If helpers don't work, manually construct URLs:

  • Google OAuth: {{baseUrl}}/api/auth/oauth/google
  • GitHub OAuth: {{baseUrl}}/api/auth/oauth/github
  • Open these URLs directly in your browser

Why Direct OAuth Requests Show HTML

  • OAuth endpoints return HTTP redirects (302) to provider websites
  • Postman shows the redirect HTML instead of following it
  • This is normal behavior - OAuth requires browser-based flows

4. CSRF Token Automation

The collection automatically handles CSRF tokens:

  • Pre-request scripts fetch CSRF tokens when needed
  • Tokens are stored in the csrf_token environment variable
  • All state-changing requests include the token automatically

๐Ÿ”‘ Authentication Methods

1. Email Authentication

POST /api/auth/register
{
  "email": "user@example.com",
  "password": "SecurePassword123!",
  "name": "Test User"
}

POST /api/auth/login
{
  "email": "user@example.com", 
  "password": "SecurePassword123!"
}

2. OAuth Authentication

  • Google OAuth: GET /api/auth/oauth/google
  • GitHub OAuth: GET /api/auth/oauth/github

3. Session-Based Authentication

  • Uses secure HTTP-only cookies
  • Sessions are automatically maintained across requests
  • CSRF protection via X-CSRF-Token header

๐Ÿ“ฑ Core API Workflows

1. Create a New App with AI

# 1. Login or use OAuth
POST /api/auth/login

# 2. Start code generation
POST /api/agent
{
  "query": "Create a React todo app with TypeScript and Tailwind CSS",
  "agentMode": "smart",
  "language": "typescript", 
  "frameworks": ["react", "tailwindcss"],
  "selectedTemplate": "react-typescript"
}

# 3. Connect to WebSocket for real-time updates
GET /api/agent/{agentId}/ws (WebSocket)

# 4. Deploy preview when ready
GET /api/agent/{agentId}/preview

2. Browse and Interact with Apps

# Get public apps (no auth required)
GET /api/apps/public?page=1&limit=20&sort=stars&order=desc

# Get app details (no auth required)
GET /api/apps/{appId}

# Star an app (requires auth)
POST /api/apps/{appId}/star

# Fork an app (requires auth) 
POST /api/apps/{appId}/fork

3. Configure AI Models

# Get available models and providers
GET /api/model-configs/byok-providers

# Update model configuration for specific agent action
PUT /api/model-configs/planner
{
  "modelName": "claude-3-5-sonnet-20241022",
  "maxTokens": 4096,
  "temperature": 0.7,
  "reasoningEffort": "medium"
}

# Test model configuration
POST /api/model-configs/test
{
  "agentActionName": "planner",
  "useUserKeys": true
}

4. Manage API Keys and Secrets

# Get secret templates
GET /api/secrets/templates

# Store an API key
POST /api/secrets
{
  "templateId": "openai_api_key",
  "name": "My OpenAI API Key",
  "envVarName": "OPENAI_API_KEY",
  "value": "sk-your-api-key-here"
}

# Create custom model provider  
POST /api/user/providers
{
  "name": "My Custom OpenAI Provider",
  "baseUrl": "https://api.openai.com/v1",
  "apiKey": "sk-your-key",
  "models": [...]
}

๐Ÿ”ง Advanced Features

Environment Variables

The collection uses these automatically managed variables:

VariableDescriptionAuto-populated
csrf_tokenCSRF protection tokenโœ…
user_idCurrent user IDโœ…
session_idCurrent session IDโœ…
agent_idCurrent agent/app IDโœ…
app_idCurrent app IDโœ…
provider_idModel provider IDManual
secret_idSecret IDManual

Request Automation

  • CSRF Tokens: Automatically fetched and included
  • Session Management: Cookies handled transparently
  • Variable Population: IDs extracted from responses
  • Error Handling: Test scripts validate responses

WebSocket Testing

For WebSocket endpoints like agent communication:

  1. Use a WebSocket client (wscat, Postman WebSocket, etc.)
  2. Connect to: ws://localhost:8787/api/agent/{agentId}/ws
  3. Include authentication cookies
  4. Send/receive real-time messages during code generation

๐Ÿ› ๏ธ Development Setup

Local Development

  1. Start Wrangler Dev Server:

    cd /path/to/v1dev
    npm run local  # Starts on http://localhost:8787
    
  2. Update Environment:

    • Set baseUrl to http://localhost:8787
    • Ensure .dev.vars contains required environment variables
  3. Test Authentication:

    • OAuth may require ngrok for localhost callback URLs
    • Email auth works directly with localhost

Production Testing

  1. Update baseUrl to your production domain
  2. Ensure OAuth apps are configured with correct callback URLs
  3. Test with real OAuth credentials

๐Ÿ“š API Documentation

Authentication Levels

  • Public: No authentication required
  • Authenticated: Requires valid session
  • Owner Only: Requires ownership of the resource

Common Parameters

ParameterDescriptionExample
pagePage number for pagination1
limitItems per page20
sortSort fieldcreatedAt, stars
orderSort orderasc, desc
periodTime period filtertoday, week, month, all
searchSearch query"todo app"

Response Format

All API responses follow this structure:

{
  "success": true,
  "data": { ... },
  "message": "Optional message",
  "pagination": {  // For paginated responses
    "page": 1,
    "limit": 20, 
    "total": 100,
    "totalPages": 5
  }
}

Error Responses

{
  "success": false,
  "error": "Error message",
  "code": "ERROR_CODE",
  "details": { ... }  // Optional additional details
}

๐Ÿšจ Troubleshooting

Common Issues

  1. CSRF Token Errors:

    • Ensure pre-request scripts are enabled
    • Manually run "Get CSRF Token" request
    • Check that X-CSRF-Token header is included in POST/PUT/DELETE requests
  2. Authentication Issues:

    • Verify cookies are enabled in Postman
    • Check that OAuth callback URLs match your configuration
    • Ensure session hasn't expired (check "Get User Profile")
  3. WebSocket Connection Issues:

    • WebSockets require active session authentication
    • Use external WebSocket client if Postman WebSocket support is limited
    • Verify agent ownership for WebSocket connections
  4. Local Development Issues:

    • Ensure Wrangler is running (npm run local)
    • Check that .dev.vars file contains required environment variables
    • Verify D1 database is set up (npm run db:setup)

Getting Help

  1. Check API Response: Look at response body for detailed error messages
  2. Verify Environment: Ensure correct baseUrl is set
  3. Test Authentication: Run "Check Auth Status" to verify session
  4. Review Logs: Check browser DevTools or Wrangler logs for additional context

๐ŸŽฏ Testing Workflows

Complete User Journey

  1. Register/Login โ†’ Authentication working
  2. Create App โ†’ AI generation working
  3. Browse Public Apps โ†’ Public feed working
  4. Star/Fork App โ†’ Social features working
  5. Configure Models โ†’ AI customization working
  6. Manage Secrets โ†’ Security features working
  7. Export to GitHub โ†’ Integration working

Quick Health Check

Run these requests to verify the system:

  1. GET /api/auth/providers - System status
  2. GET /api/apps/public - Public API working
  3. POST /api/auth/login - Authentication working
  4. GET /api/model-configs - AI system working
  5. GET /api/stats - Analytics working

This collection provides comprehensive coverage of all V1 Dev APIs with proper authentication, error handling, and real-world usage examples. Perfect for development, testing, and integration work!