CLI Reference
Learn about the AgentPress command-line tools for syncing your API methods.
agentpress-sync
The main CLI command that scans your API routes and uploads method definitions to AgentPress.
Usage
bunx agentpress-syncHow It Works
The agentpress-sync command performs the following steps:
- Scans your API directory for
route.methods.tsfiles - Parses exported
methodsarrays - Converts Zod schemas to JSON Schema format
- Validates all method definitions
- Uploads methods to AgentPress
Requirements
- Must be run from your Next.js project root
- Requires
AGENTPRESS_SECRET_KEYenvironment variable - Project must have an
app/apiorsrc/app/apidirectory - Zod v4+ must be installed
Environment Variables
Set these in your .env.local file:
# Required
AGENTPRESS_SECRET_KEY="your-secret-key-from-agentpress"
# Optional - custom API endpoint (defaults to AgentPress cloud)
NEXT_PUBLIC_AGENTPRESS_API_BASE_URL="https://your-api.com"Output Examples
Successful Sync
🔍 Scanning API routes for methods...
📁 Using API directory: /home/user/project/src/app/api
Found 4 route file(s)
✓ Found 3 method(s) in /api/users
✓ Found 2 method(s) in /api/products
✓ Found 1 method(s) in /api/orders
✓ Found 2 method(s) in /api/analytics
📤 Uploading 4 route(s) to AgentPress...
✅ Methods uploaded successfully!Issues Found
⚠️ Warning in /api/users/route.methods.ts:
Method "updateUser" missing description
✓ Upload completed with 1 warningTroubleshooting
”AGENTPRESS_SECRET_KEY environment variable is required”
Solution: Create a .env.local file in your project root:
echo 'AGENTPRESS_SECRET_KEY="your-key-here"' > .env.local“API directory not found”
Solution: Make sure you’re running the command from your Next.js project root and that you have an app/api or src/app/api directory.
# Navigate to project root
cd /path/to/your/nextjs/app
# Verify API directory exists
ls -la src/app/api # or app/api
# Run sync
bunx agentpress-sync”Zod not found in your project”
Solution: Install Zod:
bun add zod@^4.0.0“Found 0 route file(s)”
Causes:
- No
route.methods.tsfiles exist - Files are named incorrectly (must be exactly
route.methods.ts) - Files don’t export a
methodsarray
Solution:
- Check file names and paths
- Ensure methods are exported correctly:
// ✅ Correct
export const methods = [
{ method: "GET", name: "getUsers", ... }
];
// ❌ Wrong
export default const methods = [...]
// ❌ Wrong
const methods = [...] // Not exportedLast updated on