wispfnDocs
REST API

List and read versions, create a version from a batch of changes, publish, roll back and restore with the REST API.

#List versions

GET /api/projects/:id/versions

Returns the version history, newest first: number, summary, author, time and when each was published.

#Get a version

GET /api/projects/:id/versions/:n
GET /api/projects/:id/versions/latest

The version's functions (including before and after) and library modules with their code. latest is the newest version — the current draft.

#Create a version from a batch of changes

POST /api/projects/:id/versions

Applies several changes at once and creates one new draft version. Either every change applies or none does — if one fails, nothing is saved and the error names it (Change 2 (delete_function orders): …). Scope: functions:write.

{
  "summary": "Orders API and nightly report",
  "changes": [
    { "op": "put_library", "name": "money", "code": "export const cents = (n) => Math.round(n * 100);" },
    { "op": "put_function", "name": "orders", "method": "POST", "code": "export async function handler(req) { … }", "visibility": "private" },
    { "op": "put_function", "name": "report", "http": false, "code": "export async function handler() { … }", "schedule": { "cron": "0 6 * * *", "timezone": "UTC" } },
    { "op": "put_function", "name": "before", "code": "export async function handler(req) { … }" },
    { "op": "delete_function", "name": "legacy-orders" }
  ]
}
opFieldsDoes
put_functionname, code, and any function field: http, method, visibility, mcp, beforeAfter, schedule, cache, language, description, inputSchema, outputSchemaCreates the function, or updates the one with that name
delete_functionnameDeletes a function
put_libraryname, code, language, descriptionAdds or replaces a library module
delete_librarynameDeletes a library module

When updating, fields you leave out keep their current values; code is required only when creating. Up to 100 changes per call. summary (up to 200 characters) is the version's description; without it, Wisp lists the changes.

Returns { "changed": true, "version": 13, "summary": "…", "deploy": { … } }, or { "changed": false } when nothing differed. The new version is a draft: test it, then publish.

#Publish

POST /api/projects/:id/publish

Body: { "version": 12 } to publish (roll back to) a specific version, or {} for the current draft. Scope: projects:deploy.

curl -X POST https://wispfn.com/api/projects/$PROJECT/publish \
  -H "Authorization: Bearer $WISP_API_KEY" -H "content-type: application/json" -d '{}'

#Restore

POST /api/projects/:id/versions/:n/restore

Makes the draft match version n by creating a new version. Doesn't publish. Scope: functions:write.