Zum Inhalt springen

REST-API-Referenz

EmDash stellt eine REST-API unter /_emdash/api/ für Inhaltsverwaltung, Medien-Uploads und Schema-Operationen bereit.

API-Anfragen erfordern eine Authentifizierung über einen Bearer-Token:

Authorization: Bearer <token>

Generieren Sie Token über die Admin-Oberfläche oder programmatisch.

Alle Antworten folgen einem einheitlichen Format:

// Erfolg
{
"success": true,
"data": { ... }
}
// Fehler
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Menschenlesbare Nachricht",
"details": { ... }
}
}
GET /_emdash/api/content/:collection
ParameterTypBeschreibung
collectionstringCollection-Slug (Pfad)
cursorstringPaginierungs-Cursor (Query)
limitnumberElemente pro Seite (Query, Standard: 50)
statusstringNach Status filtern (Query)
orderBystringFeld zum Sortieren (Query)
orderstringSortierrichtung: asc oder desc (Query)
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"type": "posts",
"slug": "hello-world",
"data": { "title": "Hallo Welt", ... },
"status": "published",
"createdAt": "2025-01-24T12:00:00Z",
"updatedAt": "2025-01-24T12:00:00Z"
}
],
"nextCursor": "eyJpZCI6..."
}
}
GET /_emdash/api/content/:collection/:id
{
"success": true,
"data": {
"item": {
"id": "01HXK5MZSN...",
"type": "posts",
"slug": "hello-world",
"data": { "title": "Hallo Welt", ... },
"status": "published",
"createdAt": "2025-01-24T12:00:00Z",
"updatedAt": "2025-01-24T12:00:00Z"
}
}
}
POST /_emdash/api/content/:collection
Content-Type: application/json
{
"data": {
"title": "Neuer Beitrag",
"content": [...]
},
"slug": "new-post",
"status": "draft"
}
{
"success": true,
"data": {
"item": { ... }
}
}
PUT /_emdash/api/content/:collection/:id
Content-Type: application/json
{
"data": {
"title": "Aktualisierter Titel"
},
"status": "published"
}
DELETE /_emdash/api/content/:collection/:id
{
"success": true,
"data": {
"success": true
}
}
GET /_emdash/api/media
ParameterTypBeschreibung
cursorstringPaginierungs-Cursor
limitnumberElemente pro Seite (Standard: 20)
mimeTypestringNach MIME-Typ-Präfix filtern
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"filename": "photo.jpg",
"mimeType": "image/jpeg",
"size": 102400,
"width": 1920,
"height": 1080,
"url": "https://cdn.example.com/photo.jpg",
"createdAt": "2025-01-24T12:00:00Z"
}
],
"nextCursor": "eyJpZCI6..."
}
}
GET /_emdash/api/media/:id
POST /_emdash/api/media
Content-Type: application/json
{
"filename": "photo.jpg",
"mimeType": "image/jpeg",
"size": 102400,
"width": 1920,
"height": 1080,
"storageKey": "uploads/photo.jpg"
}
PUT /_emdash/api/media/:id
Content-Type: application/json
{
"alt": "Bildbeschreibung",
"caption": "Bildunterschrift"
}
DELETE /_emdash/api/media/:id
GET /_emdash/api/media/file/:key

Liefert den eigentlichen Dateiinhalt. Nur für lokalen Speicher.

GET /_emdash/api/content/:collection/:entryId/revisions
ParameterTypBeschreibung
limitnumberMaximale zurückzugebende Revisionen (Standard: 50)
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"collection": "posts",
"entryId": "01HXK5MZSN...",
"data": { ... },
"createdAt": "2025-01-24T12:00:00Z"
}
],
"total": 5
}
}
GET /_emdash/api/revisions/:revisionId
POST /_emdash/api/revisions/:revisionId/restore

Stellt den Inhalt auf den Zustand dieser Revision wieder her und erstellt eine neue Revision.

