Quickstart

Create a Bytesms API key, send a test email, verify a domain and send your first real email — with cURL, Node.js, Python, PHP, Go and SMTP examples.

1. Create an API key

Sign up, open Dashboard → API Keys and create a key. Keys start with tp_live_ and are shown once — store it in a secret manager or an environment variable such as BYTESMS_API_KEY. See Authentication for the permission levels.

2. Send a test email right away

Before you verify a domain you can already send from [email protected] but only to your own account email and to the @test.bytesms.com test addresses:

# Send a test email
curl -X POST 'https://api.bytesms.com/api/v1/emails' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{"from":"Bytesms <[email protected]>","to":["[email protected]"],"subject":"Hello from Bytesms","html":"<p>It works!</p>"}'
Response
{
  "id": "cmg4k2x7a0001l8v9h3q2d5rt"
}

3. Add and verify your domain

To send to anyone else, add a domain you own. Use a subdomain such as mail.example.com if you want to keep sending reputation separate from your root domain.

# Add a domain
curl -X POST 'https://api.bytesms.com/api/v1/domains' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{"name":"example.com"}'

The response lists the DNS records to publish at your DNS provider — a DKIM TXT record and a return-path CNAME (plus recommended SPF and DMARC records). After publishing them, trigger a check:

# Verify the domain
curl -X POST 'https://api.bytesms.com/api/v1/domains/{domain_id}/verify' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx'

Verification is also re-checked automatically every few minutes; the domain moves from pending to verified once the DKIM record and the return path (or SPF) resolve. Details: Domains.

4. Send your first real email

# Send an email
curl -X POST 'https://api.bytesms.com/api/v1/emails' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{"from":"Acme <[email protected]>","to":["[email protected]"],"subject":"Welcome to Acme","html":"<h1>Welcome!</h1><p>Thanks for signing up.</p>"}'

5. Track what happens

  1. Poll GET /api/v1/emails/{id} — its last_event becomes sent, then delivered (or bounced).
  2. Or add a webhook endpoint and receive email.delivered, email.bounced and the other events as they happen.

Other ways to send

Bytesms SDK for TypeScript and JavaScript

The official @bytesms/sdk package wraps the REST API with types, { data, error } results, idempotency keys, automatic retries and webhook verification. It runs on Node.js 18+, Bun, Deno and edge runtimes. Details: TypeScript SDK.

// npm install @bytesms/sdk
import { Bytesms } from "@bytesms/sdk";

const bytesms = new Bytesms(process.env.BYTESMS_API_KEY);

const { data, error } = await bytesms.emails.send(
  {
    from: "Acme <[email protected]>",
    to: "[email protected]",
    subject: "Hello from Bytesms",
    html: "<p>It works!</p>",
  },
  { idempotencyKey: "hello-1" },
);
console.log(data ?? error);

SMTP

Any SMTP client works: host smtp.bytesms.com, port 465 (TLS) or 587 (STARTTLS), username bytesms, password = your API key. The same sending rules and quotas apply; attachments are rejected. Details: SMTP.

import nodemailer from "nodemailer";

const transporter = nodemailer.createTransport({
  host: "smtp.bytesms.com",
  port: 465,
  secure: true, // implicit TLS; use port 587 with secure: false for STARTTLS
  auth: { user: "bytesms", pass: process.env.BYTESMS_API_KEY },
});

const info = await transporter.sendMail({
  from: "Acme <[email protected]>",
  to: "[email protected]",
  subject: "Hello from Bytesms",
  html: "<p>It works!</p>",
});
console.log(info.messageId);

Resend SDKs

The REST API is Resend-style, so the official resend SDKs for Node.js and Python can send through Bytesms when you point them at https://api.bytesms.com/api/v1. We tested sending, batch sending, retrieving an email, listing domains and error handling. Only the parameters documented here are accepted, and attachments are not supported. Other Resend SDKs and Resend endpoints that aren't in these docs are untested, so for other languages call the REST API directly (the PHP and Go tabs above).

import { Resend } from "resend";

// resend >= 6: pass baseUrl. Any version: set RESEND_BASE_URL=https://api.bytesms.com/api/v1 instead.
const resend = new Resend(process.env.BYTESMS_API_KEY, { baseUrl: "https://api.bytesms.com/api/v1" });

const { data, error } = await resend.emails.send({
  from: "Acme <[email protected]>",
  to: ["[email protected]"],
  subject: "Hello from Bytesms",
  html: "<p>It works!</p>",
});
console.log(data ?? error);

Keep keys on the server

Never ship an API key in browser or mobile code. For a key that can only send (and only from one domain), create a sending-access key.