Articles on: API

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:

While creating a document
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.

NameTypeDescription
reminders.toobjectMain recipient of email
reminders.to.namestringName of main recipient
reminders.to.emailemailEmail of main recipient
reminders.ccarray[object]email CC list
reminders.cc[].namestringName of recipient
reminders.cc[].emailemailEmail of recipient
reminders.fromobjectEmail from
reminders.from.namestringSender Name
reminders.from.emailemailSender 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>_). 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





> urlKey: Your business URL key
> 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"
}



Updated on: 31/01/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!