# Cancel scheduled payment API

### Cancels a scheduled payment before execution.

## Cancels a scheduled payment before execution.

<mark style="color:green;">`POST`</mark> `https://api.iamport.kr/subscribe/payments/unschedule`

#### Request Body

| Name                                            | Type   | Description                                                                                                     |
| ----------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------- |
| customer\_uid<mark style="color:red;">\*</mark> | String | <mark style="color:red;">**Billing key**</mark>                                                                 |
| merchant\_uid                                   | Array  | <p><strong>Order ID</strong></p><p>If omitted, cancels all scheduled payments associated with customer_uid.</p> |

{% tabs %}
{% tab title="200: OK Success" %}
{% tabs %}
{% tab title="ScheduleResponse" %}
**`code`** <mark style="color:red;">**\***</mark>**&#x20;**<mark style="color:purple;">**integer**</mark>

**Response code**

0: success, Not 0: check the message



**`message`** <mark style="color:red;">**\***</mark>**&#x20;**<mark style="color:green;">**string**</mark>

**Response message**

A non-zero code includes a message like 'Invalid payment info'.



**`response`** <mark style="color:red;">**(Array\[ScheduleResultAnnotation], optional**</mark>
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="ScheduleResultAnnotation" %}
**`code`** <mark style="color:red;">**\***</mark> <mark style="color:purple;">**integer**</mark>

**Response code**

0: success, Not 0: check the message



**`message`** <mark style="color:red;">**\***</mark>**&#x20;**<mark style="color:green;">**string**</mark>

**Response message**

A non-zero code includes a message like 'Invalid payment info'.



**`customer_uid`** <mark style="color:red;">**\***</mark> <mark style="color:green;">**string**</mark>

**Billing key**



**`merchant_uid`  \* &#x20;**<mark style="color:green;">**string**</mark>

**Order ID**



**`imp_uid`** <mark style="color:red;">\*</mark> <mark style="color:green;">**string**</mark>

**i'mport transaction UID**



**`schedule_at`**  <mark style="color:red;">**\***</mark>  <mark style="color:blue;">**UNIX timestamp**</mark>&#x20;

**Payment scheduled at**



**`executed_at`** <mark style="color:red;">**\***</mark>  <mark style="color:blue;">**UNIX timestamp**</mark>

**Payment started at**



**`revoked_at`** <mark style="color:red;">**\***</mark>  <mark style="color:blue;">**UNIX timestamp**</mark>

**Payment cancelled at**&#x20;



**`amount`** <mark style="color:red;">**\***</mark> <mark style="color:purple;">**integer**</mark>

**Payment amount**



**`name`**  <mark style="color:green;">**string**</mark>

**Product name**



**`buyer_name`**  <mark style="color:green;">**string**</mark>

**Customer name**



**`buyer_email`**  <mark style="color:green;">**string**</mark>

**Customer email**\


**`buyer_tel`**  <mark style="color:green;">**string**</mark>

**Customer phone number**



**`buyer_addr`**  <mark style="color:green;">**string**</mark>

**Customer address**



**`buyer_postcode`**  <mark style="color:green;">**string**</mark>

**Customer zip code**



**`custom_data`**  <mark style="color:green;">**string**</mark>

**Echo data as JSON string**



**`schedule_status`**  <mark style="color:red;">**\***</mark>**&#x20;** <mark style="color:green;">**string**</mark>

**Status of scheduled payment**&#x20;

* `scheduled` (payment is scheduled for execution)
* `executed` (payment is completed)
* `revoked` (payment is cancelled)



**`payment_status`** <mark style="color:red;">**\***</mark>**&#x20;** <mark style="color:green;">**string**</mark>

**Payment approval state**&#x20;

* `null`: Scheduled payment has not executed yet (actual null value, not string)
* `paid`: Scheduled payment is approved
* `failed`: Scheduled payment approval failed
* `cancelled`: Scheduled payment is refunded (cancelled) after approval



**`fail_reason`**  <mark style="color:green;">**string**</mark>

**Reason for failure**&#x20;
{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="401: Unauthorized Missing or invalid access token" %}
```javascript
{
    // Response
}
```
{% endtab %}
{% endtabs %}

<details>

<summary>Response Model Schema</summary>

```json
{
  "code": 0,
  "message": "string",
  "response": [
    {
      "customer_uid": "string",
      "merchant_uid": "string",
      "imp_uid": "string",
      "schedule_at": "0",
      "executed_at": "0",
      "revoked_at": "0",
      "amount": 0,
      "name": "string",
      "buyer_name": "string",
      "buyer_email": "string",
      "buyer_tel": "string",
      "buyer_addr": "string",
      "buyer_postcode": "string",
      "custom_data": "string",
      "schedule_status": "scheduled",
      "payment_status": "paid",
      "fail_reason": "string"
    }
  ]
}
```

</details>

{% hint style="success" %}
**Swagger Test Link**

[**https://api.iamport.kr/#!/subscribe/unschedule**](https://api.iamport.kr/#!/subscribe/unschedule)
{% endhint %}
