Using API v1? See what changes in v2, or the v1 docs
Build with v0
v0 can add Google Calendar and Microsoft Outlook to your app with Pyas. You connect the Pyas MCP server to v0, and v0 gets the code for each task from Pyas while it builds your app. You store a key as an environment variable. The key stays on the server, and the code works with the sandbox's sample people before anyone connects a real calendar.
Add Pyas to v0
- In v0, open the + menu in the prompt box and select MCPs.
- Add a custom server with the address
https://mcp.pyas.io/sandbox, and choose OAuth for authentication. - Sign in to Pyas, choose your app, and select Allow. See Sign in for what each permission allows.
v0 uses the Pyas tools while it builds your app. The app it builds calls the Pyas API directly, with your key, and doesn't use the MCP server.
Ask for what you want
Ask in plain words, for example:
Add a button that lets people connect their Google or Outlook calendar, and show their events for the next week.
v0 checks your setup with setup_status and gets the code for each task with get_recipe. It adds your app's preview address to the allowed origins with update_app, and creates a test key with get_test_key. You confirm the address in Pyas, from the link it gives you. Every response from Pyas ends with the next step.
Store the key
Store the test key as an environment variable named PYAS_API_KEY:
- Open the project menu, then Settings, then Environment Variables.
- Add
PYAS_API_KEY. The preview reads the Development variables, and the published app reads the Production ones, so add it to each environment where you use it.
Route handlers read the variable on the server, and it never reaches the browser. Don't name it with a NEXT_PUBLIC_ prefix, which would send it to the browser. A test key works only in your app's sandbox.
What v0 adds
The code runs as Next.js route handlers:
lib/pyas.ts the Pyas client, and who is signed in
app/api/pyas/connect-session/route.ts creates a connect session for the button
app/api/pyas/events/route.ts the person's events for the next 7 days
app/api/pyas/book/route.ts books the first free 30 minutes tomorrow
components/connect-calendar.tsx the "Connect an account" button
Your pages call the routes with fetch, for example fetch('/api/pyas/events').
With a test key, the routes use the sandbox's sample person, so the events and booking work right away. The connect button shows a message from Pyas that connecting a real calendar requires a live key. This is expected.
Receive webhooks
Ask v0 to receive Pyas webhooks. It adds app/api/pyas/webhooks/route.ts, which verifies the signature of each delivery against the raw body before it reads the event.
v0 adds the endpoint to your sandbox with create_webhook, at your published address:
https://<your-app>.vercel.app/api/pyas/webhooks
Store the signing secret that create_webhook returns as an environment variable named PYAS_WEBHOOK_SECRET. See Webhooks for the events Pyas sends.
Go live
- Make
currentUserId()inlib/pyas.tsreturn the signed-in person's ID from your app's sign-in. Until then, the routes respond with401and the codeSIGN_IN_REQUIREDto every request made with a live key, so people's calendars never mix. - In the Pyas dashboard, choose a plan and create a live key. Plans, payment and live keys are always done by you, in the dashboard.
- Replace the
PYAS_API_KEYProduction variable with the live key, and publish again with Publish Changes. A changed variable applies only to a new deployment. - Add your published address to the app's allowed origins, and add a live webhook endpoint in the dashboard.