دليل API

الحملات المتكاملة

أنشئ النص ومسودة واتساب وصورة وصوتاً اختياريين في طلب واحد آمن لإعادة المحاولة.

POST/campaigns

حملة عربية مع صورة وصوت

ينشئ ثلاث نسخ ومسودة واتساب وصورة وصوتاً في عملية واحدة. التكلفة القصوى 12 عملة.

curl --request POST \
  --url https://www.lahjty.com/api/v1/campaigns \
  --header "Authorization: Bearer $LAHJTY_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: campaign-merchant91-1849" \
  --data '{
  "external_id": "campaign-1849",
  "external_customer_id": "merchant-91",
  "brief": {
    "description": "Weekend offer for a specialty coffee subscription",
    "product": "Monthly specialty coffee subscription",
    "offer": "20% off through Saturday",
    "objective": "Drive WhatsApp orders",
    "output_language": "ar",
    "market": "SA",
    "dialect": "saudi",
    "platform": "whatsapp",
    "tone": "warm",
    "audience": "specific",
    "specific_audience": "Young professionals in Riyadh",
    "required_keywords": [
      "قهوة مختصة"
    ],
    "excluded_keywords": [
      "مجاني"
    ],
    "call_to_action": "اطلب الآن"
  },
  "deliverables": {
    "copy": {
      "type": "ad_copy",
      "framework": "aida"
    },
    "image": {
      "enabled": true,
      "type": "product_showcase",
      "style": "photorealistic",
      "aspect_ratio": "1:1",
      "resolution": "1K",
      "visual_keywords": [
        "specialty coffee",
        "Riyadh morning"
      ],
      "excluded_visuals": [
        "people",
        "logos"
      ],
      "include_text": false
    },
    "speech": {
      "enabled": true,
      "voice_profile": "confident_announcer",
      "delivery": "natural",
      "content_type": "marketing"
    }
  },
  "metadata": {
    "experiment": "repeat-use-pilot"
  }
}'

Example response

response.json
{
  "id": "cmp_01jexample",
  "object": "campaign",
  "request_id": "req_01jexample",
  "status": "completed",
  "external_id": "campaign-1849",
  "output_language": "ar",
  "market": "SA",
  "dialect": "saudi",
  "copy": {
    "variants": [
      {
        "index": 1,
        "content": "..."
      }
    ]
  },
  "whatsapp_template": {
    "status": "draft",
    "header": "خصم 20٪ حتى السبت",
    "body": "...",
    "footer": null,
    "buttons": [
      {
        "type": "quick_reply",
        "text": "اطلب الآن"
      }
    ],
    "warnings": [
      "This convenience draft is not a Meta submission payload."
    ]
  },
  "image": {
    "url": "https://example.convex.cloud/api/storage/image"
  },
  "speech": {
    "url": "https://example.convex.cloud/api/storage/audio"
  },
  "usage": {
    "credits_used": 12,
    "balance_after": 476
  }
}
POST/campaigns

حملة نص فقط

عطّل الصورة والصوت لتجربة منخفضة المخاطر بتكلفة عملتين.

curl --request POST \
  --url https://www.lahjty.com/api/v1/campaigns \
  --header "Authorization: Bearer $LAHJTY_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: campaign-copy-only-1850" \
  --data '{
  "external_id": "campaign-1850",
  "external_customer_id": "merchant-93",
  "brief": {
    "description": "Back-to-school stationery sale",
    "output_language": "en",
    "market": "AE",
    "platform": "whatsapp",
    "tone": "friendly",
    "call_to_action": "Shop the collection"
  },
  "deliverables": {
    "copy": {
      "type": "ad_copy",
      "framework": "aida"
    },
    "image": {
      "enabled": false
    },
    "speech": {
      "enabled": false
    }
  }
}'

سلوك الفشل الجزئي

تُحسب تكلفة الحملة حسب المخرجات المطلوبة وتُسترد عند فشل التوليد وفق عقد الواجهة. احتفظ بالنص السابق للتاجر حتى تُخزّن الاستجابة المكتملة.