---
# System prepended metadata

title: New Unsubscribe API Flow
tags: [API Document]

---

---
tags: API Document
---
New Unsubscribe API Flow
===
## Unsubscribe the *OLD payment user*
### Step 1: Verify the user is an *OLD payment user* and can do the unsubscribe action

#### Get profile data from `/api/v1/self`
```javascript=
{
    "id": 642,
    "user": "yemakiw282@jalcemail.com",
    "name": "yemakiw282@jalcemail.com",
    "profile": 550,
    "email": "yemakiw282@jalcemail.com",
    "role": "Standard",
    "role_id": 11,
    "capacity": 200,
    "mine_capacity": 200,
    "share_capacity": 500,
    "resource_capacity": 30,
    "resource_len": 5,
    "length": 2000,
    "subscription": "sub_ttttttttttt",  // *The subscription ID
    "plan": null,
    "tried": false,
    "end_role": "2020-10-29T12:53:39.955909Z",
    "simple_count": 0,
    "traditional_count": 0,
    "share_simple_count": 0,
    "share_traditional_count": 0,
    "akls": "6ec9fa84-7c25-47f6-a2e7-aea78206ec67",
    "charset": "s",
    "image": "https://ponddy-auth-develop.s3.amazonaws.com/static/user-images/9bea3b2c-2825-477e-a8c3-b9b167b85a43.svg?1601346170",
    "username": "yemakiw282@jalcemail.com",
    "sales_code": null,
    "onboarding": true,
    "language": "en",
    "uuid": "9bea3b2c-2825-477e-a8c3-b9b167b85a43",
    "is_sent_valued_customer_coupon": false,
    "cancel_at_period_end": null,  // It will be null
    "last_succeed_payment_intent": "pi_1HWYVBHRhoOpWeKwvclahX90",
    "default_payment_method": null,
    "last_token_expired_time": "0.0000000000",
    "levelsystem": 1,
    "account": null
}
```

#### Logic
```javascript=
if (
  self.subscription
){
  unsubscribeButton.show()
}
```
### Step 2: [Unsubscribe](https://hackmd.io/d48bSwr0RMquOe1B0QrNfQ?view#POST-apiv1payplannew_unsubscribe)
#### `POST` /api/v1/pay/plan/new_unsubscribe
##### Headers
- Authentication
    - User's SSO token
##### Return
==HTTP 204==

## Unsubscribe the *NEW payment user*
### Step 1: Verify the user is a *NEW payment user* and can do the unsubscribe action

#### Get profile data from `/api/v1/self`
```javascript=
{
    "id": 642,
    "user": "yemakiw282@jalcemail.com",
    "name": "yemakiw282@jalcemail.com",
    "profile": 550,
    "email": "yemakiw282@jalcemail.com",
    "role": "Standard",
    "role_id": 11,
    "capacity": 200,
    "mine_capacity": 200,
    "share_capacity": 500,
    "resource_capacity": 30,
    "resource_len": 5,
    "length": 2000,
    "subscription": null,
    "plan": null,
    "tried": false,
    "end_role": "2020-10-29T12:53:39.955909Z",
    "simple_count": 0,
    "traditional_count": 0,
    "share_simple_count": 0,
    "share_traditional_count": 0,
    "akls": "6ec9fa84-7c25-47f6-a2e7-aea78206ec67",
    "charset": "s",
    "image": "https://ponddy-auth-develop.s3.amazonaws.com/static/user-images/9bea3b2c-2825-477e-a8c3-b9b167b85a43.svg?1601346170",
    "username": "yemakiw282@jalcemail.com",
    "sales_code": null,
    "onboarding": true,
    "language": "en",
    "uuid": "9bea3b2c-2825-477e-a8c3-b9b167b85a43",
    "is_sent_valued_customer_coupon": false,
    "cancel_at_period_end": false,  // It will not be null
    "last_succeed_payment_intent": "pi_yyyyyyyyyyy",
    "default_payment_method": null,
    "last_token_expired_time": "0.0000000000",
    "levelsystem": 1,
    "account": null
}
```


#### Logic
```javascript=
if (
  self.cancel_at_period_end !== null
){
  unsubscribeButton.show()
}
```
### Step 2: [Unsubscribe](https://hackmd.io/d48bSwr0RMquOe1B0QrNfQ?view#POST-apiv1payplannew_unsubscribe)
#### `POST` /api/v1/pay/plan/new_unsubscribe
##### Headers
- Authentication
    - User's SSO token
##### Return
==HTTP 204==
