yawn.ai/docs/integration
…/integration
Sign In
Docs
YawnConnect SDKHandshake FlowApproval via Email/SMSWebhooksAgent Instructions
GitHub

Integration Guide

Connect to Yawn.ai

Integrate any system — human or AI agent — with the Yawn.ai platform via the YawnConnect SDK, enterprise handshake protocol, and approval-gated email/SMS flow.

YawnConnect SDK

The TypeScript SDK provides a simple interface for connecting to the yawn.ai network from any server-side application.

Install
# Copy connect/yawn-connect.ts into your project's lib/ directory
# No npm package required — it's a single-file SDK
Initialize
import { YawnConnect } from '@/lib/yawn-connect'

const yawn = new YawnConnect({
  apiKey: process.env.YAWN_API_KEY!,   // yawn_sk_...
  yawnSlug: 'your-yawn-slug',
  baseUrl: 'https://yawn.ai',         // default
})
Usage
// Establish handshake with another yawn
await yawn.handshake('parent-yawn-slug', 'child')

// Submit evidence
await yawn.submitEvidence('yawn-uuid', {
  type: 'link',
  content: 'Customer purchase completed',
  proof_url: 'https://your-site.com/receipt/123',
})

// Check connection status
const status = await yawn.ping()
// → { status: 'ok', connected: true }

Environment variables

# .env (never commit)
YAWN_API_KEY=yawn_sk_your_key_here
YAWN_BASE_URL=https://yawn.ai

Capture endpoints

Use POST /api/thoughts/capture for free-text → Seed yawn_files row. Workflow and trigger capture hit different tables; see docs/api/ENDPOINT_INVENTORY.md in the repo.

RouteCreates yawnPurpose
POST /api/thoughts/captureYes (Seed)Canonical NL capture
POST /api/triggers/capturePipeline-specificTriggers / mobile
POST /api/workflows/captureNoBrowser workflow recording

Handshake Flow

The enterprise handshake creates a bidirectional link between two yawns. This is how external systems discover, connect, and exchange data with the yawn.ai network.

1
Get API key — Sign up at yawn.ai/jobs, verify email, receive yawn_sk_...
2
Create your yawn — POST /api/thoughts/capture with your intention
3
Establish handshake — POST /api/enterprise/handshake with source and target slugs
4
System creates links — Bidirectional yawn_links created (forward + inverse)
5
Logged to inbox — api_handshake inbox item created for audit trail
6
Connected — Your yawn is now part of the network

Link types

TypeInverseUse case
forkforked_fromYawn derived from another
parent_childchild_ofHierarchical relationship
inheritsinherited_byPolicy/rule inheritance
referencesreferenced_byKnowledge reference

Approval via Email / SMS

When an action requires human approval (risk level: critical, or policy escalation), the system sends a notification via SendGrid email and/or Twilio SMS with one-click approve/reject links.

Email (SendGrid)

HTML email with action description, risk level, and one-click approve/reject buttons. Links expire with the approval request (24h default).

SMS (Twilio)

Short message with approve link. Reply YES to approve or NO to reject. Inbound SMS handled by Twilio webhook.

Approval flow

Action requires approval (PDP returns "escalate")
  ↓
approval_requests row created (status: pending)
  ↓
DB trigger mirrors to inbox_items
  ↓
approval_notify job enqueued
  ↓
Heartbeat processes job:
  → SendGrid email with approve/reject links
  → Twilio SMS with approve link
  ↓
User clicks approve link in email
  ↓
GET /api/approve/{token}?action=approve
  ↓
approval_requests.status → "approved"
inbox_items.approval_status → "approved"
  ↓
System executes approved action

Webhooks

Yawn.ai can receive webhooks from external services. All webhook endpoints are excluded from auth middleware.

EndpointSourceAuth
/api/webhooks/stripeStripeStripe signature
/api/webhooks/github/{id}GitHubHMAC-SHA256
/api/webhooks/twilio/inboundTwilioTwilio signature
/api/webhooks/twilio/statusTwilioTwilio signature

AI Agent Integration Instructions

Copy these instructions into any AI coding agent (Google AI Studio, Claude, Codex, Cursor) to enable autonomous integration with Yawn.ai.

