واجهة برمجة تطبيقات شبكة فلسطين

اقرأ أعمالك التجارية واستورد منتجاتك في السوق من برنامجك الخاص. الإصدار الأول تجريبي (بيتا): يضيف ولا يحذف، ونُنبّهك قبل إزالة أي شيء.

الإصدار 1.0.0-betaتنزيل ملف OpenAPI

العنوان الأساسي

https://api.palinetwork.com/v1

هذه النسخة العربية ترجمة آلية لم تُراجَع بعد. النص الإنجليزي هو المرجع. مرجع واجهة البرمجة أدناه بالإنجليزية.

البدء السريع

تحتاج إلى نحو خمس دقائق. كل مثال يقرأ الرمز ومعرّف العمل التجاري من البيئة (PALI_TOKEN وBUSINESS_ID)، فيمكنك نسخه كما هو. الأسعار بأصغر وحدة نقدية: 3500 تعني 35.00.

  1. الخطوة 1

    أنشئ رمز وصول لعمل تجاري واحد

    في لوحة التحكم افتح «رموز واجهة البرمجة» وأنشئ رمزاً. اربطه بالعمل التجاري الذي تريد العمل عليه، واختر الصلاحيات businesses:read وproducts:read وproducts:write.

    يبدأ الرمز بـ pali_ ويظهر مرة واحدة فقط. انسخه الآن واحتفظ به سراً، ثم ضعه في بيئتك:

    يفتح لوحة التحكم (سجّل الدخول أولاً).

    export PALI_TOKEN="pali_…"

  2. الخطوة 2

    اعثر على عملك التجاري

    استدعِ GET /businesses. الرمز المربوط بعمل واحد يرى هذا العمل فقط. انسخ قيمة id: ستدخل في كل مسار أدناه.

    export BUSINESS_ID="<id>"

    curl -X GET "https://api.palinetwork.com/v1/businesses" \
      -H "Authorization: Bearer $PALI_TOKEN"

    تبدو الاستجابة هكذا

    {
      "data": [
        {
          "id": "0198e6f2-8d47-7c3e-a6b1-2f4d9c0a7e53",
          "name": "Nablus Soap House",
          "slug": "nablus-soap-house",
          "role": "owner",
          "marketplace": {
            "enabled": true,
            "suspended": false,
            "plan_allows_selling": true
          }
        }
      ]
    }

  3. الخطوة 3

    استورد منتجاً واحداً

    أرسل المنتج بالطريقة PUT تحت مفتاح من اختيارك (OLIVE-SOAP هنا). الإرسال الأول ينشئه، وإرساله مرة أخرى يحدّثه. اقرأ outcome لتعرف ما حدث، واقرأ status وawaiting_review لتعرف ما سيراه المشترون.

    curl -X PUT "https://api.palinetwork.com/v1/businesses/$BUSINESS_ID/products/by-external-id/OLIVE-SOAP" \
      -H "Authorization: Bearer $PALI_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "title": "Olive soap",
        "description": "Handmade in Nablus.",
        "status": "active",
        "currency": "ILS",
        "variants": [
            {
                "external_id": "OLIVE-SOAP-1",
                "sku": "OLIVE-SOAP",
                "price": 3500,
                "quantity": 12,
                "weight_grams": 100
            }
        ]
    }'

    تبدو الاستجابة هكذا

    {
      "external_id": "OLIVE-SOAP",
      "outcome": "created",
      "product_id": "0198e6f4-3c1a-7b52-9d0e-5a1f2b7c9e10",
      "status": "active",
      "awaiting_review": false,
      "images": "none",
      "missing": [],
      "reason": null,
      "errors": [],
      "warnings": []
    }

  4. الخطوة 4

    استورد دفعة

    أرسل حتى 100 منتج في طلب واحد. لكل منتج نتيجته بترتيب الإرسال. تكرر هذه الدفعة المنتج من الخطوة 3، فيعود unchanged، بينما يعود المنتجان الآخران created. للمنتج الأول صورة تُجلب بعد الاستجابة (images تساوي pending).

    curl -X POST "https://api.palinetwork.com/v1/businesses/$BUSINESS_ID/products/batch" \
      -H "Authorization: Bearer $PALI_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "products": [
            {
                "external_id": "OLIVE-SOAP",
                "title": "Olive soap",
                "description": "Handmade in Nablus.",
                "status": "active",
                "currency": "ILS",
                "variants": [
                    {
                        "external_id": "OLIVE-SOAP-1",
                        "sku": "OLIVE-SOAP",
                        "price": 3500,
                        "quantity": 12,
                        "weight_grams": 100
                    }
                ]
            },
            {
                "external_id": "LAUREL-SOAP",
                "title": "Laurel soap",
                "status": "active",
                "currency": "ILS",
                "variants": [
                    {
                        "external_id": "LAUREL-SOAP-1",
                        "sku": "LAUREL-SOAP",
                        "price": 4800,
                        "quantity": 40
                    }
                ],
                "images": [
                    {
                        "url": "https://shop.example/img/laurel-soap.jpg",
                        "alt": "A bar of laurel soap"
                    }
                ]
            },
            {
                "external_id": "ZAATAR-MIX",
                "title": "Za'\''atar mix",
                "status": "draft",
                "currency": "ILS",
                "variants": [
                    {
                        "external_id": "ZAATAR-MIX-1",
                        "sku": "ZAATAR-MIX",
                        "price": 2500,
                        "quantity": null
                    }
                ]
            }
        ]
    }'

    تبدو الاستجابة هكذا

    {
      "results": [
        {
          "external_id": "OLIVE-SOAP",
          "outcome": "unchanged",
          "product_id": "0198e6f4-3c1a-7b52-9d0e-5a1f2b7c9e10",
          "status": "active",
          "awaiting_review": false,
          "images": "none",
          "missing": [],
          "reason": null,
          "errors": [],
          "warnings": []
        }
      ],
      "summary": {
        "created": 2,
        "updated": 0,
        "linked": 0,
        "unchanged": 1,
        "skipped": 0,
        "failed": 0
      }
    }

  5. الخطوة 5

    اقرأ منتجاتك

    اعرض ما يملكه العمل التجاري. تسير الصفحات بترتيب الإنشاء، وتكون next_cursor تساوي null في الصفحة الأخيرة. أضف external_id=OLIVE-SOAP للعثور على منتج واحد بمفتاحك.

    curl -X GET "https://api.palinetwork.com/v1/businesses/$BUSINESS_ID/products?limit=25&status=active" \
      -H "Authorization: Bearer $PALI_TOKEN"

