# 생성 및 업데이트

이 엔드포인트들은 Journey 정의, 즉 제목, 설정, 캔버스 위의 포인트를 생성하고 편집합니다. Journey를 시작하지는 않습니다. Journey를 시작하려면 [Lifecycle](/ko/developer/api-reference/customer-journey-api/lifecycle/)을 사용하세요.

두 엔드포인트 모두 [Journey 객체](/ko/developer/api-reference/customer-journey-api/journey-object/)를 수락하고 반환합니다.

<Aside type="tip">
JSON으로 전체 Journey 그래프를 작성하는 것은 어렵습니다. 각 포인트에는 자체 채널 필드와 조건이 있습니다([포인트 참조](/ko/developer/api-reference/customer-journey-api/point-reference/)). 가장 신뢰할 수 있는 워크플로는 [Customer Journey 빌더](/ko/product/customer-journey/pushwoosh-journey-overview/)에서 Journey를 한 번 빌드하고, 생성/업데이트 응답에서 다시 읽어온 다음, 이 엔드포인트를 사용하여 프로그래밍 방식으로 복제하거나 조정하는 것입니다.
</Aside>

## 생성

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

새로운 Journey를 `STATUS_DRAFT` 상태로 생성합니다.

### 요청

| 필드 | 필수 | 타입 | 설명 |
|---|---|---|---|
| `title` | 예 | string | Journey 이름. |
| `params` | 예 | [`JourneyParams`](/ko/developer/api-reference/customer-journey-api/journey-object/#journeyparams) | Journey 전체 구성. `params.application_code`는 필수입니다. |
| `points` | 아니요 | [`Point`](/ko/developer/api-reference/customer-journey-api/journey-object/#point)의 배열 | 캔버스 위의 Journey 요소와 그 연결. |
| `comments` | 아니요 | [`JourneyComment`](/ko/developer/api-reference/customer-journey-api/journey-object/#journeycomment)의 배열 | 캔버스 주석. |

##### 요청 예시
```bash title="Journey 생성"
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": []
  }'
```

### 응답

새로운 [Journey 객체](/ko/developer/api-reference/customer-journey-api/journey-object/)를 반환합니다. `info.uuid`에서 Journey의 UUID를 읽어와서 후속 업데이트 및 라이프사이클 호출에 사용하세요.
##### 응답 예시
```json
{
  "info": {
    "uuid": "11111111-2222-3333-4444-555555555555",
    "title": "Welcome series",
    "status": "STATUS_DRAFT",
    "params": { "application_code": "XXXXX-XXXXX" }
  },
  "points": [],
  "comments": []
}
```

## 전체 Journey 예시

작은 환영 플로우를 위한 완전한 `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`를 통해 함께 연결됩니다. [출력 키](/ko/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}`

기존 Journey의 정의를 교체합니다. **완전한** 정의를 보내야 합니다. 제출하는 포인트와 주석이 현재의 것을 대체합니다.

### 경로 파라미터

| 이름 | 타입 | 설명 |
|---|---|---|
| `uuid` | string | 업데이트할 [Journey ID](/ko/developer/api-reference/api-identifiers/#journey-id). |

### 요청

| 필드 | 타입 | 설명 |
|---|---|---|
| `title` | string | 새 Journey 이름. |
| `params` | [`JourneyParams`](/ko/developer/api-reference/customer-journey-api/journey-object/#journeyparams) | 새 Journey 전체 구성. |
| `points` | [`Point`](/ko/developer/api-reference/customer-journey-api/journey-object/#point)의 배열 | 새로운 전체 포인트 세트. |
| `comments` | [`JourneyComment`](/ko/developer/api-reference/customer-journey-api/journey-object/#journeycomment)의 배열 | 새로운 전체 주석 세트. |
| `autosave` | bool | `true`일 경우, 변경 사항이 에디터 자동 저장으로 처리됩니다. 기본값은 `false`입니다. |

##### 요청 예시 

```bash title="Journey 이름 변경 및 재구성"
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": []
  }'
```

### 응답

업데이트된 [Journey 객체](/ko/developer/api-reference/customer-journey-api/journey-object/)를 반환합니다.

## 업데이트 및 재개

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

한 번의 호출로 Journey에 편집 내용을 적용하고 재개합니다. 이는 [업데이트](#update) 후 라이프사이클 [시작](/ko/developer/api-reference/customer-journey-api/lifecycle/)을 호출하는 것과 같습니다. 요청 본문은 [업데이트](#update)와 동일합니다. 일시 중지된 Journey를 다시 `STATUS_RUNNING` 상태로 되돌리고 싶을 때 사용하세요.

## 이름 변경

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

포인트나 설정을 건드리지 않고 Journey 제목만 변경합니다.

| 필드 | 필수 | 타입 | 설명 |
|---|---|---|---|
| `title` | 예 | string | 새 Journey 이름. |

##### 요청 예시

```bash title="Journey 이름 변경"
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="Journey 객체" href="/developer/api-reference/customer-journey-api/journey-object/" />
  <LinkCard title="Lifecycle" href="/developer/api-reference/customer-journey-api/lifecycle/" />
  <LinkCard title="API로 시작" href="/developer/api-reference/customer-journey-api/start-by-api/" />
</CardGrid>