Agent Onboarding Spec

# Yawn.ai Integration Instructions for AI Agents
# Version: 1.0.0 | Base URL: https://yawn.ai/api

## What is Yawn.ai?
Yawn.ai is an AI orchestration platform that turns raw intentions into
structured, evidence-backed outcomes. A "yawn" is a relationship contract
between an entity and something they care about.

## Core Loop: Capture → Structure → Experiment → Evidence → Promote
1. Capture raw text → creates a Seed yawn (L0)
2. Answer 18 fundamental questions → coherence score increases
3. Create experiments with hypotheses and success criteria
4. Submit evidence to prove outcomes
5. Coherence drives promotion: Seed → Yawn → Project → Venture → Company

## Authentication
Header: x-api-key: yawn_sk_your_key
Get key: sign up at yawn.ai/jobs, verify email, key revealed once.

## Step 1: Create a Yawn
POST /api/thoughts/capture
Content-Type: application/json
x-api-key: yawn_sk_...

{ "raw_text": "Your intention described in natural language" }

→ Returns: { yawnId, slug, coherenceScore }

## Step 2: Answer Fundamental Questions (loop until coherent)
POST /api/yawn/{yawnId}/questions
{ "questionId": "identity.awakening", "answer": "..." }

18 Questions in 6 Categories:
IDENTITY: awakening*, subject, target
POSITION: parent*, domain, keywords, inIndex
STATE: currentState*, desiredState*, blockers, boosters, boundaries
COMPLETION: conditions*, experiments, evidence
LEARNING: evolutionLog, emergenceNotes, dos, donts
RISK: vulnerabilities, earlyWarnings, mitigations
(* = critical for first promotion)

## Step 3: Check Coherence
GET /api/yawn/{yawnId}/questions
→ Returns: { assessment: { overall: { percentage, status }, nextQuestion } }
Status: critical (<70%), needs_attention (70-89%), coherent (≥90%)

## Step 4: Establish Handshake
POST /api/enterprise/handshake
{
  "source_slug": "your-yawn-slug",
  "target_slug": "target-yawn-slug",
  "link_type": "references",
  "capabilities": ["read", "reference"]
}
→ Creates bidirectional link, logged to inbox

## Step 5: Create Experiments
POST /api/yawn/{yawnId}/experiments
{
  "title": "...",
  "hypothesis": "If X then Y",
  "success_criteria": ["metric1", "metric2"]
}

## Step 6: Submit Evidence
POST /api/yawn/evidence
{
  "yawn_id": "uuid",
  "kind": "observation|artifact|test_log|screenshot|link|self_attest",
  "summary": "What was proven",
  "value": 15
}

## Verification (Self-Test)
1. Create yawn → verify yawnId returned
2. Answer 5 critical questions → verify coherence > 25%
3. Establish handshake → verify success: true
4. Submit evidence → verify evidence.id returned
5. Check coherence → verify score increased

## Approval System
Critical actions require human approval via email/SMS.
The system will notify the yawn owner; you do NOT need to handle this.
If an action returns { "escalated": true }, wait for approval.

## Key Endpoints Summary
POST /api/thoughts/capture          → Create yawn
GET  /api/yawn/{id}/questions       → Get coherence
POST /api/yawn/{id}/questions       → Answer question
POST /api/yawn/{id}/experiments     → Create experiment
POST /api/yawn/evidence             → Submit evidence
POST /api/enterprise/handshake      → Link yawns
GET  /api/health                    → Health check
GET  /api/yawn/protocol             → Protocol docs (JSON)

Self-testing loop

After integration, the agent should verify the loop by: (1) creating a yawn, (2) answering all 18 questions, (3) checking coherence reaches 70%+, (4) establishing a handshake, (5) submitting evidence that the integration works. If coherence is below 70%, there is a lacuna to fill.

Security Model

LayerProtection
TransportHTTPS/TLS for all requests
Authenticationyawn_sk_ API key or Supabase session
StorageAES-256-GCM encrypted at rest, decrypted server-side only
AuthorizationRLS policies, owner-scoped access
ApprovalHuman-in-the-loop for critical actions
AuditAll handshakes logged to inbox_items
API ReferenceGetting Started