Social Integration Operations
Managing social media connections and publishing.
Connection Status
View All Connections
SELECT
id, platform, account_name, is_active,
token_expires_at, last_post_at, error_message
FROM "SocialConnection"
WHERE tenant_id = 'TENANT_ID'
ORDER BY platform, account_name;
Check Expiring Tokens
SELECT id, platform, account_name, token_expires_at
FROM "SocialConnection"
WHERE is_active = true
AND token_expires_at < now() + interval '7 days'
ORDER BY token_expires_at;
Token Management
Mark Connection Inactive
UPDATE "SocialConnection"
SET is_active = false, error_message = 'Token expired - reauthentication required'
WHERE id = 'CONNECTION_ID';
Refresh Token (if supported)
# Via API
curl -X POST https://crm-api.digiwedge.dev/api/v1/social/connections/CONNECTION_ID/refresh \
-H "Authorization: Bearer $TOKEN"
Post Operations
View Recent Posts
SELECT id, connection_id, status, content, scheduled_at, published_at, error_message
FROM "SocialPost"
WHERE tenant_id = 'TENANT_ID'
ORDER BY created_at DESC
LIMIT 20;
Check Failed Posts
SELECT
sp.id, sc.platform, sp.content, sp.status, sp.error_message, sp.retry_count
FROM "SocialPost" sp
JOIN "SocialConnection" sc ON sp.connection_id = sc.id
WHERE sp.status = 'FAILED'
AND sp.created_at > now() - interval '7 days'
ORDER BY sp.created_at DESC;
Retry Failed Post
UPDATE "SocialPost"
SET status = 'SCHEDULED', error_message = NULL, retry_count = 0
WHERE id = 'POST_ID';
Cancel Scheduled Post
UPDATE "SocialPost"
SET status = 'CANCELLED'
WHERE id = 'POST_ID' AND status = 'SCHEDULED';
Engagement Sync
Force Engagement Update
# Via API
curl -X POST https://crm-api.digiwedge.dev/api/v1/social/posts/POST_ID/sync-engagement \
-H "Authorization: Bearer $TOKEN"
View Engagement Stats
SELECT
id, platform_post_id,
likes, comments, shares, reach, impressions,
engagement_synced_at
FROM "SocialPost"
WHERE id = 'POST_ID';
Common Issues
Token Expired
Symptoms: Posts failing with auth errors
Resolution:
- Mark connection inactive
- Notify club admin to re-authenticate
- Admin reconnects via OAuth flow
Rate Limited
Symptoms: Posts failing with rate limit error
Resolution:
- Check post frequency:
SELECT count(*), date_trunc('hour', published_at)
FROM "SocialPost"
WHERE connection_id = 'CONNECTION_ID'
AND published_at > now() - interval '24 hours'
GROUP BY date_trunc('hour', published_at);
- Reschedule posts with wider spacing
Content Rejected
Symptoms: Platform rejected content
Resolution:
- Check error message for specifics
- Review content against platform guidelines
- Edit and retry
Connection Not Available
Symptoms: User says they connected but can't post
Check:
SELECT * FROM "SocialConnection"
WHERE tenant_id = 'TENANT_ID'
AND platform = 'FACEBOOK'
ORDER BY created_at DESC;
Platform-Specific Notes
Facebook
- Tokens expire after 60 days (long-lived)
- Page tokens don't expire
- Check page permissions in Meta Business Suite
Instagram
- Connected via Facebook Graph API
- Requires Instagram Business account
- Must be linked to Facebook Page
Twitter
- OAuth 2.0 with PKCE
- Refresh tokens supported
- Check rate limits per endpoint