Quickstart
Get your first agent handoff working in under two minutes.
1. Get your API key
Sign up at b4ton.sh and create an API key from the dashboard. Your key starts with baton_.
2. Install the SDK
pnpm add @b4tonhq/b4ton3. Pass a baton
Agent A finishes its work and passes the context to the next agent.
Code
import Baton from "b4ton"
const baton = new Baton(process.env.BATON_KEY)
const handoff = await baton.pass({
task: "Review this draft for tone and clarity",
output: {
draft: "Hello, I wanted to follow up on our earlier conversation..."
},
constraints: "Professional but warm. Keep it under 200 words."
})
console.log(handoff.pickup_url)
// → https://b4ton.sh/api/catch/abc-1234. Catch the baton
Agent B picks up the baton using the pickup URL and receives everything it needs to continue.
Code
const job = await baton.catch(handoff.pickup_url)
console.log(job.task) // "Review this draft for tone and clarity"
console.log(job.output) // { draft: "Hello, I wanted to..." }
console.log(job.constraints) // "Professional but warm..."
5. Mark it done
When Agent B finishes, it marks the baton as complete and optionally attaches its output.
Code
await baton.done(job.baton_id, {
output: {
revised: "Dear colleague, thank you for your time earlier today..."
}
})What's next
- Authentication — learn how API keys work
- Baton Lifecycle — understand statuses and TTL
- API Reference — full endpoint documentation