# Node SDK: always branch on the error half

`resend.emails.send` resolves to an object with two halves. API-level failures
(unknown domain, bad from address, rate limits) arrive in `error`, not as a
thrown exception. Code that only reads `data` treats failures as successes.

## The shape

```js
import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

const { data, error } = await resend.emails.send({
  from: '[SENDER]',
  to: ['[RECIPIENT]'],
  subject: 'Hello World',
  html: '&lt;strong&gt;It works!&lt;/strong&gt;',
});

if (error) {
  console.error(error);
  process.exitCode = 1;
} else {
  console.log('sent', data.id);
}
```

## Checklist

- Read the key from `process.env.RESEND_API_KEY`. Never paste the key into source.
- Branch on `error` immediately after every send. `data` is only meaningful when
  `error` is empty.
- `data.id` is the id of the created email. Log it; you will need it when
  debugging delivery later.
- A try/catch around the call still makes sense for transport failures (DNS,
  network), but it will not catch API errors. You need both.
- The from address must belong to a verified domain, or the error half tells
  you so with a 403.