الأدلة

المصادقة والصلاحيات

يحمل كل طلب الترويسة Authorization: Bearer pali_…. الرمز يخص عضواً، ويظهر مرة واحدة، ويبقى 90 يوماً ما لم تختر مدة أخرى (365 كحد أقصى)، ولا يملك العضو أكثر من 5 رموز نشطة. إذا ألغيت رمزاً في لوحة التحكم توقف عن العمل فوراً.

يمكن ربط الرمز بعمل تجاري واحد. على أي عمل آخر يردّ بـ 404 تماماً كما لو كان العمل غير موجود. الرمز غير المربوط يرى كل الأعمال التي يملكها صاحبه أو يديرها. لكتابة المنتجات تحتاج إلى دور مالك أو مدير.

تحتاج كل عملية إلى صلاحية واحدة. الرمز الذي لا يملكها يحصل على 403 مع insufficient_scope قبل البحث عن أي شيء آخر.

  • businesses:read: عرض أعمالك التجارية.
  • products:read: عرض منتجات عمل تجاري وقراءتها.
  • products:write: إنشاء المنتجات واستبدالها، واحداً واحداً أو في دفعة.

حدود الاستخدام

يسري حدّان على مالك الرمز، ويُشتركان بين كل رموزه. هما إعدادات وقد تتغير، فالأرقام أدناه هي أرقام اليوم، والترويسات تخبرك دائماً بالأرقام الحالية.

يحمل كل طلب ناجح الترويسات RateLimit-Limit وRateLimit-Remaining وRateLimit-Reset (بالثواني) للنافذة الأقرب إلى النفاد. عند بلوغ الحد تكون الاستجابة 429 مع rate_limited وترويسة Retry-After: انتظر هذا العدد من الثواني. لم يُكتب شيء. وترد Retry-After مع 503 أيضاً.

  • الطلبات في الدقيقة: 300. الدفعة تُحسب طلباً واحداً.
  • الوحدات في اليوم: 60,000. المنتج في عملية كتابة وحدة واحدة، وكل طلب آخر وحدة واحدة. تحتاج الدفعة إلى كل وحداتها المتبقية، وإلا رُفضت كلها بـ 429 قبل كتابة أي منتج.
  • تنزيلات الصور في اليوم: 2,000 صورة جديدة. بعد ذلك تُتخطى الصورة مع التحذير image_budget وتُجرَّب مجدداً عند إرسال المنتج في المرة التالية.

مفاتيحك، وتبنّي المنتجات الموجودة

تسمّي كل منتج بقيمة external_id من اختيارك: من 1 إلى 128 حرفاً قابلاً للطباعة بلا مسافات في جسم الدفعة. وفي عنوان PUT الفردي لا يجوز إلا A-Z a-z 0-9 : _ -. المفتاح الخارج عن هذا النمط يمر عبر مسار الدفعة. المفاتيح دقيقة (حالة الأحرف مهمة) وتخص العمل التجاري. ولكل متغيّر external_id خاص به أيضاً.

المفتاح الذي لم تستخدمه من قبل يبحث أولاً عن منتج يملكه العمل التجاري بالرمز SKU أو الباركود نفسه. إذا وجد منتجاً واحداً بالضبط لا يديره نظام آخر تبنّاه وردّ linked، فلا يتكرر في الاستيراد الأول ما أنشأه البائع في لوحة التحكم. وإذا تطابق عدة منتجات تحصل على ambiguous_match، وإذا كان نظام آخر (استيراد متجر أو ملف) يديره تحصل على managed_by_source. لا يُكتب فوق شيء في هاتين الحالتين.

المنتجات التي ترسلها يديرها تكاملك مع الواجهة: تعرض لوحة التحكم «يُدار بواسطة تكامل الواجهة البرمجية» وتقفل الحقول التي ترسلها إلى أن يفكّ البائع الارتباط. ويمكن للبائع أيضاً استرجاع المنتج، فيرد skipped مع السبب excluded (أو removed إذا حذفه).

الأسعار والعملات

المبالغ أعداد صحيحة بأصغر وحدة من currency المنتج (ISO 4217): سنت، أغورة، فلس. 3500 بالشيكل تعني 35.00. استخدم compare_at_price للسعر السابق عندما يكون price سعر تخفيض.

