Python

Integrasi AyoSend dengan Python menggunakan library httpx atau requests.

Install

pip install httpx

Python

import httpx, os

response = httpx.post(
    'https://api.ayosend.id/v1/emails',
    headers={'Authorization': f'Bearer {os.environ["AYOSEND_API_KEY"]}'},
    json={
        'from': 'Toko <no-reply@toko.com>',
        'to': ['pelanggan@email.com'],
        'subject': 'Kode OTP kamu',
        'html': '<p>Kode OTP: <strong>847291</strong></p>',
    }
)
print(response.json()['id'])