---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/verify/email#article
headline: Send Email Verifications with Verify and Twilio SendGrid
description: Set up your Twilio account to send verification emails with Verify and Twilio SendGrid with step-by-step instructions, complete with sample code.
url: https://www.twilio.com/docs/verify/email
inLanguage: en
dateModified: 2026-10-08T15:07:09.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# Send Email Verifications with Verify and Twilio SendGrid

This guide explains how to set up and send email verifications using Twilio Verify and Twilio SendGrid.

## Prerequisites

Using Verify with Twilio SendGrid requires the following configurations.

### Set up your Twilio SendGrid account

[Create a Twilio SendGrid account][] or [log in to your existing account][]. Email verifications use the Twilio SendGrid transactional email API.

### Create a Twilio SendGrid API key

To create a Twilio SendGrid API key, use the [Twilio SendGrid API][create-api-key] or the [Twilio SendGrid console][tsc-api-keys].

Create Twilio SendGrid API keys with [limited scopes][]. Set to **Restricted Access** with the following limited scopes:

| Access details             | Access level |
| -------------------------- | ------------ |
| Mail Send > Mail Send      | Full Access  |
| Mail Send > Scheduled Send | No Access    |
| Template Engine            | Read Access  |

To set up your Verify email integration, save your Twilio SendGrid API key.

### Set up domain authentication

Domain authentication lets you send email from your company's domain *without* `via sendgrid.net`. [Configure domain authentication][], then authenticate your domain in the [Twilio SendGrid console][tsc-sender-auth].

## Create an email template

To [create or select a design][dynamic-templates] for your template, go to the Twilio SendGrid [**Dynamic Templates** page][tsc-templates]. To include the Verify code in your email template, *use at least one of the following three variables*.

| Variable                      | Necessity | Contents                                                                                                                                   |
| ----------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `twilio_code`                 | Required  | The 4-10 digit One Time Passcode (OTP) without descriptive text.                                                                           |
| `twilio_message`              | Required  | Both the internationalized descriptive text and the OTP. Language defaults to English. To override language, [use the Locale parameter][]. |
| `twilio_message_without_code` | Required  | The internationalized descriptive text *only*.                                                                                             |
| `twilio_service_name`         | Optional  | The human-readable name given to the Service.                                                                                              |

* The `twilio_message` value resembles **Your MyServiceName verification code is: 123456** or **Su codigo de verificación para MyServiceName es: 123456**.
* The `twilio_message_without_code` value resembles **Your MyServiceName verification code is** or **Su codigo de verificacion para MyServiceName es**.

### Find Template ID

To find a list of your templates and their unique IDs, go to the Twilio SendGrid [**Dynamic Templates** page][tsc-templates]. Creating a Verify email integration requires a template ID. This ID contains 64 characters with one dash (`d-uuid`).

```html {title="Example Twilio SendGrid HTML Template with variables"}
<html>
  <head>
    <style type="text/css">
      body, p, div {
        font-family: Helvetica, Arial, sans-serif;
        font-size: 14px;
      }
      a {
        text-decoration: none;
      }
      a.verify {
        background-color:#ffbe00;
        color:#000000;
        display:inline-block;
        padding:12px 40px 12px 40px;
        text-align:center;
      }
    </style>
    <title></title>
  </head>
  <body>
  <center>
    <p>Example 1 - just the code (no localization in the message):</p>
    <p>The verification code is: <strong>{{twilio_code}}</strong></p>
    <p>Example 2 - use the code in a clickable link to trigger a verification check:</p>
    <p>
      <a href="https://example.com/signup/email/verify?token={{twilio_code}}"
         class="verify" target="_blank">Verify Email Now</a>
    </p>
    <p>Example 3 - entire localized message and code:</p>
    <p><strong>{{twilio_message}}</strong></p>
    <p><a href="https://www.twilio.com/en-us/blog/insights/open-source-transactional-email-templates">Check out more templates</a></p>
    <span style="font-size: 10px;"><a href=".">Email preferences</a></span>
  </center>
  </body>
</html>
```

This produces an email that resembles the following:

