import "dotenv/config"

const API_KEY = process.env.SMTP2GO_API_KEY
if (!API_KEY) throw new Error('Missing SMTP2GO_API_KEY')

const BASE = 'https://api.smtp2go.com/v3'

async function main() {
  const res = await fetch(`${BASE}/subaccounts/search`, {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({ api_key: API_KEY, fuzzy_search: true, states: 'all', sort_direction: 'asc', page_size: 20 }),
  })

  const json = await res.json().catch(() => ({}))
  console.log('status', res.status)
  console.dir(json, { depth: 3 })
}

main().catch((e) => { console.error(e); process.exit(1) })
