# 검수 요청

원문: https://commerce.bootpay.ai/api/alimtalk/template/register

> 만든 템플릿의 카카오 검수를 요청하는 API. 반려 시 수정 후 재요청

만든 템플릿의 카카오 검수를 요청합니다. 자체 템플릿은 **[템플릿 생성](https://commerce.bootpay.ai/api/alimtalk/template/create) → 검수 요청 → 승인** 순서로 발송할 수 있게 됩니다. 템플릿을 만들면 카카오에 바로 올라가므로, 이어서 이 API로 검수를 요청합니다.

::: warning 되돌릴 수 없는 호출입니다
검수 요청은 취소할 수 없고, 결과가 나올 때까지 문구를 고칠 수 없습니다. 요청 전에 [템플릿 상세](https://commerce.bootpay.ai/api/alimtalk/template/list)로 문구를 확인합니다.
:::

## 검수 요청 API

카카오에 심사를 요청합니다. 결과는 승인(APR) 또는 반려(REJ)로 돌아옵니다.

::: endpoint
method: POST
url: https://message.bootapi.com/alimtalk/templates/{id}/inspect
auth: [Basic Auth](https://commerce.bootpay.ai/api/server/authentication)
:::

### 호출할 수 있는 상태

**대기(`vendor_status: 1`) + REG(`inspection_status: "registered"`)** 일 때만 요청할 수 있습니다.

| 현재 상태 | 결과 |
|-----------|------|
| 아직 올리기 전 (`register: false` 로 만든 경우) | 거부됩니다. [아래](#register-false-로-만든-템플릿-등록)처럼 먼저 등록합니다 |
| 대기 + REG | **요청 가능** |
| REQ (검수 중) | 거부됩니다. 이미 심사 중입니다 |
| APR (승인) | 거부됩니다. 이미 승인됐습니다 |
| REJ · KRR (반려) | 거부됩니다. **문구를 [수정](https://commerce.bootpay.ai/api/alimtalk/template/update)한 뒤** 다시 요청합니다 |

::: info 반려는 재요청이 아니라 수정 후 재요청입니다
반려된 템플릿을 그대로 다시 요청하면 같은 이유로 또 반려됩니다. `comments`의 사유를 반영해 문구를 고친 다음 요청합니다.
:::

### 코드 예제

::: code-group

```bash [cURL]
curl -X POST "https://message.bootapi.com/alimtalk/templates/68b0f2a1c3d4e5f6a7b8c9d0/inspect" \
  -H "Authorization: Basic {base64(client_key:secret_key)}"
```

```javascript [Node.js]
import { BootpayCommerce } from '@bootpay/backend-js'

const commerce = new BootpayCommerce({
    client_key: 'your-commerce-client-key',
    secret_key: 'your-commerce-secret-key',
    mode: 'production'
})

const response = await commerce.alimtalkTemplate.inspect('68b0f2a1c3d4e5f6a7b8c9d0')
console.log(response)
```

```python [Python]
from bootpay_backend import BootpayCommerce

commerce = BootpayCommerce(
    client_key='your-commerce-client-key',
    secret_key='your-commerce-secret-key',
    mode='production'
)

response = commerce.alimtalk_template.inspect('68b0f2a1c3d4e5f6a7b8c9d0')
print(response)
```

```php [PHP]
use Bootpay\ServerPhp\BootpayCommerceApi;

$commerce = new BootpayCommerceApi("your-commerce-client-key", "your-commerce-secret-key");
$response = $commerce->alimtalkTemplate->inspect('68b0f2a1c3d4e5f6a7b8c9d0');
print_r($response);
```

```java [Java]
import kr.co.bootpay.store.BootpayStore;
import kr.co.bootpay.store.model.request.TokenPayload;
import kr.co.bootpay.store.model.response.BootpayStoreResponse;

TokenPayload tp = new TokenPayload("your-commerce-client-key", "your-commerce-secret-key");
BootpayStore commerce = new BootpayStore(tp).withToken();

BootpayStoreResponse response = commerce.alimtalkTemplate.inspect("68b0f2a1c3d4e5f6a7b8c9d0");
System.out.println(response.getRawData());
```

```ruby [Ruby]
require 'bootpay'

commerce = BootpayStore::RestClient.new(client_key: 'your-commerce-client-key', secret_key: 'your-commerce-secret-key')
response = commerce.alimtalk_template_inspect(template_id: '68b0f2a1c3d4e5f6a7b8c9d0')
puts response.data
```

```go [Go]
import "github.com/bootpay/backend-go/v2"

commerce := bootpay.NewCommerceAPI("your-commerce-client-key", "your-commerce-secret-key", nil, "production")
response, err := commerce.AlimtalkTemplate.Inspect("68b0f2a1c3d4e5f6a7b8c9d0")
fmt.Println(response, err)
```

```csharp [.NET]
using Bootpay.Commerce;

var commerce = new BootpayCommerceApi("your-commerce-client-key", "your-commerce-secret-key");
var response = await commerce.AlimtalkTemplateInspect("68b0f2a1c3d4e5f6a7b8c9d0");
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

:::

### 응답

요청 직후에는 `inspection_status`가 `requested`(REQ)입니다. 심사가 끝나면 `approved`(APR) 또는 `rejected`(REJ)로 바뀝니다.

```json
{
  "id": "68b0f2a1c3d4e5f6a7b8c9d0",
  "code": "BT_A58A7B_1A2B3C4D",
  "inspection_status": "requested",
  "vendor_status": 1,
  "comments": [],
  "comment_count": 0
}
```

반려되면 `comments`에 사유가 담깁니다.

## 검수 결과 받기

심사 결과를 폴링하지 않고 받으려면 [발송결과 웹훅](https://commerce.bootpay.ai/api/alimtalk-ops/webhook/setup)에서 검수 승인(`310`)·검수 반려(`311`) 이벤트를 구독합니다. 등록 거절(KRR)도 `311`로 옵니다. 이 웹훅은 그 템플릿을 처음 등록한 프로젝트로만 갑니다 — 같은 채널을 연동한 다른 프로젝트는 받지 못하므로 그쪽은 [템플릿 상세](https://commerce.bootpay.ai/api/alimtalk/template/list)로 확인합니다.

## 에러 코드

::: error-codes

| 코드 | error_code | 메시지 | 대처 방법 |
|------|------------|--------|-----------|
| `-48` | `INVALID_PARAMETER` | 호출 불가 상태 | 검수는 대기+REG 에서만, 등록은 아직 올리기 전에만 요청할 수 있습니다 |
| `3015` | `TEMPLATE_NOT_FOUND` | 템플릿 없음 | id 또는 코드를 확인합니다 |
| `3017` | `TEMPLATE_VARIABLE_MISSING` | 규격 위반 | 등록 직전 재검증에서 걸렸습니다. 문구·버튼 규격을 확인합니다 |
| `3018` | `SENDER_NOT_VERIFIED` | 발신프로필 미검증 | 채널을 다시 연동해 인증을 마칩니다 |
| `3024` | `SENDER_NOT_LINKED` | 발신프로필 미연결 | 이 프로젝트의 채널인지 확인합니다 |
| `3013` | `KAKAO_TEMPLATE_REQUEST_FAILED` | 등록·검수요청 거부 (HTTP 500) | `message`의 사유를 확인합니다 |

:::

## register: false 로 만든 템플릿 등록

[템플릿 생성](https://commerce.bootpay.ai/api/alimtalk/template/create)에서 `register: false` 를 줬다면 부트페이에만 저장된 상태입니다. 이 API로 카카오에 올린 뒤 검수를 요청합니다. `register` 를 생략하면 생성할 때 바로 올라가므로 호출할 필요가 없습니다.

::: endpoint
method: POST
url: https://message.bootapi.com/alimtalk/templates/{id}/register
auth: [Basic Auth](https://commerce.bootpay.ai/api/server/authentication)
:::

### 등록 요청 파라미터

::: parameters

| 파라미터 | 타입 | 필수 | 설명 |
|---------|------|------|------|
| id | String | Y | 템플릿 문서 id (경로 파라미터) |

:::

이미지형 템플릿의 본문 이미지와 아이템리스트형의 본문 이미지·하이라이트 썸네일은 이 시점에 카카오로 사본이 만들어집니다. 그 전에는 부트페이 storage 에만 있습니다.

### 등록 코드 예제

::: code-group

```bash [cURL]
curl -X POST "https://message.bootapi.com/alimtalk/templates/68b0f2a1c3d4e5f6a7b8c9d0/register" \
  -H "Authorization: Basic {base64(client_key:secret_key)}"
```

```javascript [Node.js]
import { BootpayCommerce } from '@bootpay/backend-js'

const commerce = new BootpayCommerce({
    client_key: 'your-commerce-client-key',
    secret_key: 'your-commerce-secret-key',
    mode: 'production'
})

const response = await commerce.alimtalkTemplate.register('68b0f2a1c3d4e5f6a7b8c9d0')
console.log(response)
```

```python [Python]
from bootpay_backend import BootpayCommerce

commerce = BootpayCommerce(
    client_key='your-commerce-client-key',
    secret_key='your-commerce-secret-key',
    mode='production'
)

response = commerce.alimtalk_template.register('68b0f2a1c3d4e5f6a7b8c9d0')
print(response)
```

```php [PHP]
use Bootpay\ServerPhp\BootpayCommerceApi;

$commerce = new BootpayCommerceApi("your-commerce-client-key", "your-commerce-secret-key");
$response = $commerce->alimtalkTemplate->register('68b0f2a1c3d4e5f6a7b8c9d0');
print_r($response);
```

```java [Java]
import kr.co.bootpay.store.BootpayStore;
import kr.co.bootpay.store.model.request.TokenPayload;
import kr.co.bootpay.store.model.response.BootpayStoreResponse;

TokenPayload tp = new TokenPayload("your-commerce-client-key", "your-commerce-secret-key");
BootpayStore commerce = new BootpayStore(tp).withToken();

BootpayStoreResponse response = commerce.alimtalkTemplate.register("68b0f2a1c3d4e5f6a7b8c9d0");
System.out.println(response.getRawData());
```

```ruby [Ruby]
require 'bootpay'

commerce = BootpayStore::RestClient.new(client_key: 'your-commerce-client-key', secret_key: 'your-commerce-secret-key')
response = commerce.alimtalk_template_register(template_id: '68b0f2a1c3d4e5f6a7b8c9d0')
puts response.data
```

```go [Go]
import "github.com/bootpay/backend-go/v2"

commerce := bootpay.NewCommerceAPI("your-commerce-client-key", "your-commerce-secret-key", nil, "production")
response, err := commerce.AlimtalkTemplate.Register("68b0f2a1c3d4e5f6a7b8c9d0")
fmt.Println(response, err)
```

```csharp [.NET]
using Bootpay.Commerce;

var commerce = new BootpayCommerceApi("your-commerce-client-key", "your-commerce-secret-key");
var response = await commerce.AlimtalkTemplateRegister("68b0f2a1c3d4e5f6a7b8c9d0");
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

:::

### 등록 응답

등록에 성공하면 `vendor_status`가 `1`(대기), `inspection_status`가 `registered`(REG)가 됩니다.

```json
{
  "id": "68b0f2a1c3d4e5f6a7b8c9d0",
  "code": "BT_A58A7B_1A2B3C4D",
  "vendor_status": 1,
  "inspection_status": "registered"
}
```

## 함께 보기

- [알림톡 발송](https://commerce.bootpay.ai/api/alimtalk-ops/send/send) — 승인(APR)된 템플릿 코드로 발송합니다
