Skip to main content
POST
/
sandbox
/
gmail
/
{sandbox_id}
/
initialize
Initialize gmail sandbox with data
curl --request POST \
  --url https://api.klavis.ai/sandbox/gmail/{sandbox_id}/initialize \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data @- <<EOF
{
  "messages": [
    {
      "subject": "Weekly Team Update",
      "to": "johndoe@klavis.ai",
      "cc": "johndoe@klavis.ai",
      "body": "Hi Team,\n\nHere's our weekly update:\n\n1. Project A is on track\n2. Sprint planning next week\n3. New hire starting Monday\n\nBest regards",
      "labels": [
        "INBOX",
        "IMPORTANT"
      ]
    },
    {
      "subject": "Project Status Report",
      "to": "johndoe@klavis.ai",
      "body": "Dear Client,\n\nI'm writing to update you on the project status. All milestones are being met on schedule.\n\nKey accomplishments this week:\n- Completed Phase 1\n- Initiated Phase 2\n- Stakeholder review meeting scheduled\n\nLooking forward to our next meeting.\n\nBest regards",
      "labels": [
        "INBOX"
      ]
    },
    {
      "subject": "Follow-up on Support Ticket #12345",
      "to": "johndoe@klavis.ai",
      "body": "Hello Support Team,\n\nI wanted to follow up on ticket #12345. Has there been any progress on this issue?\n\nThank you for your assistance.\n\nBest regards",
      "labels": [
        "INBOX"
      ]
    },
    {
      "subject": "Meeting Notes - Q4 Planning",
      "to": "johndoe@klavis.ai",
      "cc": "johndoe@klavis.ai",
      "body": "Hi everyone,\n\nAttached are the notes from our Q4 planning session:\n\n- Budget allocation approved\n- New initiatives prioritized\n- Timeline established\n\nPlease review and provide feedback by EOW.\n\nThanks",
      "labels": [
        "INBOX",
        "CATEGORY_UPDATES"
      ]
    },
    {
      "subject": "Quarterly Review Reminder",
      "to": "johndoe@klavis.ai",
      "body": "Team,\n\nFriendly reminder that quarterly reviews are due next Friday.\n\nPlease complete your self-assessment and submit to your manager.\n\nThank you!",
      "labels": [
        "INBOX"
      ]
    }
  ],
  "drafts": [
    {
      "subject": "Re: Partnership Proposal",
      "to": "partner@example.com",
      "body": "Hi there,\n\nThank you for reaching out regarding the partnership opportunity. I'm very interested in learning more.\n\nCould we schedule a call next week to discuss further?\n\nBest regards"
    },
    {
      "subject": "Vacation Request - December",
      "to": "hr@example.com",
      "cc": "manager@example.com",
      "body": "Dear HR,\n\nI would like to request vacation time from December 20-30, 2024.\n\nPlease let me know if you need any additional information.\n\nThank you"
    },
    {
      "subject": "Product Feedback",
      "to": "product@example.com",
      "body": "Hi Product Team,\n\nI wanted to share some feedback on the recent update:\n\n1. The new dashboard is much more intuitive\n2. Performance has improved significantly\n3. One suggestion: add keyboard shortcuts\n\nOverall, great work!\n\nBest"
    }
  ]
}
EOF
import requests

url = "https://api.klavis.ai/sandbox/gmail/{sandbox_id}/initialize"

