# 알림톡 전송

## 1. SendATS - 단건전송

승인된 템플릿의 내용을 작성하여 1건의 알림톡 전송을 팝빌에 접수합니다.

- 전송실패시 사전에 지정한 변수 ‘Altsendtype’ 값으로 대체문자를 전송할 수 있고, 이 경우 문자(SMS/LMS) 요금이 과금됩니다.
- 승인된 템플릿과 일치하지 않는 내용(알림톡 내용, 버튼 목록)을 입력하는 경우 ‘전송실패’ 처리됩니다.
- 팝빌 서비스의 안정적인 제공을 위하여 동시호출이 제한될 수 있습니다.\
  동시에 1,000건 이상 요청하는 경우 동보전송 또는 대량전송으로 이용하시는 것을 권장합니다.

```pascal
function SendATS(CorpNum : String; TemplateCode : String; SenderNum : String; Altsendtype : String; ReserveDT: String; ReceiverNum : String; ReceiverName : String; ATSMsg : String; ATSAltSjt : String ; ATSAltMsg : String; Buttons : TSendKakaoButtonList; UserID : String = ''; requestNum : String = '') : String;
```

### 요청

**Parameters**

- CorpNum `type: String` `length: 10` `required: Y` `description: 팝빌회원 사업자번호 ('-' 제외)`
- TemplateCode `type: String` `length: 12` `required: Y` `description: 승인된 알림톡 템플릿 코드`
- SenderNum `type: String` `length: 20` `required: 조건부` `description: 발신번호`
  - 대체문자 전송시 필수
  - 팝빌에 등록되지 않은 발신번호를 입력하는 경우 오류 반환
- Altsendtype `type: String` `length: 1` `required: N` `description: 대체문자 유형`
  - `C`: 알림톡 내용 전송
  - `A`: 대체문자 내용 전송
  - 기본값 : 미전송
- ReserveDT `type: String` `length: 14` `required: N` `description: 전송 예약일시`
  - 형식 : yyyyMMddHHmmss
  - 기본값 : 즉시전송
- ReceiverNum `type: String` `length: 20` `required: Y` `description: 수신번호`
- ReceiverName `type: String` `length: 70` `required: N` `description: 수신자명`
- ATSMsg `type: String` `length: 1,300` `required: Y` `description: 알림톡 내용 (템플릿 내용의 변수 치환 필요)`
  - 템플릿 예시 : 주문하신 #{상품}이 금일 발송 처리되었습니다.
  - 작성 예시 : 주문하신 노트북이 금일 발송 처리되었습니다.
- ATSAltSjt `type: String` `length: 64` `required: N` `description: 대체문자 제목`
  - 대체문자 내용이 90byte 초과한 경우에만 적용
  - 단위 : byte
- ATSAltMsg `type: String` `length: 2,000` `required: N` `description: 대체문자 내용`
  - 메시지 길이에 따라 단문(90byte 이하) 또는 장문(90byte 초과)으로 전송
  - 단위 : byte
- Buttons `type: TSendKakaoButtonList` `length: 5` `required: N` `description: 버튼 목록`
  - 버튼링크를 변경해야할 경우 사용
  - 최대 : 5개
  - 기본값 : 승인된 템플릿의 버튼 목록
  - buttonName `type: String` `length: 14` `required: Y` `description: 버튼명`
  - buttonType `type: String` `length: 2` `required: Y` `description: 버튼유형`
    - `WL`: 웹링크
    - `AL`: 앱링크
    - `DS`: 배송조회
    - `MD`: 메시지전달
    - `BK`: 봇키워드
    - `AC`: 채널추가
  - buttonURL1 `type: String` `length: 1,000` `required: 조건부` `description: 버튼링크`
    - {buttonType} = "AL" 경우 iOS 앱링크 적용
    - {buttonType} = "WL" 경우 Mobile 웹링크 적용
    - {buttonType} = "WL" or "AL" 경우 필수
  - buttonURL2 `type: String` `length: 1,000` `required: 조건부` `description: 버튼링크`
    - {buttonType} = "AL" 경우 Android 앱링크 적용
    - {buttonType} = "WL" 경우 PC 웹링크 적용
    - {buttonType} = "WL" or "AL" 경우 필수
  - buttonTG `type: String` `length: 3` `required: N` `description: 아웃 링크`
    - `out`: 디바이스 기본 브라우저
    - 기본값 : 카카오톡 인앱 브라우저 사용
- UserID `type: String` `length: 50` `required: N` `description: 팝빌회원 아이디`
- requestNum `type: String` `length: 36` `required: N` `description: 요청번호`
  - 파트너가 접수 단위를 식별하기 위해 할당하는 관리번호
  - 영문 대소문자, 숫자, 특수문자('-','\_')만 이용 가능

### 응답

String - 요청에 대한 접수번호(receiptNum)

### 예외

**EPopbillException**

