Before You Start
You’ll need:
- A Jasni account - Sign up free
- An API key - Get one from your dashboard
- An inbox for your agent (create one in the dashboard or connect an existing account)
Send Your Agent’s First Email
TypeScript SDK
cURL
JavaScript
Python
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)
curl -X POST https://api.jasni.ai/api/v1/emails/send \
-H "Authorization: Bearer jsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"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>"
}'
const response = await fetch('https://api.jasni.ai/api/v1/emails/send', {
method: 'POST',
headers: {
'Authorization': 'Bearer jsk_your_api_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
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>'
}),
});
const data = await response.json();
console.log(data);
import requests
response = requests.post(
'https://api.jasni.ai/api/v1/emails/send',
headers={
'Authorization': 'Bearer jsk_your_api_key',
'Content-Type': 'application/json',
},
json={
'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>'
}
)
print(response.json())
Response
Your agent just sent its first email autonomously.
Read Your Agent’s Inbox
Let your agent check its inbox for incoming messages:
TypeScript SDK
cURL
JavaScript
Python
const { emails } = await jasni.emails.list({
account: '[email protected]',
folder: 'INBOX',
limit: 10,
})
emails.forEach(email => {
console.log(`From: ${email.from} - Subject: ${email.subject}`)
})
curl -X GET "https://api.jasni.ai/api/v1/[email protected]&folder=INBOX&limit=10" \
-H "Authorization: Bearer jsk_your_api_key"
const response = await fetch(
'https://api.jasni.ai/api/v1/[email protected]&folder=INBOX&limit=10',
{
headers: {
'Authorization': 'Bearer jsk_your_api_key',
},
}
);
const data = await response.json();
console.log(data.data.emails);
import requests
response = requests.get(
'https://api.jasni.ai/api/v1/emails',
headers={
'Authorization': 'Bearer jsk_your_api_key',
},
params={
'account': '[email protected]',
'folder': 'INBOX',
'limit': 10
}
)
emails = response.json()['data']['emails']
for email in emails:
print(f"From: {email['from']} - Subject: {email['subject']}")
Enable Real-Time Reactions
Set up webhooks so your agent gets notified instantly when emails arrive:
TypeScript SDK
cURL
JavaScript
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)
curl -X POST https://api.jasni.ai/api/v1/webhooks \
-H "Authorization: Bearer jsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-server.com/webhook",
"events": ["email.received", "email.sent"],
"description": "My first webhook"
}'
const response = await fetch('https://api.jasni.ai/api/v1/webhooks', {
method: 'POST',
headers: {
'Authorization': 'Bearer jsk_your_api_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://your-server.com/webhook',
events: ['email.received', 'email.sent'],
description: 'My first webhook'
}),
});
const data = await response.json();
// Save the secret! It's only shown once
console.log('Webhook secret:', data.data.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