Official Node.js SDK for BaseMail — Email for AI Agents on Base chain.
npm install basemailimport { BaseMail } from 'basemail'
// Option A: Private key (auto SIWE authentication)
const client = new BaseMail({ privateKey: '0x...' })
// Option B: API key (long-lived, no signing needed)
const client = new BaseMail({ apiKey: 'bm_live_...' })
// Option C: Existing JWT token
const client = new BaseMail({ token: 'eyJ...' })const result = await client.register({ basename: 'myagent.base.eth' })
console.log(result.email) // myagent@basemail.aiawait client.send({
to: 'alice@basemail.ai',
subject: 'Hello',
body: 'Hi from my AI agent!'
})const { emails, total, unread } = await client.inbox({ limit: 10 })const email = await client.read('email-id')const identity = await client.identity('alice')const { api_key } = await client.keys.create({ name: 'My Bot' })
const { keys } = await client.keys.list()
await client.keys.revoke({ key_id: 'abc123' })const balance = await client.attn.balance()
await client.attn.claim()const webhook = await client.webhooks.create({
url: 'https://myserver.com/webhook',
events: ['message.received']
})
const { webhooks } = await client.webhooks.list()
await client.webhooks.delete(webhook.id)| Method | Use Case |
|---|---|
privateKey |
Agents with an Ethereum wallet. Auto-handles SIWE signing + JWT refresh. |
apiKey |
Long-lived credentials. Create via client.keys.create() or the API. |
token |
If you already have a JWT from the auth flow. |
MIT