payload = {
"messages": [
{
"subject": "Weekly Team Update",
"to": "johndoe@klavis.ai",
"cc": "johndoe@klavis.ai",
"body": "Hi Team,

Here's our weekly update:

1. Project A is on track
2. Sprint planning next week
3. New hire starting Monday

Best regards",
"labels": ["INBOX", "IMPORTANT"]
},
{
"subject": "Project Status Report",
"to": "johndoe@klavis.ai",
"body": "Dear Client,

I'm writing to update you on the project status. All milestones are being met on schedule.

Key accomplishments this week:
- Completed Phase 1
- Initiated Phase 2
- Stakeholder review meeting scheduled

Looking forward to our next meeting.

Best regards",
"labels": ["INBOX"]
},
{
"subject": "Follow-up on Support Ticket #12345",
"to": "johndoe@klavis.ai",
"body": "Hello Support Team,

I wanted to follow up on ticket #12345. Has there been any progress on this issue?

Thank you for your assistance.

Best regards",
"labels": ["INBOX"]
},
{
"subject": "Meeting Notes - Q4 Planning",
"to": "johndoe@klavis.ai",
"cc": "johndoe@klavis.ai",
"body": "Hi everyone,

Attached are the notes from our Q4 planning session:

- Budget allocation approved
- New initiatives prioritized
- Timeline established

Please review and provide feedback by EOW.

Thanks",
"labels": ["INBOX", "CATEGORY_UPDATES"]
},
{
"subject": "Quarterly Review Reminder",
"to": "johndoe@klavis.ai",
"body": "Team,

Friendly reminder that quarterly reviews are due next Friday.

Please complete your self-assessment and submit to your manager.

Thank you!",
"labels": ["INBOX"]
}
],
"drafts": [
{
"subject": "Re: Partnership Proposal",
"to": "partner@example.com",
"body": "Hi there,

Thank you for reaching out regarding the partnership opportunity. I'm very interested in learning more.

Could we schedule a call next week to discuss further?

Best regards"
},
{
"subject": "Vacation Request - December",
"to": "hr@example.com",
"cc": "manager@example.com",
"body": "Dear HR,

I would like to request vacation time from December 20-30, 2024.

Please let me know if you need any additional information.

Thank you"
},
{
"subject": "Product Feedback",
"to": "product@example.com",
"body": "Hi Product Team,

I wanted to share some feedback on the recent update:

1. The new dashboard is much more intuitive
2. Performance has improved significantly
3. One suggestion: add keyboard shortcuts

Overall, great work!

Best"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [
{
subject: 'Weekly Team Update',
to: 'johndoe@klavis.ai',
cc: 'johndoe@klavis.ai',
body: JSON.stringify('Hi Team,\n\nHere\'s our weekly update:\n\n1. Project A is on track\n2. Sprint planning next week\n3. New hire starting Monday\n\nBest regards'),
labels: ['INBOX', 'IMPORTANT']
},
{
subject: 'Project Status Report',
to: 'johndoe@klavis.ai',
body: JSON.stringify('Dear Client,\n\nI\'m writing to update you on the project status. All milestones are being met on schedule.\n\nKey accomplishments this week:\n- Completed Phase 1\n- Initiated Phase 2\n- Stakeholder review meeting scheduled\n\nLooking forward to our next meeting.\n\nBest regards'),
labels: ['INBOX']
},
{
subject: 'Follow-up on Support Ticket #12345',
to: 'johndoe@klavis.ai',
body: JSON.stringify('Hello Support Team,\n\nI wanted to follow up on ticket #12345. Has there been any progress on this issue?\n\nThank you for your assistance.\n\nBest regards'),
labels: ['INBOX']
},
{
subject: 'Meeting Notes - Q4 Planning',
to: 'johndoe@klavis.ai',
cc: 'johndoe@klavis.ai',
body: JSON.stringify('Hi everyone,\n\nAttached are the notes from our Q4 planning session:\n\n- Budget allocation approved\n- New initiatives prioritized\n- Timeline established\n\nPlease review and provide feedback by EOW.\n\nThanks'),
labels: ['INBOX', 'CATEGORY_UPDATES']
},
{
subject: 'Quarterly Review Reminder',
to: 'johndoe@klavis.ai',
body: JSON.stringify('Team,\n\nFriendly reminder that quarterly reviews are due next Friday.\n\nPlease complete your self-assessment and submit to your manager.\n\nThank you!'),
labels: ['INBOX']
}
],
drafts: [
{
subject: 'Re: Partnership Proposal',
to: 'partner@example.com',
body: JSON.stringify('Hi there,\n\nThank you for reaching out regarding the partnership opportunity. I\'m very interested in learning more.\n\nCould we schedule a call next week to discuss further?\n\nBest regards')
},
{
subject: 'Vacation Request - December',
to: 'hr@example.com',
cc: 'manager@example.com',
body: JSON.stringify('Dear HR,\n\nI would like to request vacation time from December 20-30, 2024.\n\nPlease let me know if you need any additional information.\n\nThank you')
},
{
subject: 'Product Feedback',
to: 'product@example.com',
body: JSON.stringify('Hi Product Team,\n\nI wanted to share some feedback on the recent update:\n\n1. The new dashboard is much more intuitive\n2. Performance has improved significantly\n3. One suggestion: add keyboard shortcuts\n\nOverall, great work!\n\nBest')
}
]
})
};