للدينار الأردني يجب أن يكون المبلغ من مضاعفات 10 حالياً، وإلا فشل المنتج بـ precision_unsupported. سيخفَّف هذا لاحقاً دون تغيير في العقد. والعملة التي لا يبيع بها السوق تُفشل المنتج بـ unsupported_currency.

الدفعات: النتائج والفشل الجزئي

تقبل الدفعة من 1 إلى 100 منتج وما لا يزيد على 1,000 متغيّر. يُكتب كل منتج على حدة، فلا يُلغي فشل أحدها غيره. الاستجابة 200 مع قائمة results بترتيب الإرسال وsummary، حتى لو فشلت كل المنتجات: اقرأ كل نتيجة.

لكل نتيجة outcome: created أو updated أو linked أو unchanged أو skipped أو failed، وقد تُضاف نتائج جديدة، فتجاهل ما لا تعرفه. النتيجة failed تسرد errors، وقد تحمل أي نتيجة warnings لم توقفها، مثل gtin_dropped.

الطلب الذي لا يمكن قراءته أصلاً (أنواع خاطئة، حقل مجهول، مفتاح مكرر، منتجات كثيرة جداً) يُرفض كله بـ 422 ولا يُكتب شيء. يجب أن يكون الجسم JSON (application/json) وبحجم 64 كيلوبايت على الأكثر، و1 ميغابايت في مساري كتابة المنتجات.

إعادة المحاولة بأمان

مساران الكتابة كلاهما upsert بمفتاحك، فيمكنك إرسال الطلب نفسه مجدداً كلما لم تتأكد من وصوله. إرسال المنتج مرة أخرى دون تغيير يردّ unchanged مع product_id نفسه. لا تحتاج إلى Idempotency-Key.

أعد المحاولة بعد خطأ في الشبكة، وبعد 429 و503 و409 (import_in_progress، أي أن كتابة أخرى على العمل نفسه ما زالت جارية) بعد انقضاء Retry-After. لا تعد إرسال أجوبة 4xx الأخرى كما هي: ستفشل بالطريقة نفسها حتى تصلح الطلب. اذكر request_id للمشكلة عند طلب المساعدة.

الصور بالعنوان

أرسل حتى 12 صورة لكل منتج (11 عندما يحتوي المنتج على فيديو مرفوع) كعناوين https (images)، وصورة لكل متغيّر (image_url). يجب أن تكون عامة، وعلى المنفذ القياسي، وبلا اسم مستخدم في العنوان.

نجلبها بعد طلبك، مرة لكل عنوان، فتكون الاستجابة سريعة وتقول images إنها pending. الصورة التي تعذّر نسخها تظهر تحذيراً على المنتج (اقرأه بـ GET)، وتُجرَّب مجدداً عند إرسال المنتج في المرة التالية.

ما يراه المشترون

status هو ما تقوله عن المنتج. أما الكلمة الأخيرة فللسوق: البائع غير المفعّل بعد يحصل على مسودات، وarchived يبقى مؤرشفاً، ومنتجات البائع الجديد الأولى تنتظر المراجعة (awaiting_review). تسرد missing ما ما زال على البائع إضافته في لوحة التحكم، كصورة أو فئة.

الإصدارات وإيقاف الاستخدام

الإصدار في العنوان (/v1). الإصدار الأول تجريبي (بيتا). داخله لا تضيف التغييرات إلا: مسارات جديدة، وحقول طلب اختيارية، وحقول استجابة، وترويسات، وقيماً جديدة لـ code أو outcome. يجب أن يتجاهل عميلك ما لا يعرفه.

خلال مرحلة البيتا تتطلب إزالة شيء أو تغييره إشعاراً قبل 30 يوماً. وبعد البيتا (ينهيها المؤسسون) يكون الإشعار 6 أشهر على الأقل، ويبقى الإصدار المستبدَل يعمل 6 أشهر على الأقل بعد استقرار خلفه.

نعلن الإزالة بالترويستين Deprecation وSunset، وبإدخال مؤرَّخ في سجل التغييرات أدناه، وبرسالة بريد إلى الأعضاء الذين استخدمت رموزهم ذلك الشيء في آخر 90 يوماً.

الأخطاء

كل فشل مستند مشكلة (RFC 9457) فيه status الخاص بـ HTTP ورمز code ثابت وrequest_id. اعتمد على code: فقد يتغير title وdetail. قد تُضاف رموز جديدة، فتعامل مع المجهول منها حسب حالته.

رموز المشكلات