![Email verification examples with code 918135 and 'Verify Email Now' button.](https://docs-resources.prod.twilio.com/9250ce65a086222b1af746c9005a4f2b0fd6ab9ed9176a95cbeb7e13b655b5c7.png)

Transactional emails use **Email preferences** instead of [**Unsubscribe**][unsub-blog].

## Integrate Verify with Twilio SendGrid

Integrating Verify with Twilio SendGrid involves creating an email integration and connecting to the Verify service.

### Create an email integration

To create an integration in the Twilio Console:

1. Log in to the legacy Twilio Console.
2. Go to **Settings** > **[Email Integration][]**.
3. Click **Create new email integration**. The **Create new email integration** modal appears.
4. Provide values for the following fields:

   | Field                    | Value                                                             |
   | ------------------------ | ----------------------------------------------------------------- |
   | **Integration name**     | Human-readable name only visible within the Twilio console.       |
   | **“From” email address** | The sender email address displayed in the recipient's inbox. This |

address must be verified in Twilio SendGrid. |
\| **"From" name**                 | Sender name displayed in the recipients's inbox.                                                      |
\| **[SendGrid API key][API Key]** | 69 character long key formatted as `SG.xxxxxxxx.yyyyyyyy`.                                            |
\| **[Template ID][]**             | Found in your Twilio SendGrid account when you created your template.                                 |
5\. Click **Create**.

### Connect to your Verify service

Connect your email integration to your Verify service in one of two ways:

## Email integration

1. Go to **[Email Integration][]**.
2. To associate with an email integration, choose one or more services you want.

You can use one email integration for multiple services.

## Verify services

1. Go to **[Verify Services][]**.
2. Choose your service.
3. Go to the **Email** tab.
4. Choose an email integration.

Each service can only have one email integration.

## Send a Verify notification using email

An email verification can use a create Verify request with or without overrides that modify the email template and other details or use Twilio SendGrid substitutions.

## Basic verification

Start a verification with email

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function createVerification() {
  const verification = await client.verify.v2
    .services("VA305f5177a5c94bd22dba9aed7494c784")
    .verifications.create({
      channel: "email",
      to: "recipient@foo.com",
    });

  console.log(verification.sid);
}

createVerification();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

verification = client.verify.v2.services(
    "VA305f5177a5c94bd22dba9aed7494c784"
).verifications.create(channel="email", to="recipient@foo.com")

print(verification.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID at twilio.com/console
        // Provision API Keys at twilio.com/console/runtime/api-keys
        // and set the environment variables. See http://twil.io/secure
        // For local testing, you can use your Account SID and Auth token
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var verification = await VerificationResource.CreateAsync(
            channel: "email",
            to: "recipient@foo.com",
            pathServiceSid: "VA305f5177a5c94bd22dba9aed7494c784");

        Console.WriteLine(verification.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.Verification;

public class Example {
    // Find your Account SID at twilio.com/console
    // Provision API Keys at twilio.com/console/runtime/api-keys
    // and set the environment variables. See http://twil.io/secure
    // For local testing, you can use your Account SID and Auth token
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        Verification verification =
            Verification.creator("VA305f5177a5c94bd22dba9aed7494c784", "recipient@foo.com", "email").create();

        System.out.println(verification.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID at twilio.com/console
	// Provision API Keys at twilio.com/console/runtime/api-keys
	// and set the environment variables. See http://twil.io/secure
	// For local testing, you can use your Account SID and Auth token
	accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
	apiKey := os.Getenv("TWILIO_API_KEY")
	apiSecret := os.Getenv("TWILIO_API_SECRET")
	client := twilio.NewRestClientWithParams(twilio.ClientParams{
		Username:   apiKey,
		Password:   apiSecret,
		AccountSid: accountSid,
	})

	params := &verify.CreateVerificationParams{}
	params.SetChannel("email")
	params.SetTo("recipient@foo.com")

	resp, err := client.VerifyV2.CreateVerification("VA305f5177a5c94bd22dba9aed7494c784",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
$apiKey = $_ENV["TWILIO_API_KEY"];
$apiSecret = $_ENV["TWILIO_API_SECRET"];
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$twilio = new Client($apiKey, $apiSecret, $sid);

$verification = $twilio->verify->v2
    ->services("VA305f5177a5c94bd22dba9aed7494c784")
    ->verifications->create(
        "recipient@foo.com", // To
        "email", // Channel
    );

print $verification->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

verification = @client
               .verify
               .v2
               .services('VA305f5177a5c94bd22dba9aed7494c784')
               .verifications
               .create(
                 channel: 'email',
                 to: 'recipient@foo.com'
               )

puts verification.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:verifications:create \
   --service-sid VA305f5177a5c94bd22dba9aed7494c784 \
   --channel email \
   --to recipient@foo.com
```

```bash
curl -X POST "https://verify.twilio.com/v2/Services/VA305f5177a5c94bd22dba9aed7494c784/Verifications" \
--data-urlencode "Channel=email" \
--data-urlencode "To=recipient@foo.com" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

#### View the response

```json
{
  "sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VA305f5177a5c94bd22dba9aed7494c784",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "to": "recipient@foo.com",
  "channel": "email",
  "status": "pending",
  "valid": false,
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "lookup": {},
  "amount": null,
  "payee": null,
  "send_code_attempts": [
    {
      "time": "2015-07-30T20:00:00Z",
      "channel": "email",
      "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ],
  "sna": null,
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Verification with overrides

You can override the default template ID, default from name, or default from email with a channel configuration:

Start a verification with email with overrides

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function createVerification() {
  const verification = await client.verify.v2
    .services("VA305f5177a5c94bd22dba9aed7494c784")
    .verifications.create({
      channel: "email",
      channelConfiguration: {
        template_id: "d-4f7abxxxxxxxxxxxx",
        from: "override@example.com",
        from_name: "Override Name",
      },
      to: "recipient@foo.com",
    });

  console.log(verification.sid);
}

createVerification();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

verification = client.verify.v2.services(
    "VA305f5177a5c94bd22dba9aed7494c784"
).verifications.create(
    channel="email",
    to="recipient@foo.com",
    channel_configuration={
        "template_id": "d-4f7abxxxxxxxxxxxx",
        "from": "override@example.com",
        "from_name": "Override Name",
    },
)

print(verification.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID at twilio.com/console
        // Provision API Keys at twilio.com/console/runtime/api-keys
        // and set the environment variables. See http://twil.io/secure
        // For local testing, you can use your Account SID and Auth token
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var verification = await VerificationResource.CreateAsync(
            channel: "email",
            to: "recipient@foo.com",
            channelConfiguration: new Dictionary<
                string,
                Object>() { { "template_id", "d-4f7abxxxxxxxxxxxx" }, { "from", "override@example.com" }, { "from_name", "Override Name" } },
            pathServiceSid: "VA305f5177a5c94bd22dba9aed7494c784");

        Console.WriteLine(verification.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.Verification;

public class Example {
    // Find your Account SID at twilio.com/console
    // Provision API Keys at twilio.com/console/runtime/api-keys
    // and set the environment variables. See http://twil.io/secure
    // For local testing, you can use your Account SID and Auth token
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        Verification verification =
            Verification.creator("VA305f5177a5c94bd22dba9aed7494c784", "recipient@foo.com", "email")
                .setChannelConfiguration(new HashMap<String, Object>() {
                    {
                        put("template_id", "d-4f7abxxxxxxxxxxxx");
                        put("from", "override@example.com");
                        put("from_name", "Override Name");
                    }
                })
                .create();

        System.out.println(verification.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID at twilio.com/console
	// Provision API Keys at twilio.com/console/runtime/api-keys
	// and set the environment variables. See http://twil.io/secure
	// For local testing, you can use your Account SID and Auth token
	accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
	apiKey := os.Getenv("TWILIO_API_KEY")
	apiSecret := os.Getenv("TWILIO_API_SECRET")
	client := twilio.NewRestClientWithParams(twilio.ClientParams{
		Username:   apiKey,
		Password:   apiSecret,
		AccountSid: accountSid,
	})

	params := &verify.CreateVerificationParams{}
	params.SetChannel("email")
	params.SetTo("recipient@foo.com")
	params.SetChannelConfiguration(map[string]interface{}{
		"template_id": "d-4f7abxxxxxxxxxxxx",
		"from":        "override@example.com",
		"from_name":   "Override Name",
	})

	resp, err := client.VerifyV2.CreateVerification("VA305f5177a5c94bd22dba9aed7494c784",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
$apiKey = $_ENV["TWILIO_API_KEY"];
$apiSecret = $_ENV["TWILIO_API_SECRET"];
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$twilio = new Client($apiKey, $apiSecret, $sid);

$verification = $twilio->verify->v2
    ->services("VA305f5177a5c94bd22dba9aed7494c784")
    ->verifications->create(
        "recipient@foo.com", // To
        "email", // Channel
        [
            "channelConfiguration" => [
                "template_id" => "d-4f7abxxxxxxxxxxxx",
                "from" => "override@example.com",
                "from_name" => "Override Name",
            ],
        ],
    );

print $verification->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

verification = @client
               .verify
               .v2
               .services('VA305f5177a5c94bd22dba9aed7494c784')
               .verifications
               .create(
                 channel: 'email',
                 to: 'recipient@foo.com',
                 channel_configuration: {
                   'template_id' => 'd-4f7abxxxxxxxxxxxx',
                   'from' => 'override@example.com',
                   'from_name' => 'Override Name'
                 }
               )

puts verification.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:verifications:create \
   --service-sid VA305f5177a5c94bd22dba9aed7494c784 \
   --channel email \
   --to recipient@foo.com \
   --channel-configuration "{\"template_id\":\"d-4f7abxxxxxxxxxxxx\",\"from\":\"override@example.com\",\"from_name\":\"Override Name\"}"
```

```bash
CHANNEL_CONFIGURATION_OBJ=$(cat << EOF
{
  "template_id": "d-4f7abxxxxxxxxxxxx",
  "from": "override@example.com",
  "from_name": "Override Name"
}
EOF
)
curl -X POST "https://verify.twilio.com/v2/Services/VA305f5177a5c94bd22dba9aed7494c784/Verifications" \
--data-urlencode "Channel=email" \
--data-urlencode "To=recipient@foo.com" \
--data-urlencode "ChannelConfiguration=$CHANNEL_CONFIGURATION_OBJ" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

#### View the example response

```json
{
  "sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VA305f5177a5c94bd22dba9aed7494c784",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "to": "recipient@foo.com",
  "channel": "email",
  "status": "pending",
  "valid": false,
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "lookup": {},
  "amount": null,
  "payee": null,
  "send_code_attempts": [
    {
      "time": "2015-07-30T20:00:00Z",
      "channel": "SMS",
      "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ],
  "sna": null,
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Verification with substitutions

Channel configuration also supports [substitutions][].

Start a verification with email with substitutions

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function createVerification() {
  const verification = await client.verify.v2
    .services("VA305f5177a5c94bd22dba9aed7494c784")
    .verifications.create({
      channel: "email",
      channelConfiguration: {
        substitutions: {
          username: "Foo Bar",
        },
      },
      to: "recipient@foo.com",
    });

  console.log(verification.sid);
}

createVerification();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

verification = client.verify.v2.services(
    "VA305f5177a5c94bd22dba9aed7494c784"
).verifications.create(
    channel="email",
    to="recipient@foo.com",
    channel_configuration={"substitutions": {"username": "Foo Bar"}},
)

print(verification.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID at twilio.com/console
        // Provision API Keys at twilio.com/console/runtime/api-keys
        // and set the environment variables. See http://twil.io/secure
        // For local testing, you can use your Account SID and Auth token
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var verification = await VerificationResource.CreateAsync(
            channel: "email",
            to: "recipient@foo.com",
            channelConfiguration: new Dictionary<
                string,
                Object>() { { "substitutions", new Dictionary<string, Object>() { { "username", "Foo Bar" } } } },
            pathServiceSid: "VA305f5177a5c94bd22dba9aed7494c784");

        Console.WriteLine(verification.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.Verification;

public class Example {
    // Find your Account SID at twilio.com/console
    // Provision API Keys at twilio.com/console/runtime/api-keys
    // and set the environment variables. See http://twil.io/secure
    // For local testing, you can use your Account SID and Auth token
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        Verification verification =
            Verification.creator("VA305f5177a5c94bd22dba9aed7494c784", "recipient@foo.com", "email")
                .setChannelConfiguration(new HashMap<String, Object>() {
                    {
                        put("substitutions", new HashMap<String, Object>() {
                            {
                                put("username", "Foo Bar");
                            }
                        });
                    }
                })
                .create();

        System.out.println(verification.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID at twilio.com/console
	// Provision API Keys at twilio.com/console/runtime/api-keys
	// and set the environment variables. See http://twil.io/secure
	// For local testing, you can use your Account SID and Auth token
	accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
	apiKey := os.Getenv("TWILIO_API_KEY")
	apiSecret := os.Getenv("TWILIO_API_SECRET")
	client := twilio.NewRestClientWithParams(twilio.ClientParams{
		Username:   apiKey,
		Password:   apiSecret,
		AccountSid: accountSid,
	})

	params := &verify.CreateVerificationParams{}
	params.SetChannel("email")
	params.SetTo("recipient@foo.com")
	params.SetChannelConfiguration(map[string]interface{}{
		"substitutions": map[string]interface{}{
			"username": "Foo Bar",
		},
	})

	resp, err := client.VerifyV2.CreateVerification("VA305f5177a5c94bd22dba9aed7494c784",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
$apiKey = $_ENV["TWILIO_API_KEY"];
$apiSecret = $_ENV["TWILIO_API_SECRET"];
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$twilio = new Client($apiKey, $apiSecret, $sid);

$verification = $twilio->verify->v2
    ->services("VA305f5177a5c94bd22dba9aed7494c784")
    ->verifications->create(
        "recipient@foo.com", // To
        "email", // Channel
        [
            "channelConfiguration" => [
                "substitutions" => [
                    "username" => "Foo Bar",
                ],
            ],
        ],
    );

print $verification->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

verification = @client
               .verify
               .v2
               .services('VA305f5177a5c94bd22dba9aed7494c784')
               .verifications
               .create(
                 channel: 'email',
                 to: 'recipient@foo.com',
                 channel_configuration: {
                   'substitutions' => {
                     'username' => 'Foo Bar'
                   }
                 }
               )

puts verification.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:verifications:create \
   --service-sid VA305f5177a5c94bd22dba9aed7494c784 \
   --channel email \
   --to recipient@foo.com \
   --channel-configuration "{\"substitutions\":{\"username\":\"Foo Bar\"}}"
```

```bash
CHANNEL_CONFIGURATION_OBJ=$(cat << EOF
{
  "substitutions": {
    "username": "Foo Bar"
  }
}
EOF
)
curl -X POST "https://verify.twilio.com/v2/Services/VA305f5177a5c94bd22dba9aed7494c784/Verifications" \
--data-urlencode "Channel=email" \
--data-urlencode "To=recipient@foo.com" \
--data-urlencode "ChannelConfiguration=$CHANNEL_CONFIGURATION_OBJ" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

#### View example response

```json
{
  "sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VA305f5177a5c94bd22dba9aed7494c784",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "to": "recipient@foo.com",
  "channel": "email",
  "status": "pending",
  "valid": false,
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "lookup": {},
  "amount": null,
  "payee": null,
  "send_code_attempts": [
    {
      "time": "2015-07-30T20:00:00Z",
      "channel": "SMS",
      "attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ],
  "sna": null,
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Check an email verification

To check an email verification token, use the same code as other channels like SMS or voice.

Check an email verification

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function createVerificationCheck() {
  const verificationCheck = await client.verify.v2
    .services("VA305f5177a5c94bd22dba9aed7494c784")
    .verificationChecks.create({
      code: "123456",
      to: "recipient@foo.com",
    });

  console.log(verificationCheck.sid);
}

createVerificationCheck();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

verification_check = client.verify.v2.services(
    "VA305f5177a5c94bd22dba9aed7494c784"
).verification_checks.create(to="recipient@foo.com", code="123456")

print(verification_check.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID at twilio.com/console
        // Provision API Keys at twilio.com/console/runtime/api-keys
        // and set the environment variables. See http://twil.io/secure
        // For local testing, you can use your Account SID and Auth token
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var verificationCheck = await VerificationCheckResource.CreateAsync(
            to: "recipient@foo.com",
            code: "123456",
            pathServiceSid: "VA305f5177a5c94bd22dba9aed7494c784");

        Console.WriteLine(verificationCheck.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.VerificationCheck;

public class Example {
    // Find your Account SID at twilio.com/console
    // Provision API Keys at twilio.com/console/runtime/api-keys
    // and set the environment variables. See http://twil.io/secure
    // For local testing, you can use your Account SID and Auth token
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        VerificationCheck verificationCheck = VerificationCheck.creator("VA305f5177a5c94bd22dba9aed7494c784")
                                                  .setTo("recipient@foo.com")
                                                  .setCode("123456")
                                                  .create();

        System.out.println(verificationCheck.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID at twilio.com/console
	// Provision API Keys at twilio.com/console/runtime/api-keys
	// and set the environment variables. See http://twil.io/secure
	// For local testing, you can use your Account SID and Auth token
	accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
	apiKey := os.Getenv("TWILIO_API_KEY")
	apiSecret := os.Getenv("TWILIO_API_SECRET")
	client := twilio.NewRestClientWithParams(twilio.ClientParams{
		Username:   apiKey,
		Password:   apiSecret,
		AccountSid: accountSid,
	})

	params := &verify.CreateVerificationCheckParams{}
	params.SetTo("recipient@foo.com")
	params.SetCode("123456")

	resp, err := client.VerifyV2.CreateVerificationCheck("VA305f5177a5c94bd22dba9aed7494c784",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
$apiKey = $_ENV["TWILIO_API_KEY"];
$apiSecret = $_ENV["TWILIO_API_SECRET"];
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$twilio = new Client($apiKey, $apiSecret, $sid);

$verification_check = $twilio->verify->v2
    ->services("VA305f5177a5c94bd22dba9aed7494c784")
    ->verificationChecks->create([
        "to" => "recipient@foo.com",
        "code" => "123456",
    ]);

print $verification_check->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

verification_check = @client
                     .verify
                     .v2
                     .services('VA305f5177a5c94bd22dba9aed7494c784')
                     .verification_checks
                     .create(
                       to: 'recipient@foo.com',
                       code: '123456'
                     )

puts verification_check.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:verification-check:create \
   --service-sid VA305f5177a5c94bd22dba9aed7494c784 \
   --to recipient@foo.com \
   --code 123456
```

```bash
curl -X POST "https://verify.twilio.com/v2/Services/VA305f5177a5c94bd22dba9aed7494c784/VerificationCheck" \
--data-urlencode "To=recipient@foo.com" \
--data-urlencode "Code=123456" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

#### View the example response

```json
{
  "sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VA305f5177a5c94bd22dba9aed7494c784",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "to": "recipient@foo.com",
  "channel": "email",
  "status": "approved",
  "valid": true,
  "amount": null,
  "payee": null,
  "sna_attempts_error_codes": [],
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z"
}
```

[API Key]: #create-a-sendgrid-api-key

[Configure domain authentication]: /docs/sendgrid/ui/account-and-settings/how-to-set-up-domain-authentication

[tsc-api-keys]: https://app.sendgrid.com/settings/api_keys

[create-api-key]: /docs/sendgrid/api-reference/api-keys/create-api-keys

[Create a Twilio SendGrid account]: https://signup.sendgrid.com/

[Email Integration]: https://console.twilio.com/us1/develop/verify/settings/email

[tsc-templates]: https://mc.sendgrid.com/dynamic-templates

[tsc-sender-auth]: https://app.sendgrid.com/settings/sender_auth

[unsub-blog]: https://www.twilio.com/en-us/blog/insights/should-you-include-an-unsubscribe-link-in-transactional-email-messages

[Template ID]: #find-template-id

[Verify Services]: https://console.twilio.com/us1/develop/verify/services

[dynamic-templates]: /docs/sendgrid/ui/sending-email/how-to-send-an-email-with-dynamic-templates

[limited scopes]: /docs/sendgrid/api-reference/how-to-use-the-sendgrid-v3-api/authentication

[log in to your existing account]: https://app.sendgrid.com/login

[use the Locale parameter]: /docs/verify/supported-languages

[substitutions]: /docs/sendgrid/ui/sending-email/substitution-and-section-tags