fetch('https://api.klavis.ai/sandbox/gmail/{sandbox_id}/initialize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [
{
subject: 'Weekly Team Update',
to: 'johndoe@klavis.ai',
cc: 'johndoe@klavis.ai',
body: JSON.stringify('Hi Team,\n\nHere\'s our weekly update:\n\n1. Project A is on track\n2. Sprint planning next week\n3. New hire starting Monday\n\nBest regards'),
labels: ['INBOX', 'IMPORTANT']
},
{
subject: 'Project Status Report',
to: 'johndoe@klavis.ai',
body: JSON.stringify('Dear Client,\n\nI\'m writing to update you on the project status. All milestones are being met on schedule.\n\nKey accomplishments this week:\n- Completed Phase 1\n- Initiated Phase 2\n- Stakeholder review meeting scheduled\n\nLooking forward to our next meeting.\n\nBest regards'),
labels: ['INBOX']
},
{
subject: 'Follow-up on Support Ticket #12345',
to: 'johndoe@klavis.ai',
body: JSON.stringify('Hello Support Team,\n\nI wanted to follow up on ticket #12345. Has there been any progress on this issue?\n\nThank you for your assistance.\n\nBest regards'),
labels: ['INBOX']
},
{
subject: 'Meeting Notes - Q4 Planning',
to: 'johndoe@klavis.ai',
cc: 'johndoe@klavis.ai',
body: JSON.stringify('Hi everyone,\n\nAttached are the notes from our Q4 planning session:\n\n- Budget allocation approved\n- New initiatives prioritized\n- Timeline established\n\nPlease review and provide feedback by EOW.\n\nThanks'),
labels: ['INBOX', 'CATEGORY_UPDATES']
},
{
subject: 'Quarterly Review Reminder',
to: 'johndoe@klavis.ai',
body: JSON.stringify('Team,\n\nFriendly reminder that quarterly reviews are due next Friday.\n\nPlease complete your self-assessment and submit to your manager.\n\nThank you!'),
labels: ['INBOX']
}
],
drafts: [
{
subject: 'Re: Partnership Proposal',
to: 'partner@example.com',
body: JSON.stringify('Hi there,\n\nThank you for reaching out regarding the partnership opportunity. I\'m very interested in learning more.\n\nCould we schedule a call next week to discuss further?\n\nBest regards')
},
{
subject: 'Vacation Request - December',
to: 'hr@example.com',
cc: 'manager@example.com',
body: JSON.stringify('Dear HR,\n\nI would like to request vacation time from December 20-30, 2024.\n\nPlease let me know if you need any additional information.\n\nThank you')
},
{
subject: 'Product Feedback',
to: 'product@example.com',
body: JSON.stringify('Hi Product Team,\n\nI wanted to share some feedback on the recent update:\n\n1. The new dashboard is much more intuitive\n2. Performance has improved significantly\n3. One suggestion: add keyboard shortcuts\n\nOverall, great work!\n\nBest')
}
]
})
};

fetch('https://api.klavis.ai/sandbox/gmail/{sandbox_id}/initialize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
{
  "sandbox_id": "<string>",
  "message": "<string>"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}

Authorizations

Authorization
string
header
required

Your Klavis AI API key.

Path Parameters

sandbox_id
string
required

The unique sandbox identifier

Query Parameters

init_default_data
boolean
default:false

If true, use default test data for initialization

Body

application/json

Complete Gmail sandbox data structure with all supported objects

messages
GmailMessage · object[] | null

List of Gmail messages to send

drafts
GmailDraft · object[] | null

List of Gmail drafts to create

Response

Successful Response

Response model for sandbox initialization

sandbox_id
string
required

Sandbox identifier

status
enum<string>
required

Current status

Available options:
idle,
occupied,
error
message
string
required

Initialization result message