GET /_emdash/api/schema/collections
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"slug": "posts",
"label": "Beiträge",
"labelSingular": "Beitrag",
"supports": ["drafts", "revisions", "preview"]
}
]
}
}
GET /_emdash/api/schema/collections/:slug
ParameterTypBeschreibung
includeFieldsbooleanFelddefinitionen einbeziehen (Query)
POST /_emdash/api/schema/collections
Content-Type: application/json
{
"slug": "products",
"label": "Products",
"labelSingular": "Product",
"description": "Product catalog",
"supports": ["drafts", "revisions"]
}
PATCH /_emdash/api/schema/collections/:slug
Content-Type: application/json
DELETE /_emdash/api/schema/collections/:slug
ParameterTypBeschreibung
forcebooleanLöschen auch wenn Collection Inhalte hat (Query)
GET /_emdash/api/schema/collections/:slug/fields
POST /_emdash/api/schema/collections/:slug/fields
Content-Type: application/json
{
"slug": "price",
"label": "Price",
"type": "number",
"required": true,
"validation": {
"min": 0
}
}
PATCH /_emdash/api/schema/collections/:collectionSlug/fields/:fieldSlug
Content-Type: application/json
DELETE /_emdash/api/schema/collections/:collectionSlug/fields/:fieldSlug
POST /_emdash/api/schema/collections/:slug/fields/reorder
Content-Type: application/json
{
"fieldSlugs": ["title", "content", "author", "publishedAt"]
}
GET /_emdash/api/schema
Accept: application/json
GET /_emdash/api/schema?format=typescript
Accept: text/typescript

Gibt TypeScript-Interfaces für alle Collections zurück.

GET /_emdash/api/plugins
GET /_emdash/api/plugins/:pluginId
POST /_emdash/api/plugins/:pluginId/enable
POST /_emdash/api/plugins/:pluginId/disable
CodeHTTP-StatusBeschreibung
NOT_FOUND404Ressource nicht gefunden
VALIDATION_ERROR400Ungültige Eingabedaten
UNAUTHORIZED401Fehlender oder ungültiger Token
FORBIDDEN403Unzureichende Berechtigungen
CONTENT_LIST_ERROR500Inhaltsauflistung fehlgeschlagen
CONTENT_CREATE_ERROR500Inhaltserstellung fehlgeschlagen
CONTENT_UPDATE_ERROR500Inhaltsaktualisierung fehlgeschlagen
CONTENT_DELETE_ERROR500Inhaltslöschung fehlgeschlagen
MEDIA_LIST_ERROR500Medienauflistung fehlgeschlagen
MEDIA_CREATE_ERROR500Medienerstellung fehlgeschlagen
SCHEMA_ERROR400Schema-Operation fehlgeschlagen
DUPLICATE_SLUG409Slug existiert bereits
RESERVED_SLUG400Slug ist reserviert
GET /_emdash/api/search?q=hello+world
ParameterTypBeschreibung
qstringSuchanfrage (erforderlich)
collectionsstringKommagetrennte Collection-Slugs
statusstringNach Status filtern (Standard: published)
limitnumberMaximale Ergebnisse (Standard: 20)
cursorstringPaginierungs-Cursor
{
"results": [
{
"collection": "posts",
"id": "01HXK5MZSN...",
"slug": "hello-world",
"title": "Hallo Welt",
"snippet": "...this is a <mark>hello</mark>
<mark>world</mark>
example...",
"score": 0.95
}
],
"nextCursor": "eyJvZmZzZXQiOjIwfQ"
}
GET /_emdash/api/search/suggest?q=hel&limit=5

Gibt präfix-gematchte Titel für die Autovervollständigung zurück.

POST /_emdash/api/search/rebuild

Baut den FTS-Index für alle oder bestimmte Collections neu auf.

GET /_emdash/api/search/stats

Gibt die Anzahl der indizierten Dokumente pro Collection zurück.

