# PA02-04 - Account Cancellation (アカウント解約)

## Overview

Cancels the specified service account.

- Account cancellation is **asynchronous** - may take up to 10 minutes from specified time
- **Master account cannot be cancelled** via this API

---

## Request

### Method

`POST` (JSON format)

### URL

```
https://[host]/emptool/api/master/cnclAcnt/
```

### Authentication

Obtained via separate authentication API, included in request parameters.

### POST Parameters

| No  | Parameter | Name            | Required | Description       |
| --- | --------- | --------------- | -------- | ----------------- |
| 1   | json      | JSON Parameters | ◎        | Main request body |

### JSON Parameters

| No  | Parameter | Name               | Level | Type                   | Required | Description                                                                                                 |
| --- | --------- | ------------------ | ----- | ---------------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| 1   | authKey   | Authentication Key | 1     | Alphanumeric           | ◎        | Obtained from OEM authentication                                                                            |
| 2   | kind      | Service Type       | 1     | Alphanumeric + symbols | ◎        | Target service. Master account not allowed                                                                  |
| 3   | account   | Account            | 1     | Alphanumeric + symbols | ◎        | Target account. For MVNO, specify phone number                                                              |
| 4   | runDate   | Scheduled Date     | 1     | Half-width numeric     | -        | Cancellation date. Format: `YYYYMMDD` (also accepts `YYYY/MM/DD`, `YYYY-MM-DD`). Immediate if not specified |

**Legend:** ◎ Required

---

## Request Example

### Immediate Cancellation

```json
{
  "authKey": "XXXXXXXXXX",
  "kind": "MVNO",
  "account": "08038433843"
}
```

### Scheduled Cancellation

```json
{
  "authKey": "XXXXXXXXXX",
  "kind": "MVNO",
  "account": "08038433843",
  "runDate": "20240331"
}
```

---

## Response

### Format

JSON

### Parameters

| No  | Parameter         | Name        | Level | Type                   | Required | Description         |
| --- | ----------------- | ----------- | ----- | ---------------------- | -------- | ------------------- |
| 1   | resultCode        | Result Code | 1     | Numeric                | ◎        | Overall result code |
| 2   | status            | Status      | 1     | Object                 | ◎        | -                   |
| 3   | status.message    | Message     | 2     | Alphanumeric + symbols | ◎        | Result message      |
| 4   | status.statusCode | Status Code | 2     | Numeric                | ◎        | Result code         |

---

## Response Codes

| Status | Status Code | Detail Code | Message     | Description                                   |
| ------ | ----------- | ----------- | ----------- | --------------------------------------------- |
| ○      | 200         | 100         | OK          | Success                                       |
| ○      | 200         | 101         | OK          | Already satisfies request (already cancelled) |
| ×      | 400         | 200         | Bad Request | Parameter error - kind issue                  |
| ×      | 400         | 201         | Bad Request | Parameter error - account issue               |
| ×      | 400         | 204         | Bad Request | Parameter error - other parameter issue       |
| ×      | 400         | 228         | Bad Request | Parameter error - authKey issue               |
| ×      | 403         | 205         | Auth Error  | Authentication key problem                    |
| ×      | 500         | 210         | NG          | Account not found                             |
| ×      | 500         | 230         | NG          | Account is waiting for async processing       |
| ×      | 500         | 900         | NG          | Unexpected error occurred                     |

---

## Response Example

```json
{
  "resultCode": "100",
  "status": {
    "message": "OK",
    "statusCode": "200"
  }
}
```