الحالةالرمزالمعنىما العمل
400malformed_jsonالجسم ليس JSON صالحاً.أصلح الـ JSON وأرسله مجدداً.
401unauthenticatedالرمز مفقود أو مشوَّه أو مجهول أو منتهي أو ملغى، أو ليس رمز عضو. الجواب نفسه في كل الحالات.افحص ترويسة Authorization، أو أنشئ رمزاً جديداً.
403insufficient_scopeالرمز لا يملك الصلاحية التي تحتاجها هذه العملية.أنشئ رمزاً بالصلاحية المذكورة للعملية.
403account_suspendedصاحب الرمز موقوف.تواصل معنا.
403email_unverifiedصاحب الرمز لم يتحقق من بريده الإلكتروني.تحقق من البريد الإلكتروني في حسابك.
403insufficient_roleأنت في فريق العمل التجاري، لكن دورك لا يتيح استخدام منتجاته.اطلب من مالك العمل التجاري أو مديره.
403plan_requiredتحتاج الكتابة إلى خطة للعمل التجاري تشمل البيع.غيّر الخطة في لوحة التحكم.
403commission_overdueعمولة العمل التجاري متأخرة، فترفض الكتابة.ادفع العمولة المستحقة في لوحة التحكم.
404not_foundلا يوجد مسار أو سجل كهذا. العمل التجاري الذي لا دور لك عليه، أو غير المربوط برمزك، أو غير الموجود تبدو كلها متشابهة.افحص المعرّفات والعمل التجاري المربوط بالرمز.
405method_not_allowedالمسار لا يقبل طريقة HTTP هذه.استخدم الطريقة المذكورة في المرجع.
409import_in_progressما زالت كتابة أخرى على منتجات هذا العمل التجاري جارية. لم يُكتب شيء.أرسله مجدداً بعد Retry-After.
413payload_too_largeالجسم أكبر مما يسمح به المسار.أرسل منتجات أقل في كل طلب.
415unsupported_media_typeالجسم ليس application/json.أرسل Content-Type: application/json.
422validation_failedحقل غير صالح أو مجهول. لم يُكتب شيء.اقرأ errors وأصلح كل حقل وأرسل مجدداً.
429rate_limitedبلغ مالك الرمز حدّه، أو تحتاج الدفعة إلى وحدات أكثر من المتبقي. لم يُكتب شيء.انتظر Retry-After ثانية.
500server_errorحدث خلل من جهتنا.أعد المحاولة بعد لحظة، واذكر request_id إن استمر الفشل.
503overloadedالمنصة مشغولة.أعد المحاولة بعد Retry-After.
503scope_disabledالطلبات من هذا النوع متوقفة مؤقتاً.أعد المحاولة بعد Retry-After.
503unavailableالواجهة قيد الصيانة.أعد المحاولة بعد Retry-After.

لماذا فشل منتج واحد

في الدفعة يحمل المنتج الذي تعذّرت كتابته outcome: failed وقائمة errors بهذه الرموز. ويبقى الطلب نفسه 200.

الرمزالمعنىما العمل
invalid_fieldقيمة غير مسموح بها؛ يسميها field.أصلح القيمة.
sku_takenمنتج أو متغيّر آخر في هذا العمل التجاري يستخدم الرمز SKU هذا، أو أنه مكرر في المنتج.استخدم SKU فريداً داخل العمل التجاري.
too_many_optionsللمنتج 3 خيارات على الأكثر.أرسل 3 أسماء خيارات أو أقل.
too_many_variantsللمنتج 100 متغيّر على الأكثر.قسّمه إلى عدة منتجات.
no_variantsيحتاج المنتج إلى متغيّر واحد على الأقل بسعر.أرسل متغيّراً واحداً، حتى للمنتج البسيط.
variants_not_enabledالمنتجات متعددة المتغيّرات غير متاحة بعد.أرسل متغيّراً واحداً لكل منتج.
unsupported_currencyالسوق لا يبيع بهذه العملة.استخدم عملة يبيع بها السوق.
precision_unsupportedلهذه العملة يجب أن يكون المبلغ عدداً صحيحاً من المئات من العملة إلى أن يخزّن السوق منازل عشرية أكثر.للدينار الأردني أرسل من مضاعفات 10 فلس.
invalid_priceالسعر مفقود أو ليس مبلغاً يستطيع السوق تخزينه.أرسل price عدداً صحيحاً بأصغر وحدة.
over_limitبلغ العمل التجاري عدد المنتجات المسموح له عبر الواجهة.تواصل معنا إن احتجت إلى عدد أكبر.
ambiguous_matchأكثر من منتج في هذا العمل التجاري له SKU أو باركود نفسه، فلم يُختر أي منها.اجعل رموز SKU فريدة في لوحة التحكم أولاً.
managed_by_sourceالمنتج ذو SKU أو الباركود هذا يديره نظام آخر (استيراد متجر أو ملف) ولا يجري تبنّيه.افصله في لوحة التحكم، أو اتركه لذلك النظام.

التحذيرات

التحذير لم يمنع كتابة المنتج. يوجد في warnings مع field الذي يخصه.

الرمزالمعنىما العمل
gtin_droppedالباركود ليس GTIN صالحاً، فلم يُحفظ.أرسل GTIN صالحاً من 8 أو 12 أو 13 أو 14 رقماً.
image_failedتعذّر نسخ الصورة.تُجرَّب مجدداً عند إرسال المنتج في المرة التالية.
image_budgetاستُنفد الحد اليومي لتنزيل الصور.تُجرَّب مجدداً عند إرسال المنتج في المرة التالية.
image_hostعنوان الصورة غير مسموح به.استخدم عنوان https عاماً.
too_many_imagesللمنتج صور أكثر مما يمكن عرضه: 12، أو 11 عندما يحتوي على فيديو مرفوع.أرسل صوراً أقل، أو أزل الفيديو المرفوع.

القواعد وراء 422

يسرد 422 (validation_failed) الحقول في errors، ولكل منها القاعدة التي فشلت، مثل هذه. وتستخدم أخطاء الطلب كله المسار الكامل، مثل products.3.variants.0.gtin.

الرمزالمعنىما العمل
requiredحقل مطلوب مفقود.أضفه.
maxقيمة أطول أو أكبر من المسموح.افحص الحد في المرجع.
unknown_fieldالحقل غير موجود. الحقول المجهولة مرفوضة.احذفه.

مرجع الواجهة

صادِق على كل طلب بالترويسة Authorization: Bearer pali_…. العمليات مرتبة كما في ملف المواصفات.

