Custom Agents & Bots

Any application, script, or AI agent that can make HTTP requests can integrate with SiteX CMS through the API. 

Quick Start

Here's a minimal example of publishing an article using Python:

import requests

API_URL = "https://yoursite.com/api/publish-content"
API_KEY = "sx_live_your_api_key_here"

response = requests.post(API_URL, json={
    "type": "article",
    "title": "My Article Title",
    "content": "<p>Article content goes here...</p>",
    "category_id": 1,
    "status": "published",
    "meta_title": "SEO Title for My Article",
    "meta_description": "A brief description for search engines."
}, headers={
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
})

if response.status_code == 201:
    data = response.json()
    print(f"Published: {data['url']}")
else:
    print(f"Error: {response.json()['message']}")

Node.js Example

const response = await fetch('https://yoursite.com/api/publish-content', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer sx_live_your_api_key_here',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        type: 'blog',
        title: 'My Blog Post',
        content: '<p>Post content here...</p>',
        status: 'draft'
    })
});

const data = await response.json();
console.log(data);

PHP Example

$ch = curl_init('https://yoursite.com/api/publish-content');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer sx_live_your_api_key_here',
        'Content-Type: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'type' => 'article',
        'title' => 'My Article',
        'content' => '<p>Content here</p>',
        'category_id' => 1,
        'status' => 'published'
    ])
]);
$response = curl_exec($ch);
curl_close($ch);

Building a Custom Agent

When building your own content automation agent, consider:

  1. Error handling - Check response codes and handle 429 (rate limit) with exponential backoff
  2. Content validation - Validate content before sending to avoid 422 errors
  3. Idempotency - Use the slug field to avoid creating duplicates
  4. Logging - Log API responses for debugging
  5. Rate limit awareness - Monitor X-RateLimit-Remaining headers

Webhook Notifications

SiteX can send webhook notifications when content is published or updated. Configure webhook URLs in Settings → Webhooks to receive real-time notifications in your agent.