• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
ianmenethil

ianmenethil

ZenServer

Unlisted
Like
ZenServer
Home
Code
13
.cursor
docs
9
scripts
4
src
11
tasks
tests
.gitignore
.vtignore
CLAUDE.md
README.md
deno.json
H
main.ts
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
22
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
scripts
/
README.md
Code
/
scripts
/
README.md
Search
7/9/2025
Viewing readonly version of main branch: v510
View latest version
README.md

OpenAPI Sync Scripts

Automatically sync your local openapi.json file to Val Town blob storage.

🔧 Setup

1. Get Your Val Town API Token

  1. Go to https://val.town/settings/api
  2. Create a new API token
  3. Copy the token value

2. Set Environment Variable

Windows (PowerShell):

$env:VALTOWN_API_TOKEN = "your_token_here"

Windows (Command Prompt):

set VALTOWN_API_TOKEN=your_token_here

Permanent (Windows):

[Environment]::SetEnvironmentVariable("VALTOWN_API_TOKEN", "your_token_here", "User")

🚀 Usage

Option 1: Batch File (Easiest)

cd ZenServer\scripts sync-openapi.bat

Option 2: PowerShell

cd ZenServer\scripts .\sync-openapi-to-valtown.ps1

Option 3: Deno (Cross-platform)

cd ZenServer\scripts deno run -A sync-openapi-to-valtown.ts

📁 What It Does

  • Source: F:\val.town\ZenServer\openapi.json
  • Destination: __public/ZPServer/openapi.json in Val Town blob storage
  • Action: Creates or overwrites the blob automatically
  • Verification: Reads back the uploaded content to verify success

🌐 Public Access

After upload, your OpenAPI spec will be available at:

https://api.val.town/v1/blob/__public%2FZPServer%2Fopenapi.json

🔒 Security

  • API token is read from environment variable (not stored in scripts)
  • Uses HTTPS for all API calls
  • Validates JSON before upload
  • Verifies upload integrity

🛠️ Customization

You can modify the file paths by editing the script variables:

PowerShell:

.\sync-openapi-to-valtown.ps1 -LocalFile "C:\custom\path\openapi.json" -BlobKey "custom/key"

Deno: Edit the constants at the top of sync-openapi-to-valtown.ts

🐛 Troubleshooting

"API token required" error:

  • Make sure VALTOWN_API_TOKEN environment variable is set
  • Restart your terminal after setting the variable

"File not found" error:

  • Check that F:\val.town\ZenServer\openapi.json exists
  • Verify the file path in the script matches your setup

"Invalid JSON" error:

  • Validate your JSON file with a JSON validator
  • Check for syntax errors in the OpenAPI spec

Permission errors:

  • Run PowerShell as Administrator if needed
  • Check that the file is not locked by another application
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.