Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.safefetch.dev/llms.txt

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

1. Get your API key

Sign up at safefetch.dev to get an API key. Your key looks like sf_live_....

2. Install the SDK

npm install safefetch

3. Send your first action

Set your API key and call safeFetch():
import { safeFetch } from "safefetch";

// SAFEFETCH_API_KEY is read from env automatically
const action = await safeFetch({
  url: "https://api.example.com/send-email",
  body: { to: "user@example.com", subject: "Hello from AI" },
  approve: true,   // pause for human approval before delivery
  retries: 3,
});

console.log(action.id);     // act_01jq...
console.log(action.status); // "awaiting_approval"

4. Response shape

Every safeFetch() call returns an action object:
{
  "id": "act_01jq...",
  "status": "awaiting_approval",
  "url": "https://api.example.com/send-email",
  "method": "POST",
  "body": { "to": "user@example.com", "subject": "Hello from AI" },
  "approve": true,
  "retries": 3,
  "attempts": 0,
  "created_at": "2025-01-01T00:00:00.000Z"
}
Once approved, status moves to "active" then "completed". A completed action also includes response_code, response_body, and duration_ms.

Next steps