يُولَّد المرجع من ملف OpenAPI نفسه الذي يمكنك تنزيله، لذلك يطابق الواجهة دائماً.

GET/businesses

List your businesses

يتطلب الصلاحية businesses:read

The businesses you may manage (as owner or manager), with your role and where each stands in the marketplace. A token bound to one business sees only that one.

جسم الاستجابة (200)

الحقلالنوعالوصف
dataمطلوبarray of objects
data[].idمطلوبstring (uuid)
data[].nameمطلوبstring
data[].slugمطلوبstring
data[].roleمطلوبowner | managerYour role on the business. New values may be added.
data[].marketplaceمطلوبobject
data[].marketplace.enabledمطلوبbooleanThe business takes part in the marketplace.
data[].marketplace.suspendedمطلوبboolean
data[].marketplace.plan_allows_sellingمطلوبbooleanThe business's plan includes selling. Writing products needs it.

الاستجابات

  • 200The businesses, ordered by name.
  • 401The token is missing, malformed, unknown, expired or revoked, or is not a member token (unauthenticated). The answer is the same in every case.
  • 403The token lacks the operation's scope (insufficient_scope), its owner is suspended (account_suspended) or hasn't verified their email (email_unverified), or you are on the business team without the role to use its products (insufficient_role). A write is also refused when the business's plan doesn't include selling (plan_required) or its commission is overdue (commission_overdue).
  • 429The token owner's limit is reached, or a batch needs more units than are left (rate_limited). Nothing was written.
  • 503The platform is busy (overloaded), the scope is paused (scope_disabled), or under maintenance (unavailable).
GET/businesses/{business}/products

List a business's products

يتطلب الصلاحية products:read

Every product of the business, drafts and archived ones included, and the ones another system (a shop import, a file) manages. Pages walk in creation order, so an update never moves a product between pages. Send the same filters with each cursor.

المعاملات

الحقلالموضعالنوعالوصف
businessمطلوبpathstring (uuid)The business's id, from GET /businesses.
cursorquerystringThe next_cursor of the previous page.
limitqueryinteger
updated_sincequerystring (date-time)Only products changed at or after this time (RFC 3339 with an offset, such as 2026-11-01T00:00:00Z).
external_idquerystringOnly the product with this external_id, exactly as you sent it (URL-encode it).
statusqueryactive | draft | archivedactive is for sale (once the Souq lets it), draft is not yet, archived is taken down. The Souq has the last word on what a buyer sees: see awaiting_review.

جسم الاستجابة (200)

الحقلالنوعالوصف
dataمطلوبarray of objects
data[].idمطلوبstring (uuid)
data[].external_idمطلوبstring | nullYour product key. Null for a product that did not come from the API.
data[].managed_byمطلوبapi | shopify | woocommerce | csv | nullWhat owns the product's title, price, stock and photos, or null when the seller manages it in the dashboard. New values may be added.
data[].titleمطلوبstring
data[].descriptionمطلوبstring
data[].short_descriptionمطلوبstring | null
data[].brandمطلوبstring | null
data[].statusمطلوبactive | draft | archivedactive is for sale (once the Souq lets it), draft is not yet, archived is taken down. The Souq has the last word on what a buyer sees: see awaiting_review.
data[].currencyمطلوبstringISO 4217 code of every amount of the product.
data[].optionsمطلوبarray of string
data[].variantsمطلوبarray of objects
data[].variants[].idمطلوبstring | null (uuid)Null for the one variant of a product that has no options.
data[].variants[].external_idمطلوبstring | nullYour variant key. Null for the one variant of a product that has no options.
data[].variants[].option_valuesمطلوبarray of string
data[].variants[].skuمطلوبstring | null
data[].variants[].gtinمطلوبstring | null
data[].variants[].priceمطلوبinteger | nullWhat a buyer pays, in minor units of the product's currency.
data[].variants[].compare_at_priceمطلوبinteger | nullThe price it was before, when price is a sale price, in minor units.
data[].variants[].quantityمطلوبinteger | nullNull when stock is not counted.
data[].variants[].weight_gramsمطلوبinteger | null
data[].variants[].image_urlمطلوبstring | null (uri)
data[].imagesمطلوبarray of objects
data[].images[].urlمطلوبstring (uri)
data[].images[].altمطلوبstring | null
data[].product_category_idمطلوبstring | null (uuid)
data[].awaiting_reviewمطلوبbooleanThe product is active but waits for a moderator before buyers see it.
data[].warningsمطلوبarray of objects
data[].warnings[].fieldمطلوبstringDot path to the field, relative to the product (variants.0.gtin, images). Whole-call 422 errors use the full path (products.3.variants.0.gtin).
data[].warnings[].codeمطلوبstringStable. New values may be added, such as gtin_dropped, image_failed, image_budget, image_host or too_many_images.
data[].warnings[].messageمطلوبstring
data[].created_atمطلوبstring (date-time)
data[].updated_atمطلوبstring (date-time)
next_cursorمطلوبstring | nullNull on the last page.

الاستجابات

  • 200One page of products.
  • 401The token is missing, malformed, unknown, expired or revoked, or is not a member token (unauthenticated). The answer is the same in every case.
  • 403The token lacks the operation's scope (insufficient_scope), its owner is suspended (account_suspended) or hasn't verified their email (email_unverified), or you are on the business team without the role to use its products (insufficient_role). A write is also refused when the business's plan doesn't include selling (plan_required) or its commission is overdue (commission_overdue).
  • 404No such route or record (not_found). A business you have no role on, one your token is not bound to and one that does not exist look the same.
  • 422A field is invalid or unknown (validation_failed).
  • 429The token owner's limit is reached, or a batch needs more units than are left (rate_limited). Nothing was written.
  • 503The platform is busy (overloaded), the scope is paused (scope_disabled), or under maintenance (unavailable).
