Resend invoice, by costumized email notification#
This endpoint is used to resend by email a processed “Electronic invoice” or “PDF invoice”.
Through some endpoint parameters, you can create a customized email notification layout, so that the email notification sent to your customer/receiver have a customized “from”, “fromDisplayName”, “subject” and “body content” layout.
Endpoint steps#
Get a token from your credentials by calling the endpoint Account/getToken;
Resend notifications calling the endpoint OutboundFinancialDocumentMaintenance/sendAdditionalNotifications;
Response structure from server#
When a request is well formed and the authentication data is correct the system responds with a message envelope as follows:
{
"CorrelationId": "<GUID>", /* for correlation purposes */
"IsValid": true, /* false in case of erros */
"Errors": [], /* if empty is a good signal */
"Data": "<Service Response Data>" /* the data retuned ex: token, invoice status, dependent on the endpoint called */
}
Endpoint Server Base URL#
# SANDBOX - Test Environment
server_base_adress = "dcn-solution.saphety.com/Dcn.Sandbox.WebApi"
# Saphety Invoice Network - Production Environment
#server_base_adress = "dcn-solution.saphety.com/Dcn.Business.WebApi"
1. Get a token (Account/getToken)#
Get a token from your account credentials using endpoint api/Account/getToken
Check here how to obtain an authentication token.
2. Resend PDF invoice notifications (OutboundFinancialDocumentMaintenance/sendAdditionalNotifications)#
2.1 Request body structure#
{
{
"OutboundFinancialDocumentId": "guid",
"DestinationEmails": [
{
"Email": "string",
"SendAttachment": true,
"LanguageCode": "string",
"CC": [
"string"
],
"BCC": [
"string"
],
"From": "string",
"FromDisplayName": "string",
"Subject": "string",
"Body": "string",
"BodyContentType": "string"
}
]
}
}
OutboundFinancialDocumentId#
Description: You need to supply the id of the invoice “OutboundFinancialDocumentId”.
Required: Yes
Type: string
Example: “3fa85f64-5717-4562-b3fc-2c963f66afa6”
DestinationEmails#
Array of DestinationEmail
Email
Description: Defines the primary receiver/customer email address for the notification.
Required: Yes
Type: string
Example: “receiver@example.com”
SendAttachment
Description: Indicates whether the PDF is sent or not as an attachment in the notification.
Required: No
Type: boolean
Example: true
Notes: If it’s not declared in the payload, it will assume false.
LanguageCode
Description: Indicates the email notification language content.
Required: No
Type: string
Allowed values: “pt” or “en”
Example: “pt”
Notes: If it’s not declared in the payload, it will assume “en”.
CC
Description: Defines the CC email addresses for the notification.
Required: No
Type: string array
Example: [“cc_recipient1@example.com”, “cc_recipient2@example.com”]
BCC
Description: Defines the BCC email addresses for the notification.
Required: No
Type: string array
Example: [“bcc_recipient1@example.com”, “bcc_recipient2@example.com”]
From
Description: Defines a specific sender’s email address for the notification. Please read the note below. Please read the note below.
Required: No
Type: string
Example: “sender@senderdomain.com”
Notes: If you want to use a specific “From” domain for your notifications, it will be necessary to request for email domain authentication. This process will ensure that notifications are delivered securely to customers email inboxes.
If you use a “From” email domain that is not requested or correctly configured at our server, the notification email notification will be sent by Saphety/Sovos domain as “noreply@saphety.com”.
See here the form with the steps request for email domain authentication.
FromDisplayName
Description: Specifies a specific “From display name” of the sender in the recipient’s inbox.
Required: No
Type: string
Example: “Sender Company”
Notes: By default the notification is sent with “Invoice Network” as “From display name”.
Subject
Description: Specifies a specific subject for the email notification. Please read the note below.
Required: No
Type: string
Example: “Example Subject…”
Notes: By default the notification is sent with a predefined subject description.
Body
Description: Specifies a customized content (base64) for the body of the email notification.
Required: No
Type: string
Example: “VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgZW1haWwu…”
Notes: By default the notification has a predefined body content and layout.
You can add some markings to your template that will be replaced when sending the email. You can, for example, dynamically add the document link or document number to your template. To do this, simply place the tags ##DOCUMENT_LINK## where you want the link and ##DOCUMENT_NUMBER## where you want to place the document number.
Note that these markings will be replaced with text only. So if you really want to add a link, you will need to add ##DOCUMENT_LINK## in the href of the tag (e.g: <a href=”##DOCUMENT_LINK##”>Access document</a>)
To enable dynamic variables you need to request their configuration for your company.
BodyContentType
Description: Specifies the content type of the email body.
Required: No
Type: string
Example: “application/html”
2.2 Request example#
# SIN endpoint url
service_url = "https://" + server_base_adress + "/api/OutboundFinancialDocumentMaintenance/sendAdditionalNotifications"
print ("Endpoint url: " + service_url)
#headers
headers = {
'Content-Type': 'application/json',
'Authorization': 'bearer ' + token
}
# payload as json
payload = {
'OutboundFinancialDocumentId': 'fc5e547d-8537-4e05-97d5-1159c62efd6f',
'DestinationEmails': [{
'Email': '[email protected]',
'SendAttachment': True,
'LanguageCode': 'PT',
'From': '[email protected]',
'FromDisplayName': 'Sender Company',
'Subject': 'Example Subject...',
'Body': 'WzE0OjA5XSBBYnJldSwgTnVubw0KPGh0bWw+DQoNCjxo...',
'BodyContentType': 'application/html'
}]
}
Endpoint url: https://dcn-solution.saphety.com/Dcn.Sandbox.WebApi/api/OutboundFinancialDocumentMaintenance/sendAdditionalNotifications
* Note : in the Sandbox environment, the notifications are sent only for the user registration email, even if within the payload are displayed other email addresses.
2.3 Call endpoint resend notifications#
Resend an invoice by Document id (“OutboundFinancialDocumentId“) using endpoint /api/OutboundFinancialDocumentMaintenance/sendAdditionalNotifications
# Send the request (POST).
response = requests.request("POST", service_url, data=request_data, headers=headers)
# formating the response to json for visualization purposes only
json_response = json.loads(response.text)
print(json.dumps(json_response, indent=4))
{
"CorrelationId": "50d02294-fe13-49d4-8e5b-77fd02f953f2",
"IsValid": true,
"Errors": [],
"Data": [
"[email protected]"
]
}
At response “Data” you will see the email adress where the invoice was sent to.