# Flare API Documentation > Base URL: https://joinflare.app/api/v1 --- # Introduction The Crelio API lets you programmatically manage your social media presence. Schedule posts across 8 platforms, manage connected accounts, and automate your content workflow — all through a simple REST API. ## What you can do - **List social accounts** — Get all connected platforms and their status - **Create posts** — Publish or schedule posts to one or many platforms - **Platform-specific content** — Tailor content per platform while posting in one call - **Batch operations** — Create multiple posts in a single request - **Auto-scheduling** — Let Crelio find the optimal posting time - **Media handling** — Attach images and videos via URL, base64, or multipart upload ## Base URL All API requests use the following base URL: ``` https://crelio.app/api/v1 ``` ## Supported platforms | Platform | Identifier | | ----------- | ----------- | | Twitter / X | `twitter` | | LinkedIn | `linkedin` | | Instagram | `instagram` | | Facebook | `facebook` | | TikTok | `tiktok` | | YouTube | `youtube` | | Bluesky | `bluesky` | | Threads | `threads` | ## Quick example ```bash curl -X POST https://crelio.app/api/v1/social-posts \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "accountIds": ["acc_123"], "content": "Hello from the Crelio API!", "autoSchedule": true }' ``` ## Next steps - [Authentication](/docs/authentication) — Get your API key and authenticate requests - [Social Posts](/docs/social-posts) — Create and manage posts - [Code Examples](/docs/code-examples) — Copy-paste examples in cURL, JavaScript, and Python --- # Authentication All API requests require a Bearer token in the `Authorization` header. Each token is scoped to a single brand. ## Getting your API key 1. Log into your [Crelio dashboard](https://crelio.app) 2. Go to **Settings** → **API Keys** 3. Click **Generate API Key** 4. Copy and store the key securely — it won't be shown again ## Using your API key Include the key in every request: ```bash curl https://crelio.app/api/v1/accounts \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```javascript const response = await fetch("https://crelio.app/api/v1/accounts", { headers: { Authorization: "Bearer YOUR_API_KEY", }, }); ``` ```python import requests headers = { "Authorization": "Bearer YOUR_API_KEY", } response = requests.get("https://crelio.app/api/v1/accounts", headers=headers) ``` ## Key management - Each brand has one active API key at a time - Generating a new key revokes the previous one - If a key is compromised, revoke it immediately in Settings → API Keys ## Error responses | Status | Meaning | | ------ | ----------------------------------------- | | `401` | Missing or invalid API key | | `403` | Brand is inactive or key has been revoked | ```json { "error": "Unauthorized" } ``` --- # Rate Limiting API requests are rate-limited per API key to ensure fair usage. ## Default limits | Endpoint type | Limit | | --------------- | ------------------- | | GET endpoints | 100 requests/minute | | POST endpoints | 50 requests/minute | | Batch endpoints | 20 requests/minute | ## Response headers Every response includes rate limit headers: | Header | Description | | ----------------------- | ---------------------------------------------- | | `X-RateLimit-Limit` | Maximum requests allowed in the current window | | `X-RateLimit-Remaining` | Requests remaining in the current window | | `X-RateLimit-Reset` | Unix timestamp when the window resets | | `Retry-After` | Seconds to wait before retrying (only on 429) | ## Handling rate limits When you exceed the limit, the API returns `429 Too Many Requests`: ```json { "error": "Too many requests. Please try again later." } ``` Use the `Retry-After` header to wait the appropriate amount of time: ```javascript const response = await fetch("https://crelio.app/api/v1/social-posts", { method: "POST", headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify(data), }); if (response.status === 429) { const retryAfter = parseInt(response.headers.get("Retry-After") || "60"); await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000)); // Retry the request } ``` ## Best practices - Cache responses when possible (e.g., account lists don't change frequently) - Use batch endpoints instead of creating posts one by one - Implement exponential backoff for retries - Monitor `X-RateLimit-Remaining` to avoid hitting limits --- # Accounts Retrieve all social media accounts connected to your brand. ## List accounts Returns all connected social accounts and the brand they belong to. ``` GET /accounts ``` ### Response ```json { "accounts": [ { "id": "clp1234567890", "platform": "twitter", "username": "yourbrand", "name": "Your Brand", "profileImageUrl": "https://...", "connected": true }, { "id": "clp0987654321", "platform": "linkedin", "username": "company/yourbrand", "name": "Your Brand Inc", "profileImageUrl": "https://...", "connected": true } ], "brandId": "clp1111111111", "brandName": "Your Brand" } ``` ### Account fields | Field | Type | Description | | ----------------- | ------- | -------------------------------- | | `id` | string | Unique account identifier | | `platform` | string | Platform identifier (see below) | | `username` | string | Account username on the platform | | `name` | string | Display name | | `profileImageUrl` | string | Avatar URL | | `connected` | boolean | Whether the account is active | ### Supported platforms `twitter` · `linkedin` · `instagram` · `facebook` · `tiktok` · `youtube` · `bluesky` · `threads` ### Example ```bash curl https://crelio.app/api/v1/accounts \ -H "Authorization: Bearer YOUR_API_KEY" ``` --- # Social Posts Create and manage social media posts across all connected platforms. ## Create a post Publish or schedule a post to one or more social accounts. ``` POST /social-posts ``` ### Request body ```json { "accountIds": ["clp1234567890", "clp0987654321"], "content": "Main post content for all platforms", "platformContent": { "twitter": "Short tweet version", "linkedin": "Professional LinkedIn version with more detail" }, "scheduledDate": "2025-12-25T10:00:00Z", "autoSchedule": false, "mediaUrl": "https://example.com/image.jpg", "idempotencyKey": "unique-request-id-123" } ``` ### Request fields | Field | Type | Required | Description | | ---------------------- | -------- | -------- | --------------------------------------------------------------------------------- | | `accountIds` | string[] | Yes | Social account IDs to post to | | `content` | string | Yes | Main post content | | `platformContent` | object | No | Platform-specific content overrides (see [Media & Content](/docs/media-handling)) | | `scheduledDate` | string | No | ISO 8601 date. Defaults to now | | `autoSchedule` | boolean | No | Find optimal posting time automatically | | `autoScheduleInterval` | number | No | Custom interval in hours (1–168) for auto-scheduling | | `mediaUrl` | string | No | URL of media to attach (auto-downloaded and stored) | | `mediaBase64` | string | No | Base64-encoded media file | | `mediaFileName` | string | No | Filename when using `mediaBase64` | | `idempotencyKey` | string | No | Prevent duplicate posts on retries | | `timezone` | string | No | IANA timezone for scheduling (default: UTC) | ### Response ```json { "id": "clp2222222222", "status": "SCHEDULED", "scheduledDate": "2025-12-25T10:00:00Z", "platforms": ["twitter", "linkedin"], "mediaUrl": "https://cdn.crelio.app/uploaded-image.jpg", "message": "Post scheduled for: 2025-12-25T10:00:00Z" } ``` --- ## Get a post Retrieve the status and full details of a specific post. ``` GET /social-posts/{id} ``` ### Response ```json { "id": "clp2222222222", "content": "Main post content", "scheduledDate": "2025-12-25T10:00:00Z", "status": "SCHEDULED", "platforms": ["twitter", "linkedin"], "mediaUrl": "https://cdn.crelio.app/image.jpg", "published": false, "createdAt": "2025-12-20T08:00:00Z", "updatedAt": "2025-12-20T08:00:00Z", "accounts": [ { "platform": "twitter", "actualAccountId": "clp1234567890", "username": "yourbrand", "name": "Your Brand", "profileImageUrl": "https://..." } ], "platformContent": { "twitter": "Twitter-specific content", "linkedin": "LinkedIn-specific content" }, "platformPosts": [] } ``` --- ## List posts Get a paginated list of all posts for your brand. ``` GET /social-posts ``` ### Query parameters | Parameter | Type | Description | | --------- | ------ | ------------------------------------------------------------------- | | `limit` | number | Posts to return (default: 20, max: 100) | | `offset` | number | Posts to skip for pagination | | `status` | string | Filter: `QUEUED`, `SCHEDULED`, `IN_PROGRESS`, `PUBLISHED`, `FAILED` | ### Response ```json { "posts": [ { "id": "clp2222222222", "content": "Post content", "scheduledDate": "2025-12-25T10:00:00Z", "status": "SCHEDULED", "platforms": ["twitter", "linkedin"], "mediaUrl": "https://...", "published": false, "createdAt": "2025-12-20T08:00:00Z", "updatedAt": "2025-12-20T08:00:00Z" } ], "pagination": { "total": 50, "limit": 20, "offset": 0, "hasMore": true } } ``` --- ## Update a post Update a scheduled post that hasn't been published yet. ``` PATCH /social-posts/{id} ``` ### Request body ```json { "content": "Updated content", "scheduledDate": "2025-12-26T10:00:00Z", "platformContent": { "twitter": "Updated Twitter content" } } ``` All fields are optional — only include what you want to change. --- ## Delete a post Cancel and delete a scheduled post. Only works for unpublished posts. ``` DELETE /social-posts/{id} ``` ### Response ```json { "message": "Post deleted successfully", "id": "clp2222222222" } ``` --- ## Post status values | Status | Description | | ------------- | ------------------------------- | | `QUEUED` | Queued for processing | | `SCHEDULED` | Scheduled for future publishing | | `IN_PROGRESS` | Currently being published | | `PUBLISHED` | Successfully published | | `FAILED` | Publishing failed | --- # Batch Posts Create multiple posts in a single request. Each post in the batch is processed independently — if one fails, the others still succeed. ## Create batch ``` POST /social-posts/batch ``` ### Request body ```json { "posts": [ { "accountIds": ["clp1234567890"], "content": "First post content", "scheduledDate": "2025-12-25T10:00:00Z" }, { "accountIds": ["clp0987654321"], "content": "Second post content", "autoSchedule": true }, { "accountIds": ["clp1234567890", "clp0987654321"], "content": "Cross-platform post", "platformContent": { "twitter": "Short version for X", "linkedin": "Detailed version for LinkedIn" }, "autoSchedule": true, "autoScheduleInterval": 24 } ] } ``` Each item in `posts` accepts the same fields as [Create a post](/docs/social-posts#create-a-post). ### Response Returns `207 Multi-Status` with individual results: ```json { "message": "Batch processing complete: 3 succeeded, 0 failed", "results": [ { "index": 0, "success": true, "id": "clp3333333333", "status": "SCHEDULED", "scheduledDate": "2025-12-25T10:00:00Z", "platforms": ["twitter"] }, { "index": 1, "success": true, "id": "clp4444444444", "status": "SCHEDULED", "scheduledDate": "2025-12-25T14:30:00Z", "platforms": ["linkedin"] }, { "index": 2, "success": true, "id": "clp5555555555", "status": "SCHEDULED", "scheduledDate": "2025-12-26T14:30:00Z", "platforms": ["twitter", "linkedin"] } ], "summary": { "total": 3, "succeeded": 3, "failed": 0 } } ``` ### Partial failures If some posts fail, you get a mix: ```json { "results": [ { "index": 0, "success": true, "id": "clp3333333333", "status": "SCHEDULED" }, { "index": 1, "success": false, "error": "No valid account IDs provided" } ], "summary": { "total": 2, "succeeded": 1, "failed": 1 } } ``` ### Rate limits Batch requests count as a single request against the batch rate limit (20/minute), but each post within the batch is processed individually. ### Best practices - Keep batches under 50 posts for optimal performance - Use `idempotencyKey` per post to safely retry failed batches - Check individual `results[].success` — the overall request may succeed while individual posts fail --- # Media & Content Attach media to posts and customize content per platform. ## Attaching media There are three ways to attach media to a post: ### 1. External URL Provide a `mediaUrl` — Crelio downloads the file, stores it in your CDN, and uses the stored copy. This ensures posts don't break if the original URL goes down. ```json { "accountIds": ["acc_123"], "content": "Check this out!", "mediaUrl": "https://example.com/photo.jpg" } ``` ### 2. Base64 Send the file contents directly as a base64-encoded string: ```json { "accountIds": ["acc_123"], "content": "New product photo", "mediaBase64": "iVBORw0KGgoAAAANSUhEUg...", "mediaFileName": "product.jpg" } ``` ### 3. Multipart form data Upload the file as part of a multipart request: ```bash curl -X POST https://crelio.app/api/v1/social-posts \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "accountIds=[\"acc_123\"]" \ -F "content=New product launch!" \ -F "media=@/path/to/photo.jpg" \ -F "autoSchedule=true" ``` ## Platform-specific content Use the `platformContent` object to tailor your message per platform. Any platform not listed falls back to the main `content` field: ```json { "accountIds": ["twitter_acc", "linkedin_acc", "instagram_acc"], "content": "Default content for all platforms", "platformContent": { "twitter": "Short tweet version (280 chars)", "linkedin": "Professional LinkedIn version with more details and context about our latest announcement." } } ``` In this example: - **Twitter** gets the short version - **LinkedIn** gets the professional version - **Instagram** falls back to the default `content` ## Supported media types | Type | Formats | Max size | | ----- | ------------------- | -------- | | Image | JPG, PNG, GIF, WebP | 20 MB | | Video | MP4, MOV, AVI | 500 MB | Platform-specific limits may apply (e.g., Twitter has a 280-character limit, video duration limits vary by platform). --- # Scheduling Schedule posts for a specific time or let Flare find the best slot automatically. ## Manual scheduling Set `scheduledDate` to an ISO 8601 timestamp: ```json { "accountIds": ["acc_123"], "content": "Holiday announcement!", "scheduledDate": "2025-12-25T10:00:00Z" } ``` If `scheduledDate` is omitted and `autoSchedule` is `false` (the default), the post is published immediately. ## Auto-scheduling Set `autoSchedule: true` and Flare picks the optimal time based on: - Your configured posting hours (e.g., 9 AM – 9 PM) - Existing scheduled posts (avoids clustering) - Platform best practices - Your brand's posting interval settings ```json { "accountIds": ["acc_123"], "content": "Daily update", "autoSchedule": true } ``` ### Custom intervals Override your brand's default posting interval with `autoScheduleInterval` (in hours, 1–168): ```json { "accountIds": ["acc_123"], "content": "Weekly digest", "autoSchedule": true, "autoScheduleInterval": 24 } ``` This schedules the post at least 24 hours after the last scheduled post, useful for controlling posting frequency on a per-request basis. ## Timezones All times are UTC by default. Pass a `timezone` field (IANA format) to schedule in a specific timezone: ```json { "accountIds": ["acc_123"], "content": "Good morning!", "scheduledDate": "2025-12-25T09:00:00", "timezone": "America/New_York" } ``` ## Idempotency Network issues can cause retries. Use `idempotencyKey` to prevent duplicate posts: ```json { "accountIds": ["acc_123"], "content": "Important update", "autoSchedule": true, "idempotencyKey": "update-2025-12-25-v1" } ``` If a post with the same key already exists, the API returns the existing post instead of creating a duplicate. --- # Code Examples Ready-to-use examples in popular languages. ## cURL ### List accounts ```bash curl https://crelio.app/api/v1/accounts \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### Create a post ```bash curl -X POST https://crelio.app/api/v1/social-posts \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "accountIds": ["acc_123"], "content": "Hello from the API!", "autoSchedule": true }' ``` ### Create a post with media and custom interval ```bash curl -X POST https://crelio.app/api/v1/social-posts \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "accountIds": ["acc_123"], "content": "Daily update!", "autoSchedule": true, "autoScheduleInterval": 24, "mediaUrl": "https://example.com/video.mp4" }' ``` ### Get post status ```bash curl https://crelio.app/api/v1/social-posts/POST_ID \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### List posts with filter ```bash curl "https://crelio.app/api/v1/social-posts?status=SCHEDULED&limit=10" \ -H "Authorization: Bearer YOUR_API_KEY" ``` --- ## JavaScript / Node.js ```javascript const API_KEY = "YOUR_API_KEY"; const BASE_URL = "https://crelio.app/api/v1"; const headers = { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", }; // List accounts async function listAccounts() { const res = await fetch(`${BASE_URL}/accounts`, { headers }); return res.json(); } // Create a post async function createPost(accountIds, content, options = {}) { const res = await fetch(`${BASE_URL}/social-posts`, { method: "POST", headers, body: JSON.stringify({ accountIds, content, autoSchedule: true, idempotencyKey: `post-${Date.now()}`, ...options, }), }); return res.json(); } // Get post status async function getPost(postId) { const res = await fetch(`${BASE_URL}/social-posts/${postId}`, { headers }); return res.json(); } // Batch create async function batchCreate(posts) { const res = await fetch(`${BASE_URL}/social-posts/batch`, { method: "POST", headers, body: JSON.stringify({ posts }), }); return res.json(); } // Usage const accounts = await listAccounts(); const post = await createPost([accounts.accounts[0].id], "Hello from Node.js!", { mediaUrl: "https://example.com/image.jpg", }); console.log(`Post ${post.id} status: ${post.status}`); ``` --- ## Python ```python import requests from datetime import datetime, timedelta API_KEY = "YOUR_API_KEY" BASE_URL = "https://crelio.app/api/v1" headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", } def list_accounts(): """Get all connected social accounts.""" response = requests.get(f"{BASE_URL}/accounts", headers=headers) response.raise_for_status() return response.json() def create_post(account_ids, content, **kwargs): """Create a new social post.""" data = { "accountIds": account_ids, "content": content, "autoSchedule": True, **kwargs, } response = requests.post( f"{BASE_URL}/social-posts", headers=headers, json=data ) response.raise_for_status() return response.json() def get_post(post_id): """Get a post by ID.""" response = requests.get( f"{BASE_URL}/social-posts/{post_id}", headers=headers ) response.raise_for_status() return response.json() def batch_create(posts): """Create multiple posts at once.""" response = requests.post( f"{BASE_URL}/social-posts/batch", headers=headers, json={"posts": posts}, ) response.raise_for_status() return response.json() # Usage accounts = list_accounts() account_id = accounts["accounts"][0]["id"] post = create_post( [account_id], "Hello from Python!", mediaUrl="https://example.com/image.jpg", ) print(f"Post {post['id']} status: {post['status']}") ``` --- # Errors The API uses standard HTTP status codes and returns consistent error responses. ## HTTP status codes | Code | Description | | ----- | ----------------------------------------- | | `200` | Success | | `201` | Created | | `207` | Multi-Status (batch operations) | | `400` | Bad Request — invalid parameters | | `401` | Unauthorized — invalid or missing API key | | `403` | Forbidden — brand is inactive | | `404` | Not Found | | `429` | Too Many Requests — rate limit exceeded | | `500` | Internal Server Error | ## Error response format All errors return a JSON body with an `error` field: ```json { "error": "Descriptive error message" } ``` Some errors include additional details: ```json { "error": "Validation failed", "details": { "accountIds": "At least one account ID is required", "content": "Content cannot be empty" } } ``` ## Common errors ### 400 Bad Request ```json { "error": "No valid account IDs provided" } ``` **Causes:** Missing required fields, invalid field types, account IDs that don't belong to your brand. ### 401 Unauthorized ```json { "error": "Unauthorized" } ``` **Causes:** Missing `Authorization` header, invalid API key, expired key. ### 403 Forbidden ```json { "error": "Brand is not active" } ``` **Causes:** Brand has been deactivated, API access has been revoked. ### 404 Not Found ```json { "error": "Post not found" } ``` **Causes:** Post ID doesn't exist or belongs to a different brand. ### 429 Too Many Requests ```json { "error": "Too many requests. Please try again later." } ``` **Causes:** Rate limit exceeded. Check the `Retry-After` header for wait time. See [Rate Limiting](/docs/rate-limiting). ---