> For the complete documentation index, see [llms.txt](https://ninjapay.gitbook.io/ninjapay-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ninjapay.gitbook.io/ninjapay-api-docs/how-to/api-reference-upi/plugins/invoice/add-edit-template.md).

# Add/Edit Template

This endpoint is used to add/edit template details for invoice plugin

#### Method

<pre><code><strong>POST https://api.ninjapay.me/webextension/api/v1/fiat/invoice/user/template/create
</strong></code></pre>

#### Parameters

* `id` (number):  If need to update template add value here from get template api response
* `template` (object): Contains the following properties:
  * `business_logo` (string): URL of the business logo NOTE: use upload Attachment API response for value&#x20;
  * `business_name` (string, required): Name of the business
  * `phone` (string, required): Contact phone number (without country code)
  * `phone_code` (string, required): Country code for the phone number
  * `email` (string, required): Contact email address
  * `billing_address` (string): Billing address
  * `city` (string): City of the business
  * `state` (string): State of the business
  * `zipcode` (string): Zipcode of the business
  * `country` (string): Country of the business
  * `documents` (object): Contains document details:
    * `doc_1` (object): First document:
      * `title` (string): Title of the document
      * `value` (string): Value of the document
    * `doc_2` (object): Second document:
      * `title` (string): Title of the document
      * `value` (string): Value of the document
  * `default_currency` (string): Default currency for transactions
  * `enable_qr` (boolean): Enable or disable QR code generation
  * `redirect_url` (string): URL to redirect after payment
  * `include_invoice_id` (boolean): Include invoice ID in the documentation
  * `webhook_url` (string): URL for webhook callbacks
  * `terms_condition_url` (string): URL for terms and conditions
  * `custom_thanks_message` (string): Custom thank you message
  * `custom_button_text` (string): Custom text for the payment button
  * `green_donation_link` (string): URL for green donation link
  * `donation_percentage` (number): Percentage of donation
  * `donation_message` (string): Message regarding donations
  * `tax_details` (object): Contains tax details:
    * `tax_title` (string): Title for tax
    * `tax_percentage` (number): Tax percentage
    * `tax_country` (string): Country where the tax is applicable
    * `is_all_states` (boolean): If tax is applicable to all states
    * `tax_states` (array): List of states where tax is applicable (empty if all states)

#### Request Body

```javascript
Body (application/json)
{
    "id": "",  // if need to update template add value here from get template api response
    "template": {
        "business_logo": "https://awesomecompany.com",  // URL of the business logo
        "business_name": "Awesome Company",  // Name of the business
        "phone": "234567890",  // Contact phone number (without country code)
        "phone_code": "+1",  // Country code for the phone number
        "email": "sample@gmail.com",  // Contact email address
        "billing_address": "123 Main Street",  // Billing address
        "city": "Hyderabad",  // City of the business
        "state": "Telangana",  // State of the business
        "zipcode": "12345",  // Zipcode of the business
        "country": "USA",  // Country of the business
        "documents": {
            "doc_1": {
                "title": "PAN",  // Title of the document
                "value": "HG297323"  // Value of the document
            },
            "doc_2": {
                "title": "GST",  // Title of the document
                "value": "76YHGF67656"  // Value of the document
            }
        },
        "default_currency": "USD",  // Default currency for transactions
        "enable_qr": true,  // Enable or disable QR code generation
        "redirect_url": "",  // URL to redirect after payment
        "include_invoice_id": true,  // Include invoice ID in the documentation
        "webhook_url": "",  // URL for webhook callbacks
        "terms_condition_url": "https://google.com",  // URL for terms and conditions
        "custom_thanks_message": "Thank you for your payment!",  // Custom thank you message
        "custom_button_text": "",  // Custom text for the payment button
        "green_donation_link": "",  // URL for green donation link
        "donation_percentage": 0.0,  // Percentage of donation
        "donation_message": "",  // Message regarding donations
        "tax_details": {
            "tax_title": "GST",  // Title for tax
            "tax_percentage": 18,  // Tax percentage
            "tax_country": "India",  // Country where the tax is applicable
            "is_all_states": true,  // If tax is applicable to all states
            "tax_states": []  // List of states where tax is applicable (empty if all states)
        }
    }
}


```

#### Response

```jsx
{
    "status": true,
    "data": {},
    "message": "Template changes added successfully"
}
```

#### Code Example

```jsx

const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'API_KEY' //Invoice key required
  },
  body: {
    "id": "",  // if need to update template add value here from get template api response 
    "template": {
        "business_logo": "https://awesomecompany.com",  // URL of the business logo
        "business_name": "Awesome Company",  // Name of the business
        "phone": "234567890",  // Contact phone number (without country code)
        "phone_code": "+1",  // Country code for the phone number
        "email": "sample@gmail.com",  // Contact email address
        "billing_address": "123 Main Street",  // Billing address
        "city": "Hyderabad",  // City of the business
        "state": "Telangana",  // State of the business
        "zipcode": "12345",  // Zipcode of the business
        "country": "USA",  // Country of the business
        "documents": {
            "doc_1": {
                "title": "PAN",  // Title of the document
                "value": "HG297323"  // Value of the document
            },
            "doc_2": {
                "title": "GST",  // Title of the document
                "value": "76YHGF67656"  // Value of the document
            }
        },
        "default_currency": "USD",  // Default currency for transactions
        "enable_qr": true,  // Enable or disable QR code generation
        "redirect_url": "",  // URL to redirect after payment
        "include_invoice_id": true,  // Include invoice ID in the documentation
        "webhook_url": "",  // URL for webhook callbacks
        "terms_condition_url": "https://google.com",  // URL for terms and conditions
        "custom_thanks_message": "Thank you for your payment!",  // Custom thank you message
        "custom_button_text": "",  // Custom text for the payment button
        "green_donation_link": "",  // URL for green donation link
        "donation_percentage": 0.0,  // Percentage of donation
        "donation_message": "",  // Message regarding donations
        "tax_details": {
            "tax_title": "GST",  // Title for tax
            "tax_percentage": 18,  // Tax percentage
            "tax_country": "India",  // Country where the tax is applicable
            "is_all_states": true,  // If tax is applicable to all states
            "tax_states": []  // List of states where tax is applicable (empty if all states)
        }
    }
}
};

fetch('https://api.ninjapay.me/webextension/api/v1/fiat/invoice/user/template/create', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
  
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://ninjapay.gitbook.io/ninjapay-api-docs/how-to/api-reference-upi/plugins/invoice/add-edit-template.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.
