نقطة نهاية واحدة لحملة متكاملة
تعيد نقطة الحملات ثلاث نسخ باللهجة المطلوبة ومسودة قالب واتساب وأي صورة أو صوت تم تفعيله. استخدم نقاط النهاية المنفصلة عندما يحتاج منتجك إلى تحكم أدق.
6
لهجات للصوت والحملات
4
أنواع توليد
1
رصيد مشترك
مصادقة من الخادم
أنشئ المفتاح من لوحة المطورين عندما يملك الحساب وصولاً مدفوعاً عبر خطة نشطة أو استحقاق شريك معتمد، ثم أرسله كـ Bearer token من خادمك. يظهر المفتاح مرة واحدة، ويُخزّن في لهجتي كتجزئة أحادية الاتجاه، ويمكن إلغاؤه فوراً.
Authorization: Bearer lhj_live_••••••••••••لا ترسل المفتاح في عنوان URL، ولا تحفظه في مستودع الشفرة، وخصص مفتاحاً لكل بيئة أو تكامل.
نقاط النهاية
| الطريقة | المسار | الغرض | الاعتمادات |
|---|---|---|---|
| GET | /api/v1/capabilities | القيم والتكاليف والحدود الحالية | — |
| POST | /api/v1/copy-generations | نصوص إعلانية أو عناوين أو تحويل لهجة | 1–2 |
| POST | /api/v1/image-generations | صورة حملة مستضافة بشكل دائم | 5 |
| POST | /api/v1/speech-generations | صوت عربي MP3 مستضاف بشكل دائم | 5 |
| POST | /api/v1/campaigns | نص ومسودة واتساب والوسائط المفعّلة | 2–12 |
| GET | /api/v1/usage | الرصيد واستخدام API الأخير | — |
| GET | /api/v1/requests/{request_id} | الحالة والنتيجة المخزنتان | — |
طلب حملة متكاملة
صُمم هذا الهيكل لمنصات تسويق واتساب مع بقائه مستقلاً عن مزود واتساب. استخدم external_id وexternal_customer_id لربط النتيجة بسجلاتك.
curl https://www.lahjty.com/api/v1/campaigns \
-H "Authorization: Bearer $LAHJTY_API_KEY" \
-H "Idempotency-Key: campaign-1842" \
-H "Content-Type: application/json" \
-d '{
"external_id": "campaign-1842",
"external_customer_id": "merchant-91",
"brief": {
"description": "Weekend offer for a specialty coffee subscription",
"offer": "20% off through Saturday",
"objective": "Drive WhatsApp orders",
"dialect": "saudi",
"platform": "whatsapp",
"tone": "warm",
"audience": "specific",
"specific_audience": "Young professionals in Riyadh",
"keywords": ["نهاية الأسبوع"],
"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",
"visual_keywords": ["specialty coffee", "Riyadh"],
"excluded_visuals": ["people", "logos"],
"include_text": true,
"overlay_text": "اطلب الآن",
"overlay_text_language": "ar"
},
"speech": {
"enabled": false,
"voice_profile": "confident_announcer",
"delivery": "natural",
"content_type": "marketing"
}
}
}'JavaScript / TypeScript
const response = await fetch(
"https://www.lahjty.com/api/v1/campaigns",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.LAHJTY_API_KEY}`,
"Idempotency-Key": crypto.randomUUID(),
"Content-Type": "application/json",
},
body: JSON.stringify({
brief: {
description: "Weekend coffee subscription offer",
dialect: "saudi",
platform: "whatsapp",
required_keywords: ["قهوة مختصة"],
excluded_keywords: ["مجاني"],
},
deliverables: {
copy: { type: "ad_copy", framework: "aida" },
image: {
enabled: true,
type: "offer_announcement",
include_text: true,
overlay_text: "Weekend offer",
overlay_text_language: "en",
},
speech: { enabled: false },
},
}),
},
);
if (!response.ok) {
const problem = await response.json();
throw new Error(`${problem.code}: ${problem.detail}`);
}
const campaign = await response.json();جميع عناصر التحكم في التوليد
تحدد نقطة النهاية نوع الأصل، بينما تبقى أنواع النص والصورة والأسلوب والجمهور والإطار وسياق العلامة والنص داخل الصورة وشخصية الصوت عناصر منفصلة وواضحة، فلا يضطر التكامل إلى إخفائها داخل وصف واحد.
| التحكم | الحقول | القيم |
|---|---|---|
| المدخل الأساسي | description · prompt · text | Copy/campaign brief · image brief · exact speech transcript |
| نوع النص | type / deliverables.copy.type | ad_copy · headlines · dialect_conversion |
| إطار الكتابة | framework | none · aida · pas · fab · story |
| الجمهور | audience · specific_audience · target_audience | 19 segments or free-form detail |
| السوق اللغوي | dialect · platform · tone | 7 copy dialects · 10 platforms · custom tone |
| تفاصيل الحملة | product · offer · objective · call_to_action | Optional bounded factual context |
| كلمات النص | keywords · required_keywords · excluded_keywords | Up to 20 per field with deterministic hard-rule checks |
| سياق العلامة | brand_profile_id | Copy, campaign, and standalone image |
| نوع الصورة | type | campaign_visual · product_showcase · lifestyle · offer_announcement · brand_awareness |
| أسلوب الصورة | style | photorealistic · illustration · flat-design · 3d-render · watercolor · minimalist |
| أبعاد الصورة | aspect_ratio | 1:1 · 2:3 · 3:2 · 3:4 · 4:3 · 4:5 · 5:4 · 9:16 · 16:9 |
| النص في الصورة | include_text · overlay_text · overlay_text_language | text-free · auto · ar · en |
| القواعد البصرية | visual_keywords · excluded_visuals | Up to 20 required and 20 excluded concepts |
| الصوت | voice_profile · voice · delivery · content_type | 4 Lahjty profiles · provider override · 7 deliveries · marketing/general |
| المخرجات | deliverables.image.enabled · deliverables.speech.enabled | Copy always · optional image · optional speech |
| ربط سجلات الشريك | external_id · external_customer_id · metadata | Your IDs plus up to 20 metadata strings |
كلمات مفضلة ومطلوبة ومستبعدة
استخدم keywords للكلمات المفضلة طبيعياً، وrequired_keywords للعبارات التي يجب أن تظهر في كل نسخة، وexcluded_keywords للعبارات الممنوعة. تتحقق لهجتي من كل نسخة، وتحاول الإصلاح مرة، ثم تعيد content_rejected بدلاً من نص غير ملتزم.
النص داخل الصورة والتحكم البصري
اجعل include_text بقيمة false لصورة خالية تماماً من النص. لإضافة نص، استخدم true مع overlay_text واختر auto أو ar أو en. يحافظ auto على النص كما هو، بينما تترجم ar أو en النص عند اختلاف اللغة. بعدها تضع لهجتي النص العربي أو الإنجليزي نفسه بشكل حتمي فوق صورة أساسية نظيفة، بدلاً من مطالبة نموذج الصور بتهجئته. استخدم visual_keywords للعناصر المطلوبة وexcluded_visuals للعناصر الممنوعة.
// Strict text-free image
{
"prompt": "Premium Saudi coffee campaign",
"type": "product_showcase",
"style": "photorealistic",
"aspect_ratio": "1:1",
"visual_keywords": ["Saudi coffee cup", "coffee beans"],
"excluded_visuals": ["people", "logos"],
"include_text": false
}
// Arabic overlay
{
"prompt": "Premium Saudi coffee campaign",
"type": "offer_announcement",
"include_text": true,
"overlay_text": "قهوتك، بطابعك",
"overlay_text_language": "ar"
}
// English overlay; auto also preserves English input
{
"prompt": "Premium Saudi coffee campaign",
"type": "lifestyle",
"include_text": true,
"overlay_text": "Weekend coffee offer",
"overlay_text_language": "en"
}قالب واتساب المعاد هو مسودة. يبقى مزود واتساب لديك مسؤولاً عن التحقق وإرساله لاعتماد Meta.
رصيد مشترك
تستخدم طلبات API الرصيد نفسه في لوحة لهجتي. تعمل الاعتمادات المشتراة واعتمادات الاشتراك والقسائم والرصيد المضاف يدوياً من المشرف. ويُعاد الرصيد تلقائياً عند فشل مزود التوليد.
1
تحويل لهجة
2
نص أو عناوين
5
صورة
5
صوت
إعادة محاولات آمنة وسلوك إنتاجي
- أرسل Idempotency-Key فريداً مع كل عملية POST منطقية.
- أعد استخدام المفتاح نفسه والجسم نفسه عند انقطاع الشبكة للحصول على النتيجة المخزنة.
- استخدم مفتاحاً جديداً لطلب جديد؛ يعيد تغيير الجسم مع مفتاح مستخدم خطأ 409.
- احترم Retry-After وترويسات RateLimit عند الخطأ 429.
- احفظ request_id وexternal_id في سجلاتك.
أخطاء متوقعة
تأتي الأخطاء بصيغة application/problem+json مع code ثابت ووصف واضح وrequest_id. خزّن رقم الطلب في سجلاتك وتذاكر الدعم.
{
"type": "https://www.lahjty.com/problems/insufficient-credits",
"title": "Insufficient credits",
"status": 402,
"code": "insufficient_credits",
"detail": "This request costs 7 credits; the current balance is 3.",
"request_id": "req_01…"
}قائمة الإنتاج
- أبقِ المفاتيح في أسرار الخادم.
- ضع مهلة لا تقل عن 60 ثانية للتوليد و120 ثانية للحملات المتكاملة.
- اعرض المحتوى للمراجعة البشرية قبل إرسال حملة جماعية.
- راقب الرصيد عبر GET /usage وأضف تنبيهاً للرصيد المنخفض.
- ألغِ المفاتيح القديمة فور تدويرها.