GET/businesses/{business}/products/{product}

Get one product

يتطلب الصلاحية products:read

المعاملات

الحقلالموضعالنوعالوصف
businessمطلوبpathstring (uuid)The business's id, from GET /businesses.
productمطلوبpathstring (uuid)The product's id.

جسم الاستجابة (200)

الحقلالنوعالوصف
idمطلوبstring (uuid)
external_idمطلوبstring | nullYour product key. Null for a product that did not come from the API.
managed_byمطلوبapi | shopify | woocommerce | csv | nullWhat owns the product's title, price, stock and photos, or null when the seller manages it in the dashboard. New values may be added.
titleمطلوبstring
descriptionمطلوبstring
short_descriptionمطلوبstring | null
brandمطلوبstring | null
statusمطلوبactive | draft | archivedactive is for sale (once the Souq lets it), draft is not yet, archived is taken down. The Souq has the last word on what a buyer sees: see awaiting_review.
currencyمطلوبstringISO 4217 code of every amount of the product.
optionsمطلوبarray of string
variantsمطلوبarray of objects
variants[].idمطلوبstring | null (uuid)Null for the one variant of a product that has no options.
variants[].external_idمطلوبstring | nullYour variant key. Null for the one variant of a product that has no options.
variants[].option_valuesمطلوبarray of string
variants[].skuمطلوبstring | null
variants[].gtinمطلوبstring | null
variants[].priceمطلوبinteger | nullWhat a buyer pays, in minor units of the product's currency.
variants[].compare_at_priceمطلوبinteger | nullThe price it was before, when price is a sale price, in minor units.
variants[].quantityمطلوبinteger | nullNull when stock is not counted.
variants[].weight_gramsمطلوبinteger | null
variants[].image_urlمطلوبstring | null (uri)
imagesمطلوبarray of objects
images[].urlمطلوبstring (uri)
images[].altمطلوبstring | null
product_category_idمطلوبstring | null (uuid)
awaiting_reviewمطلوبbooleanThe product is active but waits for a moderator before buyers see it.
warningsمطلوبarray of objects
warnings[].fieldمطلوبstringDot path to the field, relative to the product (variants.0.gtin, images). Whole-call 422 errors use the full path (products.3.variants.0.gtin).
warnings[].codeمطلوبstringStable. New values may be added, such as gtin_dropped, image_failed, image_budget, image_host or too_many_images.
warnings[].messageمطلوبstring
created_atمطلوبstring (date-time)
updated_atمطلوبstring (date-time)

الاستجابات

  • 200The product, with its variants, photos and warnings.
  • 401The token is missing, malformed, unknown, expired or revoked, or is not a member token (unauthenticated). The answer is the same in every case.
  • 403The token lacks the operation's scope (insufficient_scope), its owner is suspended (account_suspended) or hasn't verified their email (email_unverified), or you are on the business team without the role to use its products (insufficient_role). A write is also refused when the business's plan doesn't include selling (plan_required) or its commission is overdue (commission_overdue).
  • 404No such route or record (not_found). A business you have no role on, one your token is not bound to and one that does not exist look the same.
  • 429The token owner's limit is reached, or a batch needs more units than are left (rate_limited). Nothing was written.
  • 503The platform is busy (overloaded), the scope is paused (scope_disabled), or under maintenance (unavailable).
PUT/businesses/{business}/products/by-external-id/{external_id}

Create or replace one product by your key

يتطلب الصلاحية products:write

An upsert: the first send creates the product, later sends update it, and sending it again unchanged answers unchanged with the same product_id, so a retry is always safe. The key in the path wins; an external_id in the body, if sent, must be the same.

The product is written by the same importer as a shop sync: the Souq decides its status (a seller that is not yet enabled gets a draft; the first products of a new seller wait for review), and the fields you send are then managed by your API integration and locked in the dashboard until the seller unlinks the product. Photos are fetched after the answer: see images.

If the Souq refuses the product (for example a SKU that is taken) the answer is 422 with the reason in errors; nothing is written.

المعاملات

الحقلالموضعالنوعالوصف
businessمطلوبpathstring (uuid)The business's id, from GET /businesses.
external_idمطلوبpathstringYour own key for the product, 1 to 128 characters from A-Z a-z 0-9 : _ -. Keys are exact (case matters) and belong to the business. A key outside this pattern is not a route here: the answer is 404 (or 405) as a problem document. Send such a key through the batch route, where it is a body field.

جسم الطلب

