# إنشاء وتحديث

تقوم نقاط النهاية هذه بإنشاء وتعديل تعريف الرحلة: عنوانها، وإعداداتها، والنقاط على لوحة الرسم. هي لا تبدأ الرحلة. استخدم [دورة الحياة](/ar/developer/api-reference/customer-journey-api/lifecycle/) لذلك.

كلاهما يقبل ويعيد [كائن الرحلة](/ar/developer/api-reference/customer-journey-api/journey-object/).

<Aside type="tip">
كتابة رسم بياني كامل للرحلة في JSON أمر صعب. كل نقطة لها حقول وشروط القناة الخاصة بها ([مرجع النقطة](/ar/developer/api-reference/customer-journey-api/point-reference/)). سير العمل الأكثر موثوقية هو بناء الرحلة مرة واحدة في [منشئ رحلة العميل](/ar/product/customer-journey/pushwoosh-journey-overview/)، وقراءتها مرة أخرى من استجابة إنشاء/تحديث، ثم استخدام نقاط النهاية هذه لنسخها أو تعديلها برمجيًا.
</Aside>

## إنشاء

`POST` `https://journey.pushwoosh.com/api/v3/journeygateway`

ينشئ رحلة جديدة في حالة `STATUS_DRAFT`.

### الطلب

