Quick Start Guide

Get started with the SocialHub API in just a few minutes. This guide will walk you through making your first API requests.

Prerequisites

  • Active SocialHub account with at least one connected social media platform
  • Generated API Key (see Authentication)
  • HTTP client (curl, Postman, or your preferred programming language)

Step 1: Validate Your API Key

First, verify that your API Key is working correctly:

Validate API Keybash
curl -X POST https://your-domain.com/api/agents/v1/auth/validate \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json"

Expected response:

{
  "valid": true,
  "user": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "email": "user@example.com"
  }
}

Step 2: Publish Your First Post

Let's publish a simple text post to Instagram:

Publish to Instagrambash
curl -X POST https://your-domain.com/api/agents/v1/content/publish \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "caption": "Hello from SocialHub API! 🚀",
    "platforms": ["instagram"],
    "publish_now": true
  }'

Successful response:

{
  "success": true,
  "message": "Publication created successfully",
  "job_id": "pub_abc123",
  "scheduled_for": null,
  "platforms": ["instagram"]
}

Step 3: Schedule a Post

Now let's schedule a post for later:

Schedule a Postbash
curl -X POST https://your-domain.com/api/agents/v1/content/publish \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "caption": "Scheduled post from SocialHub API",
    "platforms": ["instagram", "facebook"],
    "scheduled_for": "2024-12-31T18:00:00Z"
  }'

Common Parameters Reference

ParameterTypeRequiredDescription
captionstringYesPost caption/text
platformsstring[]YesTarget platforms
publish_nowbooleanNoPublish immediately (default: false)
scheduled_forstringNoISO 8601 datetime for scheduling
media_urlsstring[]NoMedia file URLs (up to 10)

Example: JavaScript/TypeScript

import axios from 'axios';

const API_KEY = process.env.SOCIALHUB_API_KEY;
const BASE_URL = 'https://your-domain.com/api/agents/v1';

async function publishPost() {
  try {
    const response = await axios.post(
      `${BASE_URL}/content/publish`,
      {
        caption: 'Hello from SocialHub API!',
        platforms: ['instagram'],
        publish_now: true
      },
      {
        headers: {
          'X-API-Key': API_KEY,
          'Content-Type': 'application/json'
        }
      }
    );

    console.log('Post published:', response.data);
  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

publishPost();

Next Steps

Now that you've made your first requests, explore these guides: