cURL Examples
Command-line examples for using the Boring API with cURL.
Basic Setup
Set your API key as an environment variable:
export BORING_API_KEY="boring_xxxxxxxxxxxxx"
Simple POST Request
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "your-account-id",
"content": {
"text": "Hello from cURL!",
"mediaUrls": [],
"platform": "facebook"
},
"target": {
"targetType": "facebook"
}
}
}'
Using JSON Files
Create a JSON file with your request body:
# request.json
{
"post": {
"accountId": "your-account-id",
"content": {
"text": "Hello from cURL!",
"mediaUrls": [],
"platform": "facebook"
},
"target": {
"targetType": "facebook"
}
}
}
Then use it:
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d @request.json
Facebook Examples
Text-Only Post
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "fb-account-id",
"content": {
"text": "Hello from Boring API! π",
"mediaUrls": [],
"platform": "facebook"
},
"target": {
"targetType": "facebook"
}
}
}'
Single Photo
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "fb-account-id",
"content": {
"text": "Check out our new product!",
"mediaUrls": ["https://example.com/product.jpg"],
"platform": "facebook"
},
"target": {
"targetType": "facebook"
}
}
}'
Photo Album
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "fb-account-id",
"content": {
"text": "Our best moments! πΈ",
"mediaUrls": [
"https://example.com/photo1.jpg",
"https://example.com/photo2.jpg",
"https://example.com/photo3.jpg"
],
"platform": "facebook"
},
"target": {
"targetType": "facebook"
}
}
}'
Video Post
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "fb-account-id",
"content": {
"text": "Watch our demo! π₯",
"mediaUrls": ["https://example.com/demo.mp4"],
"platform": "facebook"
},
"target": {
"targetType": "facebook"
}
}
}'
Instagram Examples
Single Photo
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "ig-account-id",
"content": {
"text": "Beautiful sunset π
\n\n#photography #nature",
"mediaUrls": ["https://example.com/sunset.jpg"],
"platform": "instagram"
},
"target": {
"targetType": "instagram"
}
}
}'
Carousel
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "ig-account-id",
"content": {
"text": "Swipe for more! β‘οΈ\n\n#collection #new",
"mediaUrls": [
"https://example.com/item1.jpg",
"https://example.com/item2.jpg",
"https://example.com/item3.jpg"
],
"platform": "instagram"
},
"target": {
"targetType": "instagram"
}
}
}'
Reels
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "ig-account-id",
"content": {
"text": "Quick tutorial! π₯\n\n#tutorial #tips",
"mediaUrls": ["https://example.com/tutorial.mp4"],
"platform": "instagram"
},
"target": {
"targetType": "instagram"
}
}
}'
Threads Examples
Text-Only
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "threads-account-id",
"content": {
"text": "Just shipped a new feature! π",
"mediaUrls": [],
"platform": "threads"
},
"target": {
"targetType": "threads"
}
}
}'
Photo Post
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "threads-account-id",
"content": {
"text": "Morning vibes β",
"mediaUrls": ["https://example.com/morning.jpg"],
"platform": "threads"
},
"target": {
"targetType": "threads"
}
}
}'
Long-Form Thread
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"post": {
"accountId": "threads-account-id",
"content": {
"text": [
"π§΅ Let me tell you about our API (thread)",
"It started with a simple idea: make publishing easier.",
"We researched all the pain points.",
"So we built Boring: one API for all platforms.",
"What do you think? π"
],
"mediaUrls": [],
"platform": "threads"
},
"target": {
"targetType": "threads"
}
}
}'
Pretty Print Response
Use jq to format JSON responses:
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d @request.json | jq '.'
Extract specific fields:
# Get post ID
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d @request.json | jq -r '.data.post_id'
# Check if successful
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d @request.json | jq -r '.success'
Save Response to File
curl -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d @request.json \
-o response.json
cat response.json | jq '.'
Verbose Output
See full request and response:
curl -v -X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d @request.json
Only Show HTTP Status
curl -s -o /dev/null -w "%{http_code}" \
-X POST https://boring.aiagent-me.com/v2/posts \
-H "boring-api-key: $BORING_API_KEY" \
-H "Content-Type: application/json" \
-d @request.json
Shell Script Example
Create a reusable script:
#!/bin/bash
# publish.sh
API_KEY="${BORING_API_KEY}"
API_URL="https://boring.aiagent-me.com/v2/posts"
# Check if API key is set
if [ -z "$API_KEY" ]; then
echo "Error: BORING_API_KEY not set"
exit 1
fi
# Parse arguments
ACCOUNT_ID="$1"
PLATFORM="$2"
TEXT="$3"
MEDIA_URL="$4"
if [ -z "$ACCOUNT_ID" ] || [ -z "$PLATFORM" ] || [ -z "$TEXT" ]; then
echo "Usage: $0 <account_id> <platform> <text> [media_url]"
exit 1
fi
# Build media array
if [ -z "$MEDIA_URL" ]; then
MEDIA_ARRAY="[]"
else
MEDIA_ARRAY="[\"$MEDIA_URL\"]"
fi
# Create JSON payload
JSON=$(cat <<EOF
{
"post": {
"accountId": "$ACCOUNT_ID",
"content": {
"text": "$TEXT",
"mediaUrls": $MEDIA_ARRAY,
"platform": "$PLATFORM"
},
"target": {
"targetType": "$PLATFORM"
}
}
}
EOF
)
# Make request
curl -X POST "$API_URL" \
-H "boring-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d "$JSON" | jq '.'
Usage:
chmod +x publish.sh
# Text-only post
./publish.sh "account-id" "facebook" "Hello World!"
# Post with media
./publish.sh "account-id" "instagram" "Check this out!" "https://example.com/image.jpg"
Batch Publishing Script
#!/bin/bash
# batch_publish.sh
API_KEY="${BORING_API_KEY}"
API_URL="https://boring.aiagent-me.com/v2/posts"
# Read posts from CSV file
# Format: account_id,platform,text,media_url
while IFS=',' read -r account_id platform text media_url; do
echo "Publishing to $platform..."
# Build media array
if [ -z "$media_url" ]; then
media_array="[]"
else
media_array="[\"$media_url\"]"
fi
# Create JSON
json=$(cat <<EOF
{
"post": {
"accountId": "$account_id",
"content": {
"text": "$text",
"mediaUrls": $media_array,
"platform": "$platform"
},
"target": {
"targetType": "$platform"
}
}
}
EOF
)
# Make request
response=$(curl -s -X POST "$API_URL" \
-H "boring-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d "$json")
# Check result
success=$(echo "$response" | jq -r '.success')
if [ "$success" = "true" ]; then
post_id=$(echo "$response" | jq -r '.data.post_id')
echo "β Success: $post_id"
else
error=$(echo "$response" | jq -r '.message')
echo "β Failed: $error"
fi
# Rate limiting
sleep 2
done < posts.csv
Sample posts.csv:
fb-account-id,facebook,Hello from Facebook!,
ig-account-id,instagram,Check out this photo!,https://example.com/photo.jpg
threads-account-id,threads,Just launched!,
Usage:
chmod +x batch_publish.sh
./batch_publish.sh
Testing Media URLs
Before publishing, test if media URLs are accessible:
# Check if URL returns 200
curl -I https://example.com/image.jpg
# Should return:
# HTTP/2 200
# content-type: image/jpeg
Check multiple URLs:
#!/bin/bash
# check_media.sh
for url in "$@"; do
status=$(curl -s -o /dev/null -w "%{http_code}" "$url")
content_type=$(curl -s -I "$url" | grep -i content-type | cut -d' ' -f2)
if [ "$status" = "200" ]; then
echo "β $url ($content_type)"
else
echo "β $url (HTTP $status)"
fi
done
Usage:
./check_media.sh \
"https://example.com/image1.jpg" \
"https://example.com/image2.jpg" \
"https://example.com/video.mp4"
Error Handling
Handle errors in scripts:
#!/bin/bash
response=$(curl -s -X POST "$API_URL" \
-H "boring-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d @request.json)
success=$(echo "$response" | jq -r '.success')
if [ "$success" != "true" ]; then
error=$(echo "$response" | jq -r '.error')
message=$(echo "$response" | jq -r '.message')
echo "Error: $error - $message" >&2
# Handle specific errors
case "$error" in
"TokenExpired")
echo "Please reconnect your account!" >&2
exit 1
;;
"RateLimitExceeded")
retry_after=$(echo "$response" | jq -r '.retry_after')
echo "Rate limited. Retry in ${retry_after}s" >&2
exit 2
;;
*)
exit 3
;;
esac
fi
echo "Success!"
Next Steps
- Python Examples - Python code examples
- JavaScript Examples - Node.js examples
- Use Cases - Real-world scenarios
- API Reference - Complete API docs