---
# System prepended metadata

title: Api's

---

# Api's

```
     base_url: http://127.0.0.1:8000/api/v1
```

## Customer Registration
* **<base_url>/auth/register/**

```
request_method--POST


Status Code: 201

Example Request Body:
{
	"phone":"01516100100",
	"name":"Ikram Khan",
	"password":"123456"
}


Example Response Body:
{
  "message": "Registartion Successful"
}
```




## OTP verification
* **<base_url>/auth/verify-otp/**

```
request_method--POST

Status Code: 200

Example Request Body:
{
	"phone":"01516100100",
	"otp":"438132"
}


Example Response Body:
{
  "message": "Verification Successful"
}


```



## Get Token 
* **<base_url>/auth/token/**

```
request_method--POST


Status Code: 200


Example Request Body:
{
	"phone": "01516100273",
	"password":"test@1234"
}


Example Response Body:
{
  "token": {
    "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYzNDI0MTY0OCwianRpIjoiNTMyNDY4ZWVlMDQyNDY3NDk2ZGM1MDUzN2E3NTNjMTAiLCJ1c2VyX2lkIjoxfQ.3qJIZGWIckVhl7seKE5bCMer5vEQnjw8D409HtEEqTI",
    "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjM0MTU1ODQ4LCJqdGkiOiIyZWJmOWY2Mzc5ZWE0NDIxYmMwNWFmM2VlZjJlM2JlNiIsInVzZXJfaWQiOjF9.I5lXK8e76fOKW23ceX28ixbVl9mOMXJhqyWZ0y6qB2w"
  }
}
```


## Get New access token using refresh token
* **<base_url>/auth/refresh/**

```
request_method--POST

Status Code: 200

Example Request Body:
{
	"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYzNDI0NDE2MiwianRpIjoiODgzMDM2MWI4NWU5NDI4NjlhMTgwMmYwOTdiYjZlMzQiLCJ1c2VyX2lkIjoxfQ.jhTiok50gGwqUWsgTV7cDh3cV7aCmOBtBuygXw8jhS8"
}


Example Response Body:
{
  "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjM0MTU4Mzc5LCJqdGkiOiJjNjdmZDkyMzQ5MDY0Njc2YTMwYWM4NDJjOTNkZGFlMCIsInVzZXJfaWQiOjF9.n7LTIA5FAs5Syi97l19Pp5-CoA5X7VTg7LTbhEPe01c"
}


```



## Add Phone No
* **<base_url>/auth/add-phone-no/**

```
request_method--POST

--header
     Authorization: bearer {token}

Status Code: 201

Example Request Body:
{
	"phone":"01917100100"
}


Example Response Body:
{
  "message": "Phone No added Successfully, Please verify it via otp"
}


```



## Make Primary Phone No
* **<base_url>/auth/make-primary-phone/**

```
request_method--POST

--header
     Authorization: bearer {token}

Status Code: 201

Example Request Body:
{
	"phone":"01917822808"
}


Example Response Body:
{
  "message": "Now 01917822808 is your primary phone no"
}


```



## View All Plans
* **<base_url>/plans/**

```
request_method--GET

--header
     Authorization: bearer {token}

Status Code: 200



Example Response Body:
{
  "count": 3,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 1,
      "name": "Globalnet Bronze",
      "amount": "500.00",
      "payment_cycle": 30,
      "total_valid_months": 12,
      "is_cancellable": false
    },
    {
      "id": 2,
      "name": "Globalnet Sliver",
      "amount": "750.00",
      "payment_cycle": 30,
      "total_valid_months": 12,
      "is_cancellable": false
    },
    {
      "id": 3,
      "name": "Globalnet Gold",
      "amount": "1200.00",
      "payment_cycle": 30,
      "total_valid_months": 12,
      "is_cancellable": true
    }
  ]
}


```



## View Plan Details
* **<base_url>/plans/1/**

```
request_method--GET

--header
     Authorization: bearer {token}

Status Code: 200


Example Response Body:
{
  "id": 1,
  "name": "Globalnet Bronze",
  "amount": "500.00",
  "payment_cycle": 30,
  "total_valid_months": 12,
  "is_cancellable": false
}


```

## Save Plan (Only for superuser)
* **<base_url>/plans/**

```
request_method--POST

--header
     Authorization: bearer {token}

Status Code: 201

Example Request Body:
{
	"name":"Globalnet Gold",
	"amount":1200,
	"is_cancellable":true
}

**Some Optional Parameters:**
    is_cancellable : default false
    payment_cycle: int, default 30
    total_valid_months: int, default 12


Example Response Body:
{
  "id": 3,
  "name": "Globalnet Gold",
  "amount": "1200.00",
  "payment_cycle": 30,
  "total_valid_months": 12,
  "is_cancellable": true
}


```



## Update Plan (Only for superuser)
* **<base_url>/plans/<int:plan_id>**

```
request_method--PUT/PATCH

--header
     Authorization: bearer {token}

Status Code: 200

Example Request Body:
{
    "name": "Globalnet Gold",
	"amount":1500
}


Example Response Body:
{
  "id": 3,
  "name": "Globalnet Gold",
  "amount": "1500.00",
  "payment_cycle": 30,
  "total_valid_months": 12,
  "is_cancellable": true
}


```


## Delete Plan (Only for superuser)
* **<base_url>/plans/<int:plan_id>**

```
request_method--DELETE

--header
     Authorization: bearer {token}

Status Code: 204


```



## Purchase Plan
* **<base_url>/purchase-plan/**

```
request_method--POST

--header
     Authorization: bearer {token}

Status Code: 201

Example Request Body:
{
	"plan":1
}


Example Response Body:
{
  "message": "Purchase Plan Successful",
  "data": {
    "id": 5,
    "plan_id": 1,
    "start_date": "2021-10-14",
    "end_date": "2022-10-09",
    "is_active": true,
    "plan_name": "Globalnet Bronze",
    "plan_amount": 500.0,
    "plan_months_validity": 12,
    "plan_payment_cycle": 30,
    "plan_cancellable": false
  }
}


```



## Cancel Plan 
* **<base_url>/cancel-plan/<id:customer_plan_id>**

```
request_method--POST

--header
     Authorization: bearer {token}

Status Code: 201

Example Requested url:
    <base_url>/cancel-plan/5


Example Response Body:
{
  "message": "Plan is not cancellable",
  "data": {
    "id": 5,
    "plan_id": 1,
    "start_date": "2021-10-14",
    "end_date": "2022-10-09",
    "is_active": true,
    "plan_name": "Globalnet Bronze",
    "plan_amount": 500.0,
    "plan_months_validity": 12,
    "plan_payment_cycle": 30,
    "plan_cancellable": false
  }
}


```