Skip to content

Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.

fix(savvycal): send the required event booking contract

Rudy Celekli5b7511d854a1
diff --git a/tests/clis/savvycal-booking.test.cjs b/tests/clis/savvycal-booking.test.cjs
new file mode 100644
index 0000000..37fc267
--- /dev/null
+++ b/tests/clis/savvycal-booking.test.cjs
@@ -0,0 +1,56 @@
+const { test } = require('node:test')
+const assert = require('node:assert/strict')
+const { spawnSync } = require('node:child_process')
+const path = require('node:path')
+const cli = path.resolve(__dirname, '../../tools/clis/savvycal.js')
+function run(args, oracle = '') {
+ const code = `global.fetch = async (url, options) => {
+ const assert = require('node:assert/strict');
+ const parsed = new URL(url);
+ const body = options.body ? JSON.parse(options.body) : null;
+ ${oracle}
+ return new Response(JSON.stringify({accepted:true, url, body}), {status:200});
+ }; process.argv = ['node', ${JSON.stringify(cli)}, ...${JSON.stringify(args)}]; require(${JSON.stringify(cli)});`
+ return spawnSync(process.execPath, ['-e', code], {
+ encoding: 'utf8', timeout: 10000,
+ env: { ...process.env, SAVVYCAL_API_KEY: 'fixture-token' },
+ })
+}
+function result(r) { assert.equal(r.status, 0, r.stderr); return JSON.parse(r.stdout) }
+
+const booking = ['events','create','--link-id','link_123','--start-at','2026-10-10T14:00:00Z','--end-at','2026-10-10T14:30:00Z','--time-zone','America/New_York','--name','Jane Doe','--email','[email protected]']
+const expected = {start_at:'2026-10-10T14:00:00Z',end_at:'2026-10-10T14:30:00Z',time_zone:'America/New_York',display_name:'Jane Doe',email:'[email protected]'}
+test('booking uses the scheduling-link endpoint with all required event fields', () => {
+ assert.equal(result(run(booking, `
+ assert.equal(options.method, 'POST');
+ assert.equal(parsed.pathname, '/v1/links/link_123/events');
+ assert.deepEqual(body, ${JSON.stringify(expected)});
+ `)).accepted, true)
+})
+for (const missing of ['--end-at','--time-zone']) {
+ test(`missing ${missing} is rejected before a booking request`, () => {
+ const incomplete = booking.filter((v,i,a) => v !== missing && a[i-1] !== missing)
+ const r = run(incomplete, "throw new Error('booking must not be attempted')")
+ const p = result(r)
+ assert.match(p.error, new RegExp(missing))
+ })
+}
+test('booking preview matches the contract and never sends a request', () => {
+ const p = result(run([...booking,'--dry-run'], "throw new Error('unexpected fetch')"))
+ assert.equal(new URL(p.url).pathname, '/v1/links/link_123/events')
+ assert.deepEqual(p.body, expected)
+ assert.equal(p.headers.Authorization, '***')
+})
+test('booking encodes a scheduling link ID as one path component', () => {
+ const args = booking.map(v => v === 'link_123' ? 'link/with?reserved#chars' : v)
+ const p = result(run([...args,'--dry-run'], "throw new Error('unexpected fetch')"))
+ assert.equal(new URL(p.url).pathname, '/v1/links/link%2Fwith%3Freserved%23chars/events')
+})
+test('listing events keeps cursor pagination', () => {
+ result(run(['events','list','--after','cursor','--limit','5'], `
+ assert.equal(options.method, 'GET');
+ assert.equal(parsed.pathname, '/v1/events');
+ assert.equal(parsed.searchParams.get('after'), 'cursor');
+ assert.equal(parsed.searchParams.get('limit'), '5');
+ `))
+})
diff --git a/tools/clis/savvycal.js b/tools/clis/savvycal.js
index bf5b913..d028926 100755
--- a/tools/clis/savvycal.js
+++ b/tools/clis/savvycal.js
@@ -149,16 +149,19 @@ async function main() {
case 'create': {
const linkId = args['link-id']
const startAt = args['start-at']
+ const endAt = args['end-at']
+ const timeZone = args['time-zone']
const name = args.name
const email = args.email
- if (!linkId || !startAt || !name || !email) {
- result = { error: '--link-id, --start-at, --name, and --email required' }
+ if (!linkId || !startAt || !endAt || !timeZone || !name || !email) {
+ result = { error: '--link-id, --start-at, --end-at, --time-zone, --name, and --email required' }
break
}
- result = await api('POST', '/events', {
- scheduling_link_id: linkId,
+ result = await api('POST', `/links/${encodeURIComponent(linkId)}/events`, {
start_at: startAt,
- name,
+ end_at: endAt,
+ time_zone: timeZone,
+ display_name: name,
email,
})
break
@@ -208,7 +211,7 @@ async function main() {
usage: {
me: 'me',
links: 'links [list | get --id <id> | create --name <name> | update --id <id> | delete --id <id> | duplicate --id <id> | toggle --id <id> | slots --id <id>]',
- events: 'events [list | get --id <id> | create --link-id <id> --start-at <iso> --name <name> --email <email> | cancel --id <id>]',
+ events: 'events [list | get --id <id> | create --link-id <id> --start-at <iso> --end-at <iso> --time-zone <iana> --name <name> --email <email> | cancel --id <id>]',
webhooks: 'webhooks [list | create --url <url> --events <e1,e2> | delete --id <id>]',
options: '--limit <n> --after <cursor> --before <cursor>',
}
diff --git a/tools/integrations/savvycal.md b/tools/integrations/savvycal.md
index b355c8e..0bcb7ee 100644
--- a/tools/integrations/savvycal.md
+++ b/tools/integrations/savvycal.md
@@ -98,16 +98,28 @@ GET https://api.savvycal.com/v1/events/{id}
### Create an event
```bash
-POST https://api.savvycal.com/v1/events
+POST https://api.savvycal.com/v1/links/{link_id}/events
{
- "scheduling_link_id": "{link_id}",
"start_at": "2024-01-20T10:00:00Z",
- "name": "John Doe",
+ "end_at": "2024-01-20T10:30:00Z",
+ "time_zone": "America/New_York",
+ "display_name": "John Doe",
"email": "[email protected]"
}
```
+The CLI maps `--name` to `display_name` and requires the booking start, end, and
+attendee time zone. Choose an available slot for the scheduling link:
+
+```bash
+node tools/clis/savvycal.js events create --link-id link_123 \
+ --start-at 2024-01-20T10:00:00Z --end-at 2024-01-20T10:30:00Z \
+ --time-zone America/New_York --name "John Doe" --email [email protected]
+```
+
+See the official [create event contract](https://developers.savvycal.com/api/create-event).
+
### Cancel an event
```bash