# desk2app quickstart

desk2app makes your own web software (CRM, dashboard, client portal, AI agent UI — built with Claude Code, Codex, Cursor, Lovable, Bolt, Replit or by hand) available in one mobile app for iOS and Android. Your users open your portal in the app, receive push notifications that open the right page, and approve AI actions with Face ID.

You keep hosting your own software. desk2app loads your portal directly from your server and stores only the metadata needed for pairing and notifications.

## Option A: let your AI assistant do it (recommended)

Add the MCP server to your coding tool, then ask: *"Make my app available on mobile with desk2app."*

```bash
# Claude Code
claude mcp add desk2app -e DESK2APP_API_URL=https://desk2app.digeo.nl -- npx -y @desk2app/mcp

# Codex (~/.codex/config.toml)
[mcp_servers.desk2app]
command = "npx"
args = ["-y", "@desk2app/mcp"]
env = { DESK2APP_API_URL = "https://desk2app.digeo.nl" }

# Cursor (.cursor/mcp.json)
{ "mcpServers": { "desk2app": { "command": "npx", "args": ["-y", "@desk2app/mcp"], "env": { "DESK2APP_API_URL": "https://desk2app.digeo.nl" } } } }
```

The assistant logs in via your browser (you approve; no key in the chat), registers your project, verifies your domain, writes the server key to your `.env`, adds a "Connect mobile app" button and sends a test notification.

## Option B: do it yourself (5 minutes)

1. Create a free account at https://desk2app.digeo.nl/signup and add a project with your portal's https URL.
2. Verify the domain: serve `/.well-known/desk2app-verify.txt` with the token from the dashboard (or add a DNS TXT record `_desk2app.<your-host>`).
3. Create a server key and store it as `DESK2APP_API_KEY` in your server environment. **Never use it in frontend code.**
4. Install the SDK: `npm install @desk2app/sdk`

### Let a logged-in user connect their phone

```ts
import { Desk2App } from '@desk2app/sdk';
const d2a = new Desk2App(); // reads DESK2APP_API_KEY and DESK2APP_API_URL

// in a server route for the logged-in user:
const link = await d2a.pairing.create({ userId: user.id, displayName: user.name });
// show link.url as a button/link and as a QR code, plus link.code
```

The user scans the QR with the desk2app app (or pastes the link/code, or taps the link inside the app). Your portal appears as a tile in the app.

### Send a notification

```ts
await d2a.notifications.send({
  userId: user.id,
  title: 'New lead',
  body: 'You have received a new inquiry.',
  deepLink: '/leads/123', // path on your verified domain
});
```

Without the SDK (any language):

```bash
curl -X POST https://desk2app.digeo.nl/v1/notifications \
  -H "Authorization: Bearer $DESK2APP_API_KEY" -H "Content-Type: application/json" \
  -d '{"userId":"42","title":"New lead","body":"You have received a new inquiry.","deepLink":"/leads/123"}'
```

### Ask for approval (human in the loop for AI agents)

```ts
const req = await d2a.approvals.request({
  userId: user.id,
  title: 'Send quote Q-2041?',
  body: '€4,850 to Jansen Bouw B.V.',
  deepLink: '/quotes/2041',
});
// The user approves or rejects with Face ID. Poll d2a.approvals.get(req.id) or receive a webhook:
```

```ts
import { verifyWebhook } from '@desk2app/sdk';
// POST /api/desk2app/webhook — use the RAW body
const event = await verifyWebhook(rawBody, req.headers['desk2app-signature'], process.env.DESK2APP_WEBHOOK_SECRET!);
if (event.type === 'approval.decided' && event.data.decision === 'approve') { /* send the quote */ }
```

## Good to know

- **Statuses are honest:** `accepted` → `sent_to_provider` → `delivered_to_provider` → `received`/`opened` (confirmed by the phone). We never claim delivery we cannot verify.
- **No sensitive data in notifications:** title and body can show on the lock screen. Put details behind the deep link.
- **Limits (Free):** 1 project, 1 connected user, 100 notification deliveries per month. Errors use stable codes such as `plan_limit_reached`, `invalid_deep_link`, `domain_not_verified`.
- **Your portal's login stays yours.** desk2app never sees or stores your users' passwords.
- **Not allowed inside the app:** selling digital goods or subscriptions in your portal (App Store rules). Physical goods and normal business software are fine.

API reference: https://desk2app.digeo.nl/openapi.json