GET /_emdash/api/sections
GET /_emdash/api/sections?source=theme
GET /_emdash/api/sections?search=newsletter
GET /_emdash/api/sections/:slug
POST /_emdash/api/sections
Content-Type: application/json
{
"slug": "my-section",
"title": "My Section",
"keywords": ["keyword1"],
"content": [...]
}
PUT /_emdash/api/sections/:slug
DELETE /_emdash/api/sections/:slug
GET /_emdash/api/settings
POST /_emdash/api/settings
Content-Type: application/json
{
"siteTitle": "Meine Website",
"tagline": "Eine grossartige Website",
"postsPerPage": 10
}
GET /_emdash/api/menus
GET /_emdash/api/menus/:name
POST /_emdash/api/menus
Content-Type: application/json
{
"name": "footer",
"label": "Footer Navigation"
}
PUT /_emdash/api/menus/:name
DELETE /_emdash/api/menus/:name
POST /_emdash/api/menus/:name/items
Content-Type: application/json
{
"type": "page",
"referenceCollection": "pages",
"referenceId": "page_about",
"label": "About Us"
}
POST /_emdash/api/menus/:name/reorder
Content-Type: application/json
{
"items": [
{ "id": "item_1", "parentId": null, "sortOrder": 0 },
{ "id": "item_2", "parentId": null, "sortOrder": 1 },
{ "id": "item_3", "parentId": "item_2", "sortOrder": 0 }
]
}
GET /_emdash/api/taxonomies
POST /_emdash/api/taxonomies
Content-Type: application/json
{
"name": "genre",
"label": "Genres",
"labelSingular": "Genre",
"hierarchical": true,
"collections": ["books", "movies"]
}
GET /_emdash/api/taxonomies/:name/terms
POST /_emdash/api/taxonomies/:name/terms
Content-Type: application/json
{
"slug": "tutorials",
"label": "Tutorials",
"parentId": "term_abc",
"description": "How-to guides"
}
PUT /_emdash/api/taxonomies/:name/terms/:slug
DELETE /_emdash/api/taxonomies/:name/terms/:slug
POST /_emdash/api/content/:collection/:id/terms/:taxonomy
Content-Type: application/json
{
"termIds": ["term_news", "term_featured"]
}
GET /_emdash/api/widget-areas
GET /_emdash/api/widget-areas/:name
POST /_emdash/api/widget-areas
Content-Type: application/json
{
"name": "sidebar",
"label": "Hauptseitenleiste",
"description": "Appears on posts"
}
DELETE /_emdash/api/widget-areas/:name
POST /_emdash/api/widget-areas/:name/widgets
Content-Type: application/json
{
"type": "content",
"title": "Ueber",
"content": [...]
}
PUT /_emdash/api/widget-areas/:name/widgets/:id
DELETE /_emdash/api/widget-areas/:name/widgets/:id
POST /_emdash/api/widget-areas/:name/reorder
Content-Type: application/json
{
"widgetIds": ["widget_1", "widget_2", "widget_3"]
}
GET /_emdash/api/admin/users
GET /_emdash/api/admin/users?role=40
GET /_emdash/api/admin/users?search=john
GET /_emdash/api/admin/users/:id
PATCH /_emdash/api/admin/users/:id
Content-Type: application/json
{
"name": "John Doe",
"role": 40
}
POST /_emdash/api/admin/users/:id/enable
POST /_emdash/api/admin/users/:id/disable
GET /_emdash/api/setup/status

Gibt zurück, ob die Einrichtung abgeschlossen ist und ob Benutzer existieren.

POST /_emdash/api/auth/passkey/options

WebAuthn-Authentifizierungsoptionen abrufen.

POST /_emdash/api/auth/passkey/verify
Content-Type: application/json
{
"id": "credential-id",
"rawId": "...",
"response": {...},
"type": "public-key"
}

Passkey verifizieren und Sitzung erstellen.

POST /_emdash/api/auth/magic-link/send
Content-Type: application/json
{
"email": "user@example.com"
}
GET /_emdash/api/auth/magic-link/verify?token=xxx
POST /_emdash/api/auth/logout
GET /_emdash/api/auth/me
POST /_emdash/api/auth/invite
Content-Type: application/json
{
"email": "newuser@example.com",
"role": 30
}
GET /_emdash/api/auth/passkey

Passkeys des Benutzers auflisten.

POST /_emdash/api/auth/passkey/register/options
POST /_emdash/api/auth/passkey/register/verify

Neuen Passkey registrieren.

PATCH /_emdash/api/auth/passkey/:id
Content-Type: application/json
{
"name": "MacBook Pro"
}

Passkey umbenennen.

DELETE /_emdash/api/auth/passkey/:id

Passkey löschen.

POST /_emdash/api/import/wordpress/analyze
Content-Type: multipart/form-data
file: <WXR-Datei>
POST /_emdash/api/import/wordpress/execute
Content-Type: application/json
{
"analysisId": "...",
"options": {
"includeMedia": true,
"includeTaxonomies": true,
"includeMenus": true
}
}

API-Endpunkte können je nach Bereitstellungskonfiguration ratenbeschränkt sein. Bei Ratenbegrenzung enthalten Antworten:

HTTP/1.1 429 Too Many Requests
Retry-After: 60

Die API unterstützt CORS für Browseranfragen. Konfigurieren Sie erlaubte Ursprünge in Ihrer Bereitstellung.