Quickstart
Send your first email with the TypeScript SDK, or the SDK of another language.
Create an API key
In the dashboard, open your project's Development environment and create an API key. A new
organization starts with a project and opens there. Development
keys start with coss_test_: emails sent with them are recorded but never delivered, so you can
experiment freely. See Environments and API keys.
export COSS_API_KEY=coss_test_...Or, in your project's directory, let the CLI do this step and the
next: npx coss-cli init asks you to approve a development key for the project in the
dashboard (creating your account, organization and project on the way if you're new), writes it to .env.local (Next.js) or .env as COSS_API_KEY and installs the SDK.
Building with a coding agent? See Coding agents.
Install the SDK
npm install cossSend an email
The client reads COSS_API_KEY from the environment when you don't pass apiKey.
import { } from "coss";
const = new ();
const { , } = await ..({
: "Acme <onboarding@acme.com>",
: "user@example.com",
: "Hello from coss.com",
: "<p>It works!</p>",
});
if () {
.(., .);
} else {
.(., data.); const data: Email}Every method returns { data, error } and never throws for API or network failures.
The same email from one of the other SDKs, which read COSS_API_KEY too:
# pip install cosscom
from coss import Coss
client = Coss()
email = client.email.send(
from_="Acme <onboarding@acme.com>",
to=["user@example.com"],
subject="Hello from coss.com",
html="<p>It works!</p>",
)
print(email.id, email.status)Follow delivery
Each recipient has its own delivery status. Fetch the email again, or subscribe to webhooks to be told when it changes.
const { : } = await ..("email_01k7c8m4q2f3e9v6t5r1n0p8yz");
for (const of ?. ?? []) {
.(., .);
}When you are ready to deliver real email, verify a domain and switch to a key from the Production environment.
Last updated