The Platform API

Flow: Content Moderation

Manage your videos, ask questions, and build applications with the Platform API. Explore the operations below for request details, responses, and examples.

Flow: Content Moderation

1

Upload content for moderation

POST /projects/:projectId/moderate (multipart file or URL)

2

Content scan runs automatically

Checks the content against your moderation policy and reports potential violations.

3

Agent pipeline runs (if configured)

Configure automatic analysis to produce a detailed report after moderation.

4

Poll for results

GET /projects/:projectId/videos/:videoId/moderation — returns structured decision (allow/flag/ban)

5

Receive webhook (optional)

Configure webhooks to get content.flagged, content.banned, or content.approved events via HTTP POST

import requests, time

API_KEY = "svk_..."
BASE = "https://platform.endlessai.com/api/v1"
PROJECT_ID = "your-project-id"

# Step 1: Upload for moderation
with open("video.mp4", "rb") as f:
    resp = requests.post(
        f"{BASE}/projects/{PROJECT_ID}/moderate",
        headers={"X-Api-Key": API_KEY},
        files={"file": ("video.mp4", f, "video/mp4")},
    )
content_id = resp.json()["contentId"]

# Step 2: Poll for moderation result
while True:
    result = requests.get(
        f"{BASE}/projects/{PROJECT_ID}/videos/{content_id}/moderation",
        headers={"X-Api-Key": API_KEY},
    ).json()
    if result["status"] == "completed":
        break
    time.sleep(3)

print(f"Decision: {result['decision']}")
print(f"Confidence: {result['confidence']}%")
for flag in result.get("flags", []):
    print(f"  - {flag['category']}: {flag['severity']} ({flag['confidence']})")

# Step 3: Check agent report (if pipeline is enabled)
report = requests.get(
    f"{BASE}/projects/{PROJECT_ID}/videos/{content_id}/report",
    headers={"X-Api-Key": API_KEY},
)
if report.status_code == 200:
    agent = report.json()["data"]
    print(f"Agent: {agent['decision']} ({agent['confidence']}%)")