# Quickstart (/docs/quickstart)

<Steps>
<Step>

### Create an API key [#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](/docs/environments).

```bash
export COSS_API_KEY=coss_test_...
```

Or, in your project's directory, let the [CLI](/docs/cli#set-a-project-up) 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](/docs/agents).

</Step>
<Step>

### Install the SDK [#install-the-sdk]

```package-install
coss
```

</Step>
<Step>

### Send an email [#send-an-email]

The client reads `COSS_API_KEY` from the environment when you don't pass `apiKey`.

```ts twoslash title="send.ts"
import { Coss } from "coss";

const coss = new Coss();

const { data, error } = await coss.email.send({
  from: "Acme <onboarding@acme.com>",
  to: "user@example.com",
  subject: "Hello from coss.com",
  html: "<p>It works!</p>",
});

if (error) {
  console.error(error.code, error.message);
} else {
  console.log(data.id, data.status);
  //                       ^?
}
```

Every method returns `{ data, error }` and never throws for API or network failures.

The same email from one of the [other SDKs](/docs/sdks), which read `COSS_API_KEY` too:

<Tabs items={["Python", "Go", "Ruby", "PHP", "Java", ".NET"]}>
<Tab value="Python">

```python
# 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)
```

</Tab>
<Tab value="Go">

```go
// go get github.com/cosscom/coss-go
client := cossclient.NewClient()
email, err := client.Email.Send(context.Background(), &coss.SendEmailBody{
	Body: &coss.SendEmailRequest{
		From:    "Acme <onboarding@acme.com>",
		To:      &coss.SendEmailRequestTo{StringList: []string{"user@example.com"}},
		Subject: coss.String("Hello from coss.com"),
		HTML:    coss.String("<p>It works!</p>"),
	},
})
```

</Tab>
<Tab value="Ruby">

```ruby
# bundle add coss
require "coss"

client = Coss::Client.new
email = client.email.send_(
  from: "Acme <onboarding@acme.com>",
  to: ["user@example.com"],
  subject: "Hello from coss.com",
  html: "<p>It works!</p>"
)
puts email.id, email.status
```

</Tab>
<Tab value="PHP">

```php
// composer require coss/coss
$client = new Coss\Coss();
$email = $client->email->send(new Coss\Email\Requests\SendEmailBody([
    'body' => new Coss\Types\SendEmailRequest([
        'from' => 'Acme <onboarding@acme.com>',
        'to' => ['user@example.com'],
        'subject' => 'Hello from coss.com',
        'html' => '<p>It works!</p>',
    ]),
]));
echo $email->id, ' ', $email->status;
```

</Tab>
<Tab value="Java">

```java
// implementation("com.coss:coss:0.1.0")
Coss client = Coss.builder().build();
Email email = client.email().send(SendEmailRequest.builder()
        .from("Acme <onboarding@acme.com>")
        .to(SendEmailRequestTo.of(Arrays.asList("user@example.com")))
        .subject("Hello from coss.com")
        .html("<p>It works!</p>")
        .build());
```

</Tab>
<Tab value=".NET">

```csharp
// dotnet add package Coss
var client = new Coss.CossClient();
var email = await client.Email.SendAsync(new Coss.SendEmailBody
{
    Body = new Coss.SendEmailRequest
    {
        From = "Acme <onboarding@acme.com>",
        To = new[] { "user@example.com" },
        Subject = "Hello from coss.com",
        Html = "<p>It works!</p>",
    },
});
```

</Tab>
</Tabs>

</Step>
<Step>

### Follow delivery [#follow-delivery]

Each recipient has its own delivery status. Fetch the email again, or
[subscribe to webhooks](/docs/webhooks) to be told when it changes.

```ts twoslash
import { Coss } from "coss";
const coss = new Coss();
// ---cut---
const { data: email } = await coss.email.get("email_01k7c8m4q2f3e9v6t5r1n0p8yz");

for (const recipient of email?.recipients ?? []) {
  console.log(recipient.address, recipient.status);
}
```

</Step>
</Steps>

When you are ready to deliver real email, [verify a domain](/docs/email/domains) and switch to a
key from the **Production** environment.