- code `type: LongInt` `length: -` `description: API 처리 실패에 대한 오류코드`
  - 음의 정수 8자리 숫자값 [\[참고\] 오류코드](https://developers.popbill.com/error-code)
- message `type: String` `length: -` `description: API 처리 실패에 대한 오류메시지`

## 2. SendATS - 동보전송/대량전송

승인된 템플릿 내용을 작성하여 다수건의 알림톡 전송을 팝빌에 접수합니다.

- 모든 수신자에게 동일한 내용을 전송하거나(동보전송), 수신자마다 개별 내용을 전송할 수 있습니다(대량전송). (최대 1,000건)
- 전송실패시 사전에 지정한 변수 ‘Altsendtype’ 값으로 대체문자를 전송할 수 있고, 이 경우 문자(SMS/LMS) 요금이 과금됩니다.
- 승인된 템플릿과 일치하지 않는 내용(알림톡 내용, 버튼 목록)을 입력하는 경우 ‘전송실패’ 처리됩니다.

```pascal
function SendATS(CorpNum : String; TemplateCode : String; SenderNum : String; Content : String; AltSubject : String; AltContent : String; Altsendtype : String; ReserveDT : String; Receivers : TSendKakaoReceiverList; Buttons : TSendKakaoButtonList; UserID : String = ''; requestNum : String = '') : String;
```

### 요청

**Parameters**

- CorpNum `type: String` `length: 10` `required: Y` `description: 팝빌회원 사업자번호 ('-' 제외)`
- TemplateCode `type: String` `length: 12` `required: Y` `description: 승인된 알림톡 템플릿 코드`
- SenderNum `type: String` `length: 20` `required: 조건부` `description: 발신번호`
  - 대체문자 전송시 필수
  - 팝빌에 등록되지 않은 발신번호를 입력하는 경우 오류 반환
- Content `type: String` `length: 1000` `required: 조건부` `description: 알림톡 내용 (템플릿 내용의 변수 치환 필요)`
  - 동보전송 경우 필수
  - 템플릿 예시 : 주문하신 #{상품}이 금일 발송 처리되었습니다.
  - 작성 예시 : 주문하신 노트북이 금일 발송 처리되었습니다.
- AltSubject `type: String` `length: 64` `required: N` `description: 대체문자 제목`
  - 동보전송 경우 사용
  - 메시지 길이가 90byte 초과한 경우에만 적용
  - 단위 : byte
- AltContent `type: String` `length: 2000` `required: N` `description: 대체문자 내용`
  - 동보전송 경우 사용
  - 메시지 길이에 따라 단문(90byte 이하) 또는 장문(90byte 초과)으로 전송
  - 단위 : byte
- Altsendtype `type: String` `length: 1` `required: N` `description: 대체문자 유형`
  - `C`: 알림톡 내용 전송
  - `A`: 대체문자 내용 전송
  - 기본값 : 미전송
- ReserveDT `type: String` `length: 14` `required: N` `description: 전송 예약일시`
  - 형식 : yyyyMMddHHmmss
  - 기본값 : 즉시전송
- Receivers `type: TSendKakaoReceiverList` `length: 1,000` `required: Y` `description: 전송정보`
  - rcv `type: String` `length: 20` `required: Y` `description: 수신번호`
  - rcvnm `type: String` `length: 70` `required: N` `description: 수신자명`
  - msg `type: String` `length: 1,300` `required: 조건부` `description: 알림톡 내용 (템플릿 내용의 변수 치환 필요)`
    - 대량전송 경우 필수
    - 템플릿 예시 : 주문하신 #{상품}이 금일 발송 처리되었습니다.
    - 작성 예시 : 주문하신 노트북이 금일 발송 처리되었습니다.
  - altsjt `type: String` `length: 64` `required: N` `description: 대체문자 제목`
    - 대량전송 경우 사용
    - 메시지 길이가 90byte 초과한 경우에만 적용
    - 단위 : byte
  - altmsg `type: String` `length: 2,000` `required: N` `description: 대체문자 내용`
    - 대량전송 경우 사용
    - 단위 : byte
  - buttonList `type: TSendKakaoButtonList` `length: 5` `required: N` `description: 버튼 목록`
    - 대량전송 경우 사용
    - buttonName `type: String` `length: 14` `required: Y` `description: 버튼명`
    - buttonType `type: String` `length: 2` `required: Y` `description: 버튼유형`
      - `WL`: 웹링크
      - `AL`: 앱링크
      - `DS`: 배송조회
      - `MD`: 메시지전달
      - `BK`: 봇키워드
      - `AC`: 채널추가
    - buttonURL1 `type: String` `length: 1,000` `required: 조건부` `description: 버튼링크`
      - {buttonType} = "AL" 경우 iOS 앱링크 적용
      - {buttonType} = "WL" 경우 Mobile 웹링크 적용
      - {buttonType} = "WL" or "AL" 경우 필수
    - buttonURL2 `type: String` `length: 1,000` `required: 조건부` `description: 버튼링크`
      - {buttonType} = "AL" 경우 Android 앱링크 적용
      - {buttonType} = "WL" 경우 PC 웹링크 적용
      - {buttonType} = "WL" or "AL" 경우 필수
    - buttonTG `type: String` `length: 3` `required: N` `description: 아웃 링크`
      - `out`: 디바이스 기본 브라우저
      - 기본값 : 카카오톡 인앱 브라우저 사용
  - interOPRefKey `type: String` `length: 20` `required: N` `description: 파트너 지정키`
    - 카카오톡 대량/동보전송시 파트너가 개별건마다 입력할 수 있는 값
- Buttons `type: TSendKakaoButtonList` `length: 5` `required: N` `description: 버튼 목록`
  - 동보전송 경우 사용
  - 버튼링크를 변경해야할 경우 사용
  - 기본값 : 승인된 템플릿의 버튼 목록
  - buttonName `type: String` `length: 14` `required: Y` `description: 버튼명`
  - buttonType `type: String` `length: 2` `required: Y` `description: 버튼유형`
    - `WL`: 웹링크
    - `AL`: 앱링크
    - `DS`: 배송조회
    - `MD`: 메시지전달
    - `BK`: 봇키워드
    - `AC`: 채널추가
  - buttonURL1 `type: String` `length: 1,000` `required: 조건부` `description: 버튼링크`
    - {buttonType} = "AL" 경우 iOS 앱링크 적용
    - {buttonType} = "WL" 경우 Mobile 웹링크 적용
    - {buttonType} = "WL" or "AL" 경우 필수
  - buttonURL2 `type: String` `length: 1,000` `required: 조건부` `description: 버튼링크`
    - {buttonType} = "AL" 경우 Android 앱링크 적용
    - {buttonType} = "WL" 경우 PC 웹링크 적용
    - {buttonType} = "WL" or "AL" 경우 필수
  - buttonTG `type: String` `length: 3` `required: N` `description: 아웃 링크`
    - `out`: 디바이스 기본 브라우저
    - 기본값 : 카카오톡 인앱 브라우저 사용
- UserID `type: String` `length: 50` `required: N` `description: 팝빌회원 아이디`
- requestNum `type: String` `length: 36` `required: N` `description: 요청번호`
  - 파트너가 접수 단위를 식별하기 위해 할당하는 관리번호
  - 영문 대소문자, 숫자, 특수문자('-','\_')만 이용 가능

### 응답

String - 요청에 대한 접수번호(receiptNum)

### 예외

**EPopbillException**

- code `type: LongInt` `length: -` `description: API 처리 실패에 대한 오류코드`
  - 음의 정수 8자리 숫자값 [\[참고\] 오류코드](https://developers.popbill.com/error-code)
- message `type: String` `length: -` `description: API 처리 실패에 대한 오류메시지`

## 3. CancelReserve - 예약전송 취소 (접수번호)

팝빌에서 반환받은 접수번호로 예약된 카카오톡을 전송 취소합니다. (예약시간 10분 전까지 가능)

```pascal
function CancelReserve(CorpNum : String; receiptNum : String; UserID : String = '') : TResponse;
```

### 요청

**Parameters**

- CorpNum `type: String` `length: 10` `required: Y` `description: 팝빌회원 사업자번호 ('-' 제외)`
- receiptNum `type: String` `length: 18` `required: Y` `description: 팝빌에서 할당한 접수번호`
  - 카카오톡 예약전송 요청의 반환값
- UserID `type: String` `length: 50` `required: N` `description: 팝빌회원 아이디`

### 응답

**TResponse**

- code `type: LongInt` `length: -` `description: API 처리에 대한 응답코드`
  - `1`: 성공
- message `type: String` `length: -` `description: API 처리에 대한 응답메시지`

### 예외

**EPopbillException**

- code `type: LongInt` `length: -` `description: API 처리 실패에 대한 오류코드`
  - 음의 정수 8자리 숫자값 [\[참고\] 오류코드](https://developers.popbill.com/error-code)
- message `type: String` `length: -` `description: API 처리 실패에 대한 오류메시지`

## 4. CancelReserveRN - 예약전송 취소 (요청번호)

파트너가 할당한 요청번호로 예약된 카카오톡을 전송 취소합니다. (예약시간 10분 전까지 가능)

```pascal
function CancelReserveRN(CorpNum : String; requestNum : String; UserID : String = '') : TResponse;
```

### 요청

**Parameters**

- CorpNum `type: String` `length: 10` `required: Y` `description: 팝빌회원 사업자번호 ('-' 제외)`
- requestNum `type: String` `length: 36` `required: Y` `description: 파트너가 할당한 요청번호`
- UserID `type: String` `length: 50` `required: N` `description: 팝빌회원 아이디`

### 응답

**TResponse**

- code `type: LongInt` `length: -` `description: API 처리에 대한 응답코드`
  - `1`: 성공
- message `type: String` `length: -` `description: API 처리에 대한 응답메시지`

### 예외

**EPopbillException**

- code `type: LongInt` `length: -` `description: API 처리 실패에 대한 오류코드`
  - 음의 정수 8자리 숫자값 [\[참고\] 오류코드](https://developers.popbill.com/error-code)
- message `type: String` `length: -` `description: API 처리 실패에 대한 오류메시지`
