Was du brauchst
Bevor du Anfragen sendest, brauchst du:
- Einen Ocoya API-Schlüssel
- Eine Brand-ID
- Social-Profile-IDs, wenn du Posts erstellen oder planen möchtest
API-Schlüssel erhalten
Erstelle oder kopiere einen API-Schlüssel in deinen Ocoya API-Einstellungen.
API-Schlüssel sind für die Nutzung auf dem Server bestimmt. Setze sie nicht in JavaScript im Browser, mobilen Apps oder öffentlichen Repositories ein.
Base URL
Alle REST API-Beispiele verwenden:
https://www.app.ocoya.com/api/_public/v1Deine erste Anfrage senden
Am schnellsten prüfst du deinen API-Schlüssel, indem du /me aufrufst.
curl -X GET "https://www.app.ocoya.com/api/_public/v1/me" \
-H "X-API-Key: YOUR_API_KEY"Wenn der Schlüssel gültig ist, gibt die API deinen User-Kontext zurück.
{
"id": "clx354swx0006ghoatnjknv98",
"name": "Ocoya Support",
"email": "support@ocoya.com"
}Typischer Publishing-Flow
Brands auflisten
Rufe GET /brands auf und wähle die Brand, von der du posten möchtest.
Social-Profile verbinden
Wenn die Brand noch keine verbundenen Profile hat, rufe POST /social-profiles/connection-url auf und öffne die zurückgegebene url in einem Browser.
Social-Profile auflisten
Rufe GET /social-profiles?brandId=BRAND_ID auf, um verbundene Profil-IDs zu finden.
Optionalen Kontext auflösen
Rufe GET /hashtag-libraries?brandId=BRAND_ID auf, wenn ein AI-Entwurf gespeicherten Hashtag-Kontext verwenden soll.
Einen Entwurf oder geplanten Post erstellen
Rufe POST /post?brandId=BRAND_ID mit Caption, Media-URLs, Ziel-Social-Profile-IDs und optionalem scheduledAt auf.
Einen AI-Entwurf erstellen
Rufe POST /post/ai?brandId=BRAND_ID mit einem Prompt auf, wenn Ocoya zuerst die Caption generieren soll.
Eine AI-Kampagne erstellen
Rufe POST /campaigns?brandId=BRAND_ID auf, um die Generierung einer Multi-Post-Kampagne zu starten und eine sofortige GENERATING-Antwort zu erhalten.
Posts verwalten
Verwende GET /post, PATCH /post/{postId} und DELETE /post/{postId}, um Posts zu prüfen, neu zu planen oder zu entfernen.
Einen Post erstellen
Verwende scheduledAt, wenn du einen geplanten Post möchtest. Lass es weg, wenn du einen Entwurf möchtest.
curl -X POST "https://www.app.ocoya.com/api/_public/v1/post?brandId=BRAND_ID" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"caption": "Launching our summer campaign today.",
"mediaUrls": ["https://example.com/image.jpg"],
"socialProfileIds": ["SOCIAL_PROFILE_ID"],
"scheduledAt": "2026-07-01T09:00:00Z"
}'Ein Social-Profil verbinden
Verwende POST /social-profiles/connection-url, wenn du eine Browser-URL brauchst, um ein neues Social-Profil zu verbinden.
curl -X POST "https://www.app.ocoya.com/api/_public/v1/social-profiles/connection-url?brandId=BRAND_ID" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"provider":"instagram"}'Öffne die zurückgegebene url, während du bei Ocoya eingeloggt bist.
Einen AI-Entwurf erstellen
Verwende POST /post/ai, wenn Ocoya die Caption aus einem Prompt generieren soll, bevor der Entwurf angelegt wird.
Verwende hashtagLibraryId und referenceDesignIds, wenn der Entwurf eine gespeicherte Hashtag-Library oder Studio-Template-Kontext verwenden soll.
curl -X POST "https://www.app.ocoya.com/api/_public/v1/post/ai?brandId=BRAND_ID" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Write a friendly launch post for our new analytics dashboard.",
"tone": "friendly",
"postLength": "medium",
"socialProfileIds": ["SOCIAL_PROFILE_ID"],
"hashtagLibraryId": "HASHTAG_LIBRARY_ID",
"generateImage": true,
"referenceUrls": ["https://example.com/reference.png"],
"referenceDesignIds": ["STUDIO_DESIGN_ID"]
}'Eine AI-Kampagne erstellen
Verwende POST /campaigns, wenn Ocoya im Hintergrund eine Multi-Post-Kampagne generieren soll.
Die Antwort kommt sofort mit Status GENERATING. Verwende hashtagLibraryId, wenn die Kampagne eine gespeicherte Hashtag-Library nutzen soll.
curl -X POST "https://www.app.ocoya.com/api/_public/v1/campaigns?brandId=BRAND_ID" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Summer launch campaign for our ecommerce analytics dashboard, aimed at marketing teams already using spreadsheets. Confident, practical tone.",
"goal": "launch",
"duration": 10,
"count": 6,
"postLength": "medium",
"hashtagLibraryId": "HASHTAG_LIBRARY_ID",
"socialProfileIds": ["SOCIAL_PROFILE_ID"],
"generateMedia": true
}'MCP vs REST API
Verwende die REST API für Backend-Systeme, die bereits genau wissen, was sie tun sollen.
Verwende MCP, wenn du möchtest, dass AI-Clients wie Claude, Codex oder ChatGPT Ocoya-Tools entdecken und aufrufen, nachdem der User den OAuth-Zugriff freigegeben hat.