API reference
Errors
Deckle uses conventional HTTP status codes and returns a JSON error message on every failure.
A 2xx status means success. A 4xx indicates a problem with your request; a 5xx indicates a problem on Deckle’s side.
Error shape#
Every non-2xx response has the same body: a single human-readable message.
json
{
"error": "'to' must be a valid email address."
}Status codes#
| Code | Meaning |
|---|---|
200 / 201 | Success. Created resources return 201. |
202 | Accepted and queued (for example, an async send or campaign). |
400 | The request body was not valid JSON. |
401 | Missing or invalid secret API key. |
403 | Forbidden — e.g. a test key attempting a live-only action. |
404 | The resource does not exist or is not in your project. |
409 | Conflict — e.g. editing a campaign that has already sent. |
422 | Validation failed. The message names the field or rule. |
429 | Rate limit exceeded. Retry after the Retry-After header. |
5xx | Something went wrong on Deckle’s side, or delivery via SES failed (502). |
Handling errors in the SDK#
The Node.js SDK throws a DeckleError for any non-2xx response, exposing status, message, and the raw body.
ts
import { DeckleError } from "@deckle/sdk";
try {
await deckle.emails.send({ /* … */ });
} catch (err) {
if (err instanceof DeckleError) {
console.error(err.status, err.message);
}
}