الحقلالنوعالوصف
external_idstring | nullOptional here; if sent, the same as the key in the path.
titleمطلوبstring
descriptionstring | nullPlain text; HTML is not interpreted.
short_descriptionstring | nullOnly fills an empty field on the first send. It never overwrites what the seller wrote.
brandstring | null
statusمطلوبactive | draft | archivedWhat you say about the product. The Souq decides what a buyer sees: a seller that is not enabled gets drafts, and archived stays archived.
currencyمطلوبstringISO 4217. A currency the marketplace doesn't sell in fails that product with unsupported_currency.
product_category_idstring | null (uuid)A product subcategory. Only fills an empty field on the first send.
optionsarray of stringOption names, such as Size. A product has at most 3.
variantsمطلوبarray of objects1 to 100 versions (a plain product is one). Several versions are written only while the marketplace has them switched on (variants_not_enabled).
variants[].external_idمطلوبstringYour variant key, unique within the product.
variants[].option_valuesarray of stringOne value per option name of the product, in order.
variants[].skustring | nullUnique within the business.
variants[].gtinstring | nullA valid GTIN (8, 12, 13 or 14 digits). An invalid one is dropped with the warning gtin_dropped.
variants[].priceمطلوبintegerWhat a buyer pays, in minor units of the product's currency (cents; fils for JOD). For JOD it must be a multiple of 10 for now, or the product fails with precision_unsupported.
variants[].compare_at_priceinteger | nullThe price it was before, when price is a sale price.
variants[].quantityinteger | nullNull when you don't count stock; the variant is then always available.
variants[].weight_gramsinteger | null
variants[].image_urlstring | nullThe variant's photo, an https address. It is fetched like the product's photos.
imagesarray of objectsUp to 12 photos. A product with an uploaded video holds 11: the extra photo is dropped with the warning too_many_images.
images[].urlمطلوبstringA public https address on the standard port, without a user name. It is fetched after your call, by us, once per address (an address already copied is not fetched again) up to a daily budget.
images[].altstring | null

جسم الاستجابة (200)

الحقلالنوعالوصف
external_idمطلوبstring
outcomeمطلوبstringcreated, updated, linked (it adopted a product the business already had), unchanged, skipped (see reason) or failed (see errors). New values may be added; ignore what you don't know.
product_idمطلوبstring | null (uuid)Null when nothing was written.
statusمطلوبactive | draft | archived | null
awaiting_reviewمطلوبboolean
imagesمطلوبstring | nullpending while the photos are fetched after your call, done, none when the product has no photo, null when nothing was written. A photo that could not be copied is a warning on the product (GET), and is tried again the next time you send it.
missingمطلوبarray of stringWhat the seller still has to add in the dashboard, such as photo or category.
reasonمطلوبstring | nullFor skipped, excluded (the seller took the product back) or removed (they deleted it).
errorsمطلوبarray of objects
errors[].fieldمطلوبstring
errors[].codeمطلوبstringStable. invalid_field, sku_taken, too_many_options, too_many_variants, no_variants, variants_not_enabled, unsupported_currency, precision_unsupported, invalid_price, over_limit, ambiguous_match, managed_by_source. New values may be added.
errors[].messageمطلوبstring
warningsمطلوبarray of objects
warnings[].fieldمطلوبstringDot path to the field, relative to the product (variants.0.gtin, images). Whole-call 422 errors use the full path (products.3.variants.0.gtin).
warnings[].codeمطلوبstringStable. New values may be added, such as gtin_dropped, image_failed, image_budget, image_host or too_many_images.
warnings[].messageمطلوبstring

الاستجابات

  • 200What was done with the product: created, updated, linked (it adopted a product the business already had with that SKU or barcode), unchanged, or skipped (the seller excluded or deleted it).
  • 400The body is not valid JSON (malformed_json).
  • 401The token is missing, malformed, unknown, expired or revoked, or is not a member token (unauthenticated). The answer is the same in every case.
  • 403The token lacks the operation's scope (insufficient_scope), its owner is suspended (account_suspended) or hasn't verified their email (email_unverified), or you are on the business team without the role to use its products (insufficient_role). A write is also refused when the business's plan doesn't include selling (plan_required) or its commission is overdue (commission_overdue).
  • 404No such route or record (not_found). A business you have no role on, one your token is not bound to and one that does not exist look the same.
  • 409Another write to this business's products is still running (import_in_progress). Nothing was written; send it again after Retry-After.
  • 413The body is larger than the route allows, 64 KB or 1 MB on the product write routes (payload_too_large).
  • 415The body is not application/json (unsupported_media_type).
  • 422A field is invalid or unknown (validation_failed).
  • 429The token owner's limit is reached, or a batch needs more units than are left (rate_limited). Nothing was written.
  • 503The platform is busy (overloaded), the scope is paused (scope_disabled), or under maintenance (unavailable).
POST/businesses/{business}/products/batch

Create or replace up to 100 products

يتطلب الصلاحية products:write

The same upsert as the single route, for 1 to 100 products and at most 1,000 variants in one call. Every product is written on its own: one that fails never undoes another. The answer is 200 with one result per product in the order you sent them, and a summary, even when every product failed; read the results.

A call that cannot be read (bad JSON types, an unknown field, a key sent twice, too many products) is a 422 for the whole call and nothing is written. Each product costs one unit of the daily limit, and a batch needs all its units left: otherwise it is refused whole with 429 before anything is written.

المعاملات

الحقلالموضعالنوعالوصف
businessمطلوبpathstring (uuid)The business's id, from GET /businesses.

جسم الطلب

الحقلالنوعالوصف
productsمطلوبarray of objects
products[].external_idمطلوبstring | nullOptional here; if sent, the same as the key in the path.
products[].titleمطلوبstring
products[].descriptionstring | nullPlain text; HTML is not interpreted.
products[].short_descriptionstring | nullOnly fills an empty field on the first send. It never overwrites what the seller wrote.
products[].brandstring | null
products[].statusمطلوبactive | draft | archivedWhat you say about the product. The Souq decides what a buyer sees: a seller that is not enabled gets drafts, and archived stays archived.
products[].currencyمطلوبstringISO 4217. A currency the marketplace doesn't sell in fails that product with unsupported_currency.
products[].product_category_idstring | null (uuid)A product subcategory. Only fills an empty field on the first send.
products[].optionsarray of stringOption names, such as Size. A product has at most 3.
products[].variantsمطلوبarray of objects1 to 100 versions (a plain product is one). Several versions are written only while the marketplace has them switched on (variants_not_enabled).
products[].variants[].external_idمطلوبstringYour variant key, unique within the product.
products[].variants[].option_valuesarray of stringOne value per option name of the product, in order.
products[].variants[].skustring | nullUnique within the business.
products[].variants[].gtinstring | nullA valid GTIN (8, 12, 13 or 14 digits). An invalid one is dropped with the warning gtin_dropped.
products[].variants[].priceمطلوبintegerWhat a buyer pays, in minor units of the product's currency (cents; fils for JOD). For JOD it must be a multiple of 10 for now, or the product fails with precision_unsupported.
products[].variants[].compare_at_priceinteger | nullThe price it was before, when price is a sale price.
products[].variants[].quantityinteger | nullNull when you don't count stock; the variant is then always available.
products[].variants[].weight_gramsinteger | null
products[].variants[].image_urlstring | nullThe variant's photo, an https address. It is fetched like the product's photos.
products[].imagesarray of objectsUp to 12 photos. A product with an uploaded video holds 11: the extra photo is dropped with the warning too_many_images.
products[].images[].urlمطلوبstringA public https address on the standard port, without a user name. It is fetched after your call, by us, once per address (an address already copied is not fetched again) up to a daily budget.
products[].images[].altstring | null

جسم الاستجابة (200)

الحقلالنوعالوصف
resultsمطلوبarray of objects
results[].external_idمطلوبstring
results[].outcomeمطلوبstringcreated, updated, linked (it adopted a product the business already had), unchanged, skipped (see reason) or failed (see errors). New values may be added; ignore what you don't know.
results[].product_idمطلوبstring | null (uuid)Null when nothing was written.
results[].statusمطلوبactive | draft | archived | null
results[].awaiting_reviewمطلوبboolean
results[].imagesمطلوبstring | nullpending while the photos are fetched after your call, done, none when the product has no photo, null when nothing was written. A photo that could not be copied is a warning on the product (GET), and is tried again the next time you send it.
results[].missingمطلوبarray of stringWhat the seller still has to add in the dashboard, such as photo or category.
results[].reasonمطلوبstring | nullFor skipped, excluded (the seller took the product back) or removed (they deleted it).
results[].errorsمطلوبarray of objects
results[].errors[].fieldمطلوبstring
results[].errors[].codeمطلوبstringStable. invalid_field, sku_taken, too_many_options, too_many_variants, no_variants, variants_not_enabled, unsupported_currency, precision_unsupported, invalid_price, over_limit, ambiguous_match, managed_by_source. New values may be added.
results[].errors[].messageمطلوبstring
results[].warningsمطلوبarray of objects
results[].warnings[].fieldمطلوبstringDot path to the field, relative to the product (variants.0.gtin, images). Whole-call 422 errors use the full path (products.3.variants.0.gtin).
results[].warnings[].codeمطلوبstringStable. New values may be added, such as gtin_dropped, image_failed, image_budget, image_host or too_many_images.
results[].warnings[].messageمطلوبstring
summaryمطلوبobjectHow many products ended each way. New outcomes may be added.

الاستجابات

  • 200One result per product, in request order.
  • 400The body is not valid JSON (malformed_json).
  • 401The token is missing, malformed, unknown, expired or revoked, or is not a member token (unauthenticated). The answer is the same in every case.
  • 403The token lacks the operation's scope (insufficient_scope), its owner is suspended (account_suspended) or hasn't verified their email (email_unverified), or you are on the business team without the role to use its products (insufficient_role). A write is also refused when the business's plan doesn't include selling (plan_required) or its commission is overdue (commission_overdue).
  • 404No such route or record (not_found). A business you have no role on, one your token is not bound to and one that does not exist look the same.
  • 409Another write to this business's products is still running (import_in_progress). Nothing was written; send it again after Retry-After.
  • 413The body is larger than the route allows, 64 KB or 1 MB on the product write routes (payload_too_large).
  • 415The body is not application/json (unsupported_media_type).
  • 422A field is invalid or unknown (validation_failed).
  • 429The token owner's limit is reached, or a batch needs more units than are left (rate_limited). Nothing was written.
  • 503The platform is busy (overloaded), the scope is paused (scope_disabled), or under maintenance (unavailable).

سجل التغييرات

كل تغيير في الواجهة، الأحدث أولاً. تُعلَن الإزالات هنا قبل أن تحدث.

الإصدار 1 (بيتا)

1.0.0-beta
  • قراءة أعمالك التجارية: GET /businesses.
  • قراءة منتجات عمل تجاري، صفحة صفحة أو واحداً واحداً: GET /businesses/{business}/products وGET /businesses/{business}/products/{product}.
  • إنشاء منتج واحد أو استبداله بمفتاحك: PUT /businesses/{business}/products/by-external-id/{external_id}.
  • إنشاء ما يصل إلى 100 منتج أو استبدالها في طلب واحد: POST /businesses/{business}/products/batch.
  • الصور بعنوان https تُجلب بعد الطلب. حدود الاستخدام بالطلبات في الدقيقة والوحدات في اليوم.