> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.refrens.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to trigger emails for all your documents via API?

> With a separate end points, trigger emails to your clients/vendors, either at the time of creating an accounting document, or any time after.

There are two ways you can share a document with your client or vendor:

1. While creating a document
2. Via a separate endpoint for emails via POST

# 1) Email while creating an invoice

While creating an invoice, you can add a separate object for email.

| Name | Type | Description |
| ---- |
| reminders.to | object | Main recipient of email |
| reminders.to.name | string | Name of main recipient |
| reminders.to.email | email | Email of main recipient |
| reminders.cc | array[object] | email CC list |
| reminders.cc[].name | string | Name of recipient |
| reminders.cc[].email | email | Email of recipient |
| reminders.from | object | Email from |
| reminders.from.name | string | Sender Name |
| reminders.from.email | email | Sender Email |

**Important Note:** Only use "email.from" fields if you want to send emails from your own email address. For that, you will first need to connect your personal/work email with Refrens ([*See how to do that>*](https://refrens.freshdesk.com/support/solutions/articles/44002480777-how-to-send-invoice-emails-from-your-own-email-address-)). If you don't add the "email.from" fields, the emails will be sent from our own system email.

### Sample Payload

```
 "reminders": {
        "to": {
            "name": "John",
            "email": "John@gmail.com"
        },
        "cc": {
            "email": "richard@xyz.com"
        },
        "from": {
            "email": "steve@xyz.com",
            "name": "steve"
        }
    }
```
## 
# 2) Via separate end-point, post invoice creation
### URL:

**Quotations:**

```
https://api.refrens.com/businesses/:urlKey/quotations/:invoiceID/email
```

**Delivery Challans:**

```
https://api.refrens.com/businesses/:urlKey/deliverychallans/:invoiceID/email
```

**Invoices and all other documents:**

```
https://api.refrens.com/businesses/:urlKey/invoices/:invoiceID/email
```


1. > urlKey: Your business URL key
2. > invoiceID: the ID of the document you want to share over email. Find the document ID as part of the response under "_id"

## Sample Payload

```
{
    "cc": [
        {
            "email": "richard@xyz.com",
            "name": null
        }
    ],
    "to": {
        "email": "John@gmail.com",
        "name": "John"
    },
    "from": {
        "name": "Steve",
        "email": "steve@xyz.com"
    }
}
```
## Sample Response

```
{
    "cc": [],
    "to": {
        "email": "John@gmail.com",
        "name": "John"
    },
    "from": {
        "name": "Steve"
        "email": "steve@xyz.com"
    },
    "emailType": "email",
    "isExpenditureEmail": false,
    "subject": "[Important] Email Invoice For API Client - #UG0262",
    "body": "Hi Infosys,\n\nPlease find attached invoice #UG0262.\n\nInvoice No: #UG0262\nInvoice Date: Dec 12, 2023\nBilled To: API Client\nInvoice Amount: ₹1,180.0\nAmount Received: ₹1,180.0\nTotal: ₹1,180\nPayment Date: Dec 12, 2023\n\nThank you for your business.\n\nRegards ,\nRefrens Demo"
}
```

