Create a project
Sign in to failpath.dev and create a new project. Once the project is created, copy your project key — it looks like
fp_project_xxx. You’ll use it in the next step to connect your repository.Initialize your repository
Run The
failpath init at the root of your repository, passing your project key:init command sets up everything Failpath needs in your repo:| File | What it does |
|---|---|
.env | Writes FAILPATH_PROJECT_KEY=fp_project_xxx so the CLI and SDK can read your project key locally |
.failpath/flows.json | Pulls your project’s current flow graph from the dashboard |
.failpath/AGENTS.md | Provides step-key guidance for instrumenting your code correctly |
.gitignore | Updated to exclude .env from version control |
Instrument a function
Import Each call to
createFailpathClient and wrap your backend logic with run() and step(). Use the flow.slug from .failpath/flows.json as the flow key passed to run(), and each node’s sdkStepKey as the key passed to step().The example below instruments a checkout handler with two steps:step() sends a running event before the wrapped function executes, then a success or error event when it completes. If the function throws, the SDK records the error and rethrows the original exception — your existing error handling is not affected.Publish your flow
Push your local flow graph to the Failpath dashboard:Before sending anything,
publish validates .failpath/flows.json and reports any structural errors. Once validation passes, your flow definition is live on the dashboard and ready to receive events from your instrumented functions.The
.env file created by init is enough for local development, but you also need to set FAILPATH_PROJECT_KEY in your deployment environment. Platforms such as Vercel, Railway, and Convex each have their own environment variable configuration — add FAILPATH_PROJECT_KEY there so your deployed backend can send events to Failpath.