最初の投稿

API キーを取得

1. 連携済みネットワークを確認する

投稿は、店舗に連携されたアカウントを通じて公開されます。一覧を取得し、足りないものがあれば連携リンクを作成してください。

bash
curl https://api.sofia-post.com/api/v1/establishments/$ESTABLISHMENT_ID/accounts \
  -H "Authorization: Bearer $SOFIA_API_KEY"

2. メディアを追加する

Instagram と TikTok には写真または動画が必要です。公開されている https の URL からインポートします。Sofia がメディアライブラリにダウンロードし、id を返します。

bash
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 は、各ネットワークの実際のルールと連携済みアカウントに基づいて判定し、何も書き込みません。

bash
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'" }] }
    ]
  }'
json
{
  "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 を指定すると予約されます。

bash
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.json

5. 追跡する

投稿は publishing で応答され、その後、各ネットワークがパーマリンク付きの published、または理由付きの failed に変わります。GET /v1/posts/{id} で取得するか、webhook を登録して通知を受けてください。

json
{
  "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_/"
    }
  ]
}