# Franchise

### Guidelines

Below are some of the points you must be aware of while calling Payouts APIs:

* All API requests and responses are in JSON format.
* POST requests should include `ContentType: application/json`&#x20;
* All API response have **status,  message,** and **data**.
* Swipez uses API keys to allow access to the API. Once you have signed up at our merchant site, you will be able to see your [AccessKey and SecretKey](https://www.swipez.in/merchant/profile/accesskey).

### Quick Reference

| URL                                                                                                                                          | HTTP Verb | Functionality                |
| -------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ---------------------------- |
| [/api/token](https://app.gitbook.com/@billing-software/s/swipez-docs/~/drafts/-MdozwnKEnONfPzpH76b/franchise#get-token)                      | POST      | To get auth token.           |
| [/api/v1/franchise/save](https://app.gitbook.com/@billing-software/s/swipez-docs/franchise#save-franchise)                                   | POST      | To save franchise details.   |
| [/api/v1/franchise/update](https://app.gitbook.com/@billing-software/s/swipez-docs/~/drafts/-MdozwnKEnONfPzpH76b/franchise#update-franchise) | POST      | To update franchise details. |
| [/api/v1/franchise/delete](https://app.gitbook.com/@billing-software/s/swipez-docs/~/drafts/-MdozwnKEnONfPzpH76b/franchise#delete-franchise) | POST      | To delete franchise.         |

### **Authentication**

Calling the Authentication APIs allows you to get and verify bearer tokens returned by Swipez. Swipez require these token for all further communication.

> * Swipez libraries automatically call the Authorize API and internally store the token.
>
> * Do not store the token in an insecure manner. Regenerating a new token does not invalidate the already generated token. Token generated from one IP address cannot be used from a different IP address.
>
> * Token generated is valid for 60 Min . Please ensure that you get a new token by calling the authorize API once the token has expired.

### Rate limiting

The API is rate limited per user. You will receive a 429 HTTP status code if you exceed the rate limit. The rate limit is 30 requests per minute per user and is subject to change.

## Get token

<mark style="color:green;">`POST`</mark> `/api/token`

This endpoint allows you to get API token.

#### Request Body

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| access\_key\_id     | string | Your access key. |
| secret\_access\_key | string | Your secret key. |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": {
        "token": "<GENERATED TOEKN>"
    }
}
```

{% endtab %}

{% tab title="401 " %}

```
{
    "error": "Invalid Keys",
    "status": 0
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```javascript
curl --location --request POST '<BASE URL>/api/token' \
--form 'access_key_id="<GET ACCESS KEY ID FROM YOUR ACCOUNT>"' \
--form 'secret_access_key="<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>"'


```

{% endtab %}

{% tab title="PHP" %}

```
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/token',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('access_key_id' => '<GET ACCESS KEY ID FROM YOUR ACCOUNT>','secret_access_key' => '<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>'),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}
{% endtabs %}

## Save franchise

<mark style="color:green;">`POST`</mark> `/api/v1/franchise/save`

This endpoint allows you to add franchise.

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer auth token |
| Content-Type  | string | application/json  |

#### Request Body

| Name                       | Type   | Description                                                                    |
| -------------------------- | ------ | ------------------------------------------------------------------------------ |
| franchise\_code            | string | Unique identifier                                                              |
| franchise\_name            | string | Name of franchise.                                                             |
| contact\_person\_name      | string | Contact person name.                                                           |
| email\_id                  | string | Email id of franchise.                                                         |
| mobile                     | string | 10 digit mobile number of franchise                                            |
| pan\_number                | string | 10 Char Pan number                                                             |
| aadhar\_number             | string | 12 digit Aadhar num                                                            |
| gst\_number                | string | 15 char GST number.                                                            |
| address                    | string | Franchise address.                                                             |
| city                       | string | Franchise city.                                                                |
| state                      | string | Franchise state.                                                               |
| zipcode                    | string | Franchise zipcode                                                              |
| enable\_online\_settlement | number | If you want transfer franchise commission online. Values 1 for yes 0 for no.   |
| commission\_type           | string | Values: Percentage or Fixed                                                    |
| commission                 | number | Commission value either amount or percentage                                   |
| settlement\_type           | string | "Auto" for automatic transfer commission amount. "Manual" for manual transfer. |
| bank\_holder\_name         | string | Bank account holder name                                                       |
| account\_number            | string | Bank account number                                                            |
| bank\_name                 | string | Bank name                                                                      |
| account\_type              | string | Account type "Saving" or "Current"                                             |
| ifsc                       | string | IFSC code                                                                      |
| enable\_franchise\_login   | string | To enable franchise login 1 for yes 0 for no.                                  |
| login\_email               | string | Franchise login email id                                                       |
| password                   | string | Franchise login password                                                       |
| role\_name                 | string | Role name you can find in Setting->Roles menu on web dashboard                 |
|                            | string |                                                                                |

{% tabs %}
{% tab title="200 " %}

```
{
  "success":"Franchise saved successfully",
  "status": "1",
  "franchise_id": "8545"
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```javascript
curl --location --request POST '<BASE URL>/api/v1/franchise/save' \
--header 'Authorization: Bearer <TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "franchise_code": "5",
  "franchise_name": "john Ppp",
  "contact_person_name":"Paresh",
  "email_id": "johndoe@swipez.in",
  "mobile": "9999999999",
  "pan_number": "",
  "aadhar_number": "",
  "gst_number": "",
  "address": "404, Ferry bell,Lodha medows",
  "city": "Pune",
  "state": "Maharashtra",
  "zipcode": "411016",
  "enable_online_settlement": "1",
  "commission_type": "Percentage",
  "commission": "50",
  "settlement_type":"Auto",
  "bank_holder_name": "Paresh",
  "account_number": "00111122236",
  "bank_name": "SBI",
  "account_type": "Saving",
  "ifsc": "HDFC0000001",
  "enable_franchise_login":"1",
  "login_email":"franchise@swipez.in",
  "password":"password1",
  "role_name":"Role 1"
  }
'
```

{% endtab %}

{% tab title="PHP" %}

```

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/franchise/save',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "franchise_code": "5",
  "franchise_name": "john Ppp",
  "contact_person_name":"Paresh",
  "email_id": "johndoe@swipez.in",
  "mobile": "9999999999",
  "pan_number": "",
  "aadhar_number": "",
  "gst_number": "",
  "address": "404, Ferry bell,Lodha medows",
  "city": "Pune",
  "state": "Maharashtra",
  "zipcode": "411016",
  "enable_online_settlement": "1",
  "commission_type": "Percentage",
  "commission": "50",
  "settlement_type":"Auto",
  "bank_holder_name": "Paresh",
  "account_number": "00111122236",
  "bank_name": "SBI",
  "account_type": "Saving",
  "ifsc": "HDFC0000001",
  "enable_franchise_login":"1",
  "login_email":"franchise@swipez.in",
  "password":"password1",
  "role_name":"Role 1"
  }
',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer <TOKEN>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}

## Update franchise

<mark style="color:green;">`POST`</mark> `/api/v1/franchise/update`

This endpoint allows you to update franchise.

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer auth token |
| Content-Type  | string | application/json  |

#### Request Body

| Name                  | Type   | Description                         |
| --------------------- | ------ | ----------------------------------- |
| franchise\_id         | string | Franchise id                        |
| franchise\_name       | string | Name of franchise.                  |
| contact\_person\_name | string | Contact person name.                |
| email\_id             | string | Email id of franchise.              |
| mobile                | string | 10 digit mobile number of franchise |
| pan\_number           | string | 10 Char Pan number                  |
| aadhar\_number        | string | 12 digit Aadhar num                 |
| gst\_number           | string | 15 char GST number.                 |
| address               | string | Franchise address.                  |
| city                  | string | Franchise city.                     |
| state                 | string | Franchise state.                    |
| zipcode               | string | Franchise zipcode                   |
|                       | string |                                     |

{% tabs %}
{% tab title="200 " %}

```
{
  "success":"Franchise saved successfully",
  "status": "1",
  "franchise_id": "8545"
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```javascript
curl --location --request POST '<BASE URL>/api/v1/franchise/update' \
--header 'Authorization: Bearer <TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "franchise_id": "5",
  "franchise_name": "john Ppp",
  "contact_person_name":"Paresh",
  "email_id": "johndoe@swipez.in",
  "mobile": "9999999999",
  "pan_number": "",
  "aadhar_number": "",
  "gst_number": "",
  "address": "404, Ferry bell,Lodha medows",
  "city": "Pune",
  "state": "Maharashtra",
  "zipcode": "411016"
  }
'
```

{% endtab %}

{% tab title="PHP" %}

```

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/franchise/update',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "franchise_id": "5",
  "franchise_name": "john Ppp",
  "contact_person_name":"Paresh",
  "email_id": "johndoe@swipez.in",
  "mobile": "9999999999",
  "pan_number": "",
  "aadhar_number": "",
  "gst_number": "",
  "address": "404, Ferry bell,Lodha medows",
  "city": "Pune",
  "state": "Maharashtra",
  "zipcode": "411016"  
  }
',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer <TOKEN>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}

## Delete franchise

<mark style="color:green;">`POST`</mark> `/api/v1/franchise/delete`

This endpoint allows you to delete franchise.

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer auth token |
| Content-Type  | string | application/json  |

#### Request Body

| Name          | Type    | Description  |
| ------------- | ------- | ------------ |
| franchise\_id | integer | Franchise id |

{% tabs %}
{% tab title="200 " %}

```
{
  "success":"Franchise saved successfully",
  "status": "1",
  "franchise_id": "8545"
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```javascript
curl --location --request POST '<BASE URL>/api/v1/franchise/delete' \
--header 'Authorization: Bearer <TOKEN>' \
--header 'Content-Type: application/json' \
--form 'franchise_id="39"'
```

{% endtab %}

{% tab title="PHP" %}

```
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/franchise/update',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('franchise_id' => '1'),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer <TOKEN>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.swipez.in/franchise.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
