# SendGrid

> Source: https://truto.one/docs/integration-guides/sendgrid/

## Install SendGrid integration

The SendGrid integration can be found [here](https://app.truto.one/integrations/available/f2340e5e-4a07-4915-b28a-9cf8de1b91dd). Please install it in your environments before proceeding with the steps below.

## Connecting a SendGrid account

1. Click on **Connect Account**
   ![Click connect account](https://docs-assets.truto.one/truto-connect-account.png)

2. Type in a value for the Tenant ID. This can be any ID of your choosing. And then click on **Get connection link**
   ![Get connection link](https://docs-assets.truto.one/truto-connect-account-modal.png)

3. A new link will be generated. Clicking on the link will open a new tab with the list of integrations. You can share this link with your customers too, and they will be able to connect their SendGrid account.
   ![Share connection link](https://docs-assets.truto.one/truto-connect-account-link.png)

4. Select SendGrid
   ![Select SendGrid](https://docs-assets.truto.one/select-sendgrid.webp)

## Getting your Sendgrid API Key

1. You'll now be asked for your SendGrid API key. Navigate to https://app.sendgrid.com/settings/api_keys.

2. Click on **Create API Key**. ![Sendgrid create api key](https://docs-assets.truto.one/sendgrid-create-api-key.png)

3. Enter an API Key Name, select Restricted Access and Select User Account Read Access. Click **Create and View**. ![Sendgrid create api key details](https://docs-assets.truto.one/sendgrid-create-api-key-details.png) ![Sendgrid create api key details 2](https://docs-assets.truto.one/sendgrid-create-api-key-details-2.png)

4. Copy the API Key and store it somewhere safe for entering into the Truto interface later. ![Sendgrid create api key](https://docs-assets.truto.one/sendgrid-api-key.png)

5. Because Sendgrid doesn't have the necessary user interface to grant the **teammates.read** scope to the API Key, we'll have to do that using their API. So generate a similar API token that you did just now but with **Full Access** to modify the API Key we generated in the previous steps.

6. Then make a note of the API Key ID you generated in step 7. ![Sendgrid create api key id](https://docs-assets.truto.one/sendgrid-api-key-id.png)

7. Run the following cURL command to modify the scopes of the API Key,
```bash
curl --location --request PUT 'https://api.sendgrid.com/v3/api_keys/<truto_demo_api_key_id>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <full_access_api_token>' \
--data '{
    "name": "Truto Demo",
    "scopes": ["teammates.read"]
}'
```
In the command above, `truto_demo_api_key_id` is the ID of the API Key generated in step 7, `full_access_api_token` is the API Key with Full Access.

8. Now enter the API Key you stored in step 8 into the Truto Link interface.

9. _Voila!_ You should now see a connection successful message. You can now close this tab.

10. Go to your Truto account, and you should see the new SendGrid integration under **Integrated Accounts**. Click on the Account ID to view the details and initiate API calls.
