ballerinax/sendgrid Ballerina library

1.5.1

Overview

This is a generated connector for Sendgrid API v3 OpenAPI Specification.

The Beta endpoints for the new Email Activity APIs - functionality is subject to change without notice. You may not have access to this Beta endpoint.

Email Activity offers filtering and search by event type for two days worth of data. There is an optional add-on to store 60 days worth of data. This add-on also gives you access to the ability to download a CSV of the 60 days worth of email event data.

Configuring connector

Prerequisites

Quickstart

To use the Sendgrid connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

First, import the ballerinax/sendgrid module into the Ballerina project.

Copy
import ballerinax/sendgrid;

Step 2: Create a new connector instance

Configure the connection using the API-Key obtained.

Copy
sendgrid:ClientConfig configuration = {
    auth: {
        token: "<API-Key>"
    }
};
sendgrid:Client sendgridClient = check new (configuration);

Step 3: Invoke connector operation

  1. send a marketing email to a customer.
Copy
public function main() returns error? {
    sendgrid:SendMailRequest emailPayload = {
        personalizations : [{
            to: [{
                email: "<Receiver-Email>",
                name: "<Receiver-Name>"
            }]
        }],
        'from: {
            email: "<Sender-Email>",
            name: "<Sender-Name>"
        },
        content : [{
        'type: "text/plain",
        value: "<Email-Content>"
        }],
        subject: "<Email-Subject>"
    };
    _ = check sendgridClient->sendMail(emailPayload);
}
  1. Use bal run command to compile and run the Ballerina program.

Import

import ballerinax/sendgrid;Copy

Metadata

Released date: 10 months ago

Version: 1.5.1

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.4.1

GraalVM compatible: Yes


Pull count

Total: 

Current verison: 110


Weekly downloads


Source repository


Keywords

Marketing/Marketing Automation
Cost/Freemium

Contributors

Other versions

See more...