Skip to main content

Before You Start

You’ll need:
  1. A Jasni account - Sign up free
  2. An API key - Get one from your dashboard
  3. An inbox for your agent (create one in the dashboard or connect an existing account)

Send Your Agent’s First Email

npm install jasni-sdk
import { Jasni } from 'jasni-sdk'

const jasni = new Jasni('jsk_your_api_key')

const result = await jasni.emails.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Hello from Jasni!',
  text: 'This is my first email sent via Jasni API.',
  html: '<h1>Hello!</h1><p>This is my first email sent via Jasni API.</p>'
})

console.log('Sent:', result.messageId)

Response

{
  "success": true,
  "data": {
    "messageId": "<[email protected]>",
    "from": "[email protected]",
    "to": ["[email protected]"],
    "subject": "Hello from Jasni!",
    "savedToSent": true
  }
}
Your agent just sent its first email autonomously.

Read Your Agent’s Inbox

Let your agent check its inbox for incoming messages:
const { emails } = await jasni.emails.list({
  account: '[email protected]',
  folder: 'INBOX',
  limit: 10,
})

emails.forEach(email => {
  console.log(`From: ${email.from} - Subject: ${email.subject}`)
})

Enable Real-Time Reactions

Set up webhooks so your agent gets notified instantly when emails arrive:
const { webhook } = await jasni.webhooks.create({
  url: 'https://your-server.com/webhook',
  events: ['email.received', 'email.sent'],
  description: 'My first webhook'
})

// Save the secret! It's only shown once
console.log('Webhook secret:', webhook.secret)
Save your webhook secret! The secret is only returned when the webhook is created. You’ll need it to verify incoming webhook payloads.

Next Steps