منشورك الأول
احصل على مفتاح API1. تحقق من الشبكات المتصلة
يخرج المنشور عبر الحسابات المتصلة بالمنشأة. اعرضها؛ وإن غابت إحداها فأنشئ رابط ربط.
curl https://api.sofia-post.com/api/v1/establishments/$ESTABLISHMENT_ID/accounts \
-H "Authorization: Bearer $SOFIA_API_KEY"2. أضف وسائط
يتطلب Instagram وTikTok صورة أو فيديو. استورد واحدًا من رابط https عام؛ تنزّله Sofia إلى مكتبة الوسائط وتعيد id الخاص به.
curl -X POST https://api.sofia-post.com/api/v1/media \
-H "Authorization: Bearer $SOFIA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"establishmentId":"'$ESTABLISHMENT_ID'","url":"https://images.example.com/tarte-tatin.jpg"}'3. تحقق بتجربة جافة
أضف ?dry_run=true: تحكم Sofia على كل شبكة بقواعدها الفعلية وبالحساب المتصل، ولا تكتب شيئًا.
curl -X POST 'https://api.sofia-post.com/api/v1/posts?dry_run=true' \
-H "Authorization: Bearer $SOFIA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"establishmentId": "'$ESTABLISHMENT_ID'",
"targets": [
{ "platform": "instagram", "text": "Tarte tatin du jour", "media": [{ "id": "'$MEDIA_ID'" }] },
{ "platform": "facebook", "text": "Tarte tatin du jour", "media": [{ "id": "'$MEDIA_ID'" }] }
]
}'{
"status": "ready",
"dryRun": true,
"targets": [
{ "platform": "instagram", "accountId": "fecd0904-…", "handle": "sof_ia_officiel", "state": "ready" },
{ "platform": "facebook", "accountId": "a423b3a4-…", "handle": "Sofia post", "state": "ready" }
]
}4. انشر
أرسل الجسم نفسه دون dry_run، مع Idempotency-Key حتى لا تنشر إعادة المحاولة مرتين أبدًا. بدون scheduledAt يخرج المنشور الآن؛ ومع scheduledAt في المستقبل يُجدول.
curl -X POST https://api.sofia-post.com/api/v1/posts \
-H "Authorization: Bearer $SOFIA_API_KEY" \
-H 'Content-Type: application/json' \
-H "Idempotency-Key: $(uuidgen)" \
-d @post.json5. تابعه
يُجاب المنشور بـ publishing، ثم تنتقل كل شبكة إلى published مع رابطها الدائم، أو إلى failed مع سببها. اقرأه بـ GET /v1/posts/{id}، أو سجّل webhook ليُخبرك.
{
"id": "efc578cc-ef79-40e9-876d-be1a33d3b8db",
"status": "published",
"targets": [
{
"platform": "instagram",
"state": "published",
"publishedAt": "2026-11-02T20:17:25.453Z",
"permalink": "https://www.instagram.com/p/DfQJVPGFfb_/"
}
]
}