Skip to main content

Vercel Integration API

These endpoints support the Vercel Integration for automated deployment and configuration of NetPad instances.

Get Environment Variables Templateโ€‹

Retrieve the environment variables needed for deployment, optionally pre-filled with organization data.

GET /api/integrations/vercel/env

Authentication: Session authentication required

Query Parameters:

ParameterTypeRequiredDescription
organizationIdstringNoOrganization ID to get pre-filled values

Example Request (Template Only):

curl -X GET "https://your-domain.com/api/integrations/vercel/env" \
-H "Authorization: Bearer your_session_token"

Example Response:

{
"success": true,
"envVars": {
"MONGODB_URI": {
"value": "",
"description": "MongoDB connection string. Get from MongoDB Atlas.",
"required": true
},
"MONGODB_DATABASE": {
"value": "forms",
"description": "Database name for NetPad data.",
"required": true
},
"SESSION_SECRET": {
"value": "auto-generated-64-char-hex",
"description": "Secret key for session encryption. Auto-generated.",
"required": true
},
"VAULT_ENCRYPTION_KEY": {
"value": "auto-generated-base64-key",
"description": "Key for vault encryption. Auto-generated.",
"required": true
},
"NEXT_PUBLIC_APP_URL": {
"value": "${VERCEL_URL}",
"description": "Public URL of your app. Use ${VERCEL_URL} for auto-detection.",
"required": true
}
}
}

Push Environment Variables to Vercel Projectโ€‹

Push environment variables to a connected Vercel project.

POST /api/integrations/vercel/env

Authentication: Session authentication and Vercel integration installed

Request Body:

{
"installationId": "oac_xxx",
"projectId": "prj_xxx",
"organizationId": "org_xxx"
}

Example Request:

curl -X POST "https://your-domain.com/api/integrations/vercel/env" \
-H "Authorization: Bearer your_session_token" \
-H "Content-Type: application/json" \
-d '{
"installationId": "oac_xxx",
"projectId": "prj_xxx",
"organizationId": "org_xxx"
}'

Example Response:

{
"success": true,
"message": "Environment variables configured successfully",
"envVarsSet": [
"MONGODB_URI",
"MONGODB_DATABASE",
"SESSION_SECRET",
"VAULT_ENCRYPTION_KEY",
"NEXT_PUBLIC_APP_URL",
"APP_URL"
]
}

Vercel OAuth Callbackโ€‹

Handle OAuth callback from Vercel Integration installation.

GET /api/integrations/vercel/callback

Query Parameters:

ParameterTypeDescription
codestringOAuth authorization code from Vercel
configurationIdstringVercel configuration ID
teamIdstringOptional Vercel team ID
nextstringRedirect URL after installation
note

This endpoint is called automatically by Vercel during integration installation. You typically won't call this directly.


Provision MongoDB Atlas Clusterโ€‹

Provision a new MongoDB Atlas M0 cluster for Vercel deployments.

POST /api/integrations/vercel/provision

Authentication: Session authentication required

Request Body:

{
"installationId": "oac_xxx",
"organizationId": "org_xxx"
}

Example Request:

curl -X POST "https://your-domain.com/api/integrations/vercel/provision" \
-H "Authorization: Bearer your_session_token" \
-H "Content-Type: application/json" \
-d '{
"installationId": "oac_xxx",
"organizationId": "org_xxx"
}'

Example Response:

{
"success": true,
"message": "MongoDB cluster provisioned successfully",
"clusterName": "netpad-cluster-abc123",
"database": "forms",
"envVars": {
"MONGODB_URI": "mongodb+srv://...",
"MONGODB_DATABASE": "forms",
"SESSION_SECRET": "auto-generated",
"VAULT_ENCRYPTION_KEY": "auto-generated"
}
}

Integration Flowโ€‹

The Vercel integration follows this flow:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ User clicks โ”‚โ”€โ”€โ”€โ”€>โ”‚ Vercel OAuth โ”‚โ”€โ”€โ”€โ”€>โ”‚ Callback to โ”‚
โ”‚ "Add to Vercel"โ”‚ โ”‚ Authorization โ”‚ โ”‚ /callback โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Deployment โ”‚<โ”€โ”€โ”€โ”€โ”‚ Push env vars โ”‚<โ”€โ”€โ”€โ”€โ”‚ Configure โ”‚
โ”‚ Complete โ”‚ โ”‚ to Vercel โ”‚ โ”‚ env vars โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  1. User initiates: Clicks "Deploy to Vercel" button
  2. OAuth flow: User authorizes NetPad to access their Vercel account
  3. Callback: Vercel redirects to /api/integrations/vercel/callback
  4. Configuration: User configures environment variables
  5. Push: Environment variables are pushed to the Vercel project
  6. Deploy: Vercel builds and deploys the application

Environment Variables Referenceโ€‹

The integration automatically configures these environment variables:

VariableDescriptionAuto-Generated
MONGODB_URIMongoDB connection stringNo (user provides)
MONGODB_DATABASEDatabase nameYes (default: forms)
SESSION_SECRETSession encryption keyYes
VAULT_ENCRYPTION_KEYVault encryption keyYes
NEXT_PUBLIC_APP_URLPublic application URLYes (uses ${VERCEL_URL})
APP_URLServer-side application URLYes (uses ${VERCEL_URL})

Error Handlingโ€‹

Common Errorsโ€‹

Error CodeDescriptionResolution
INTEGRATION_NOT_INSTALLEDVercel integration not installedInstall the integration first
INVALID_INSTALLATION_IDInstallation ID not foundVerify the installation ID
PERMISSION_DENIEDInsufficient Vercel permissionsRe-authorize with correct scopes
PROJECT_NOT_FOUNDVercel project not foundVerify project ID
PROVISIONING_FAILEDMongoDB provisioning failedCheck Atlas API credentials

Example Error Responseโ€‹

{
"success": false,
"error": {
"code": "INTEGRATION_NOT_INSTALLED",
"message": "Vercel integration is not installed for this organization",
"details": {
"organizationId": "org_xxx"
}
}
}