Skip to main content

Documentation Index

Fetch the complete documentation index at: https://sleekplan.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Two minimal but realistic implementations show the full Canvas lifecycle. Both verify the X-Secret header, handle the initial render, react to button clicks, and return confirmation state.

Minimal endpoint

import express from 'express';

const app = express();
app.use(express.json());

const SECRET = process.env.SLEEKPLAN_CANVAS_SECRET;

app.post('/sleekplan/canvas', (req, res) => {
  if (req.get('X-Secret') !== SECRET) {
    return res.status(401).json({ error: 'Unauthorized' });
  }

  const { submit, ['button-action-create']: createClicked } = req.body;

  if (!submit) {
    return res.json([
      { type: 'text', text: 'Search or create item', style: 'paragraph' },
      { type: 'input', id: 'input-action-search', label: 'Search...', submit: true },
      { type: 'button', id: 'button-action-create', label: 'Create new item', style: 'blue', action: { type: 'submit' } }
    ]);
  }

  if (createClicked) {
    // ...create item in your system, then confirm:
    return res.json([
      { type: 'link', title: 'Linked with:', text: 'Item #123', href: 'https://example.com/items/123' },
      { type: 'button', id: 'button-action-unlink', label: 'Unlink item', style: 'blue', action: { type: 'submit' } }
    ]);
  }

  return res.json([{ type: 'text', text: 'No action', style: 'paragraph' }]);
});

app.listen(3000, () => console.log('Canvas listening on :3000'));

Tips and gotchas

Treat the header check as the first thing your handler does. Any request that fails it should receive a 401 and nothing else.
Sleekplan accepts a single object, but arrays make intent obvious and are easier to extend when you need to render multiple components.
The id is the field name in subsequent payloads — renaming it mid-flow drops state and breaks your handler’s ability to detect which button was clicked.
See Inline errors for the exact shape Sleekplan expects when you need to surface a validation message.
Need extra help? Share your endpoint URL and a sample payload with support@sleekplan.com.