| الحقل | مطلوب | النوع | الوصف |
|---|---|---|---|
| `title` | نعم | string | اسم الرحلة. |
| `params` | نعم | [`JourneyParams`](/ar/developer/api-reference/customer-journey-api/journey-object/#journeyparams) | التكوين على مستوى الرحلة. `params.application_code` مطلوب. |
| `points` | لا | array of [`Point`](/ar/developer/api-reference/customer-journey-api/journey-object/#point) | عناصر الرحلة على لوحة الرسم واتصالاتها. |
| `comments` | لا | array of [`JourneyComment`](/ar/developer/api-reference/customer-journey-api/journey-object/#journeycomment) | تعليقات لوحة الرسم. |

##### مثال على الطلب
```bash title="إنشاء رحلة"
curl -X POST https://journey.pushwoosh.com/api/v3/journeygateway \
  -H "Authorization: Api YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Welcome series",
    "params": { "application_code": "XXXXX-XXXXX" },
    "points": [],
    "comments": []
  }'
```

### الاستجابة

يعيد [كائن الرحلة](/ar/developer/api-reference/customer-journey-api/journey-object/) الجديد. اقرأ UUID الخاص بالرحلة من `info.uuid` واستخدمه في استدعاءات التحديث ودورة الحياة اللاحقة.
##### مثال على الاستجابة
```json
{
  "info": {
    "uuid": "11111111-2222-3333-4444-555555555555",
    "title": "Welcome series",
    "status": "STATUS_DRAFT",
    "params": { "application_code": "XXXXX-XXXXX" }
  },
  "points": [],
  "comments": []
}
```

## مثال على رحلة كاملة

نص `Create` كامل لتدفق ترحيبي صغير. الرسم البياني هو:

```
Start by segment ──default──▶ Send push ──default──▶ Wait 1 day ──default──▶ Boolean splitter ──output1──▶ Send email ──default──▶ Exit
                                                                                              └──default───────────────────────────▶ Exit
```

يتم ربط النقاط ببعضها البعض من خلال `info.next_point_uuid` لكل مخرج. لاحظ [مفاتيح المخرجات](/ar/developer/api-reference/customer-journey-api/journey-object/#output-keys): كل نقطة تستخدم `default`، باستثناء الفاصل المنطقي، الذي يضيف `output1` لفرع الشرط المطابق (`default` هو احتياطيه). نقطة الخروج ليس لها مخرجات.

```json
{
  "title": "Welcome series",
  "params": {
    "application_code": "XXXXX-XXXXX",
    "user_id_track_change_policy": "TRACK"
  },
  "points": [
    {
      "uuid": "11111111-1111-1111-1111-111111111111",
      "title": "New signups",
      "point_type": "POINT_TYPE_START_BY_SEGMENT",
      "position": { "x": 80, "y": 200 },
      "outputs": [
        { "identity": { "key": "default", "order": 0 },
          "info": { "title": "", "next_point_uuid": "22222222-2222-2222-2222-222222222222" } }
      ],
      "point_data": {
        "start_by_segment": {
          "application_code": "XXXXX-XXXXX",
          "filter_code": "AAAAA-BBBBB"
        }
      }
    },
    {
      "uuid": "22222222-2222-2222-2222-222222222222",
      "title": "Welcome push",
      "point_type": "POINT_TYPE_SEND_PUSH",
      "position": { "x": 340, "y": 200 },
      "outputs": [
        { "identity": { "key": "default", "order": 0 },
          "info": { "title": "", "next_point_uuid": "33333333-3333-3333-3333-333333333333" } }
      ],
      "point_data": {
        "send_push": {
          "application_code": "XXXXX-XXXXX",
          "title": "Welcome!",
          "content": "Thanks for joining — here's how to get started."
        }
      }
    },
    {
      "uuid": "33333333-3333-3333-3333-333333333333",
      "title": "Wait 1 day",
      "point_type": "POINT_TYPE_WAIT",
      "position": { "x": 600, "y": 200 },
      "outputs": [
        { "identity": { "key": "default", "order": 0 },
          "info": { "title": "", "next_point_uuid": "44444444-4444-4444-4444-444444444444" } }
      ],
      "point_data": {
        "delay": { "sec": 86400 }
      }
    },
    {
      "uuid": "44444444-4444-4444-4444-444444444444",
      "title": "Opened the push?",
      "point_type": "POINT_TYPE_BOOLEAN_SPLITTER",
      "position": { "x": 860, "y": 200 },
      "outputs": [
        { "identity": { "key": "output1", "order": 1 },
          "info": { "title": "Matched", "next_point_uuid": "55555555-5555-5555-5555-555555555555" } },
        { "identity": { "key": "default", "order": 0 },
          "info": { "title": "Everyone else", "next_point_uuid": "66666666-6666-6666-6666-666666666666" } }
      ],
      "point_data": {
        "boolean_splitter": {
          "application_code": "XXXXX-XXXXX",
          "split_strategy": "SPLIT_FILTER",
          "load_policy": "ALL",
          "filter_code": "CCCCC-DDDDD"
        }
      }
    },
    {
      "uuid": "55555555-5555-5555-5555-555555555555",
      "title": "Follow-up email",
      "point_type": "POINT_TYPE_SEND_EMAIL",
      "position": { "x": 1120, "y": 120 },
      "outputs": [
        { "identity": { "key": "default", "order": 0 },
          "info": { "title": "", "next_point_uuid": "66666666-6666-6666-6666-666666666666" } }
      ],
      "point_data": {
        "send_email": {
          "application_code": "XXXXX-XXXXX",
          "preset_code": "12345-67890"
        }
      }
    },
    {
      "uuid": "66666666-6666-6666-6666-666666666666",
      "title": "Exit",
      "point_type": "POINT_TYPE_EXIT",
      "position": { "x": 1380, "y": 200 },
      "outputs": [],
      "point_data": {
        "terminator": {}
      }
    }
  ],
  "comments": []
}
```

## تحديث

`PUT` `https://journey.pushwoosh.com/api/v3/journeygateway/{uuid}`

يستبدل تعريف رحلة موجودة. أرسل التعريف **الكامل**. النقاط والتعليقات التي ترسلها تحل محل الحالية.

### معاملات المسار

| الاسم | النوع | الوصف |
|---|---|---|
| `uuid` | string | [معرف الرحلة](/ar/developer/api-reference/api-identifiers/#journey-id) للتحديث. |

### الطلب

| الحقل | النوع | الوصف |
|---|---|---|
| `title` | string | اسم الرحلة الجديد. |
| `params` | [`JourneyParams`](/ar/developer/api-reference/customer-journey-api/journey-object/#journeyparams) | التكوين الجديد على مستوى الرحلة. |
| `points` | array of [`Point`](/ar/developer/api-reference/customer-journey-api/journey-object/#point) | المجموعة الكاملة الجديدة من النقاط. |
| `comments` | array of [`JourneyComment`](/ar/developer/api-reference/customer-journey-api/journey-object/#journeycomment) | المجموعة الكاملة الجديدة من التعليقات. |
| `autosave` | bool | عندما تكون `true`، يتم التعامل مع التغيير كحفظ تلقائي للمحرر. القيمة الافتراضية هي `false`. |

##### مثال على الطلب 

```bash title="إعادة تسمية رحلة وإعادة تكوينها"
curl -X PUT https://journey.pushwoosh.com/api/v3/journeygateway/11111111-2222-3333-4444-555555555555 \
  -H "Authorization: Api YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Welcome series v2",
    "params": { "application_code": "XXXXX-XXXXX" },
    "points": [],
    "comments": []
  }'
```

### الاستجابة

يعيد [كائن الرحلة](/ar/developer/api-reference/customer-journey-api/journey-object/) المحدث.

## تحديث واستئناف

`POST` `https://journey.pushwoosh.com/api/v3/journeygateway/{uuid}/resume`

يطبق التعديلات على رحلة ويستأنفها في استدعاء واحد. هذا يعادل [تحديث](#update) متبوعًا بـ [بدء](/ar/developer/api-reference/customer-journey-api/lifecycle/) دورة الحياة. يتطابق نص الطلب مع [تحديث](#update). استخدم هذا عند تعديل رحلة متوقفة مؤقتًا تريد إعادتها إلى حالة `STATUS_RUNNING`.

## إعادة تسمية

`POST` `https://journey.pushwoosh.com/api/v3/journeygateway/{uuid}/rename`

يغير عنوان الرحلة فقط، دون المساس بنقاطها أو إعداداتها.

| الحقل | مطلوب | النوع | الوصف |
|---|---|---|---|
| `title` | نعم | string | اسم الرحلة الجديد. |

##### مثال على الطلب

```bash title="إعادة تسمية رحلة"
curl -X POST https://journey.pushwoosh.com/api/v3/journeygateway/11111111-2222-3333-4444-555555555555/rename \
  -H "Authorization: Api YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "title": "Welcome series (Q3)" }'
```

## ذات صلة

<CardGrid>
  <LinkCard title="كائن الرحلة" href="/developer/api-reference/customer-journey-api/journey-object/" />
  <LinkCard title="دورة الحياة" href="/developer/api-reference/customer-journey-api/lifecycle/" />
  <LinkCard title="البدء عبر API" href="/developer/api-reference/customer-journey-api/start-by-api/" />
</CardGrid>