130 lines
4.4 KiB
TypeScript
130 lines
4.4 KiB
TypeScript
import { PageHeader } from "@/app/page-header";
|
||
|
||
export const metadata = { title: "Courier – Dokumentation" };
|
||
|
||
export default function Docs() {
|
||
return (
|
||
<>
|
||
<PageHeader
|
||
title="Dokumentation"
|
||
lead="Die Courier-API ist weitgehend Resend-kompatibel. Basis-URL: /api"
|
||
code={false}
|
||
eyebrow="Courier"
|
||
/>
|
||
|
||
<section className="karte app-panel">
|
||
<h2>Authentifizierung</h2>
|
||
<p className="app-muted">
|
||
Jede Anfrage braucht einen API-Key als Bearer-Token. Der Key gilt nur für seine
|
||
Absenderdomain.
|
||
</p>
|
||
<pre className="app-code">{`Authorization: Bearer ck_live_…`}</pre>
|
||
</section>
|
||
|
||
<section className="karte app-panel app-section">
|
||
<h2>Mail senden</h2>
|
||
<pre className="app-code">{`curl -X POST https://<courier-adresse>/api/emails/ \\
|
||
-H "Authorization: Bearer ck_live_…" \\
|
||
-H "Content-Type: application/json" \\
|
||
-d '{
|
||
"from": "plan <plan@hubsport.club>",
|
||
"to": "kunde@example.com",
|
||
"subject": "Dein Anmeldelink",
|
||
"html": "<p>Hallo</p>",
|
||
"text": "Hallo"
|
||
}'`}</pre>
|
||
<p className="app-muted">
|
||
Unterstützt <code>from</code>, <code>to</code>, <code>cc</code>, <code>bcc</code>,{" "}
|
||
<code>reply_to</code>, <code>subject</code>, <code>html</code>, <code>text</code>,{" "}
|
||
<code>headers</code>, <code>attachments</code> und <code>tags</code>.
|
||
</p>
|
||
</section>
|
||
|
||
<section className="karte app-panel app-section">
|
||
<h2>Versanddienst wählen</h2>
|
||
<p className="app-muted">
|
||
Amazon SES bleibt der Standard. Ein API-Key kann optional über Scaleway
|
||
Transactional Email senden; die Auswahl steht beim Erzeugen des Keys unter{" "}
|
||
<a href="/keys">API-Keys</a>.
|
||
</p>
|
||
<pre className="app-code">{`# Scaleway (EU)
|
||
SCW_SECRET_KEY=SCW...
|
||
SCW_PROJECT_ID=<project-id>
|
||
SCW_REGION=fr-par`}</pre>
|
||
<p className="app-muted">
|
||
Die Absenderdomain muss im Scaleway-Konto verifiziert sein. Scaleway
|
||
unterstützt keine SES-SNS-Ereignisse; der Status bleibt dort zunächst
|
||
<code>sent</code>, bis ein eigener Webhook angebunden ist.
|
||
</p>
|
||
</section>
|
||
|
||
<section className="karte app-panel app-section">
|
||
<h2>Gemeinsame Vorlage (optional)</h2>
|
||
<p className="app-muted">
|
||
Mit <code>template: "sport-v1"</code> rendert Courier ein gemeinsames,
|
||
mailclient-sicheres Layout. Ohne dieses Feld bleiben <code>html</code>/<code>text</code>{" "}
|
||
unverändert. Eine Vorschau gibt es unter <a href="/templates">Vorlagen</a>.
|
||
</p>
|
||
<pre className="app-code">{`POST /api/emails/
|
||
{
|
||
"from": "ablaeufe <ablaeufe@hubsport.club>",
|
||
"to": "trainer@example.com",
|
||
"subject": "Freigabe: Fahrtkosten",
|
||
"template": "sport-v1",
|
||
"brand": { "name": "Eintracht Munster", "accent": "#7c3aed" },
|
||
"content": {
|
||
"title": "Freigabe: Fahrtkosten",
|
||
"paragraphs": ["Hallo Kai,", "…"],
|
||
"facts": [{ "label": "Summe", "value": "40,00 €" }],
|
||
"button": { "label": "Jetzt freigeben", "url": "https://…" },
|
||
"note": "Die Freigabe ist bis Freitag möglich."
|
||
}
|
||
}`}</pre>
|
||
<p className="app-muted">
|
||
Logo: <code>brand.logo_cid</code> setzen und einen Anhang mit derselben{" "}
|
||
<code>content_id</code> mitsenden. Erlaubte Blöcke: <code>title</code>,{" "}
|
||
<code>preheader</code>, <code>paragraphs</code>, <code>facts</code>,{" "}
|
||
<code>button</code>, <code>note</code>, <code>footer</code>.
|
||
</p>
|
||
</section>
|
||
|
||
<section className="karte app-panel app-section">
|
||
<h2>Resend-SDK</h2>
|
||
<pre className="app-code">{`import { Resend } from "resend";
|
||
|
||
const resend = new Resend(process.env.COURIER_API_KEY, {
|
||
baseUrl: "https://<courier-adresse>/api",
|
||
});
|
||
|
||
await resend.emails.send({
|
||
from: "plan <plan@hubsport.club>",
|
||
to: "kunde@example.com",
|
||
subject: "Test",
|
||
html: "<p>Hallo</p>",
|
||
});`}</pre>
|
||
</section>
|
||
|
||
<section className="karte app-panel app-section">
|
||
<h2>Batch und Status</h2>
|
||
<pre className="app-code">{`POST /api/emails/batch // bis zu 100 Mails
|
||
GET /api/emails/:id // Status einer Mail
|
||
GET /api/health // Health-Check`}</pre>
|
||
<p className="app-muted">
|
||
Ein <code>Idempotency-Key</code>-Header verhindert doppelte Sendungen.
|
||
</p>
|
||
</section>
|
||
|
||
<section className="karte app-panel app-section">
|
||
<h2>Fehler</h2>
|
||
<pre className="app-code">{`{ "statusCode": 422, "name": "validation_error", "message": "…" }
|
||
{ "statusCode": 429, "name": "rate_limit_exceeded", "message": "…" }
|
||
{ "statusCode": 422, "name": "recipient_suppressed", "message": "…" }`}</pre>
|
||
<p className="app-muted">
|
||
Gesperrte Empfänger stehen unter <a href="/suppressions">Suppressions</a>. Domains und
|
||
Keys werden unter <a href="/domains">Domains</a> und <a href="/keys">API-Keys</a> gepflegt.
|
||
</p>
|
||
</section>
|
||
</>
|
||
);
|
||
}
|