> ## Documentation Index
> Fetch the complete documentation index at: https://docs-dev-docs-event-stream-action-templates.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Customize Email and Ticket Handling with the Management API

> Use the Management API to send emails outside of standard workflows, create tickets on demand, and customize ticket behavior.

export const AuthCodeGroup = ({children, dropdown}) => {
  const [processedChildren, setProcessedChildren] = useState(children);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      unsubscribe = window.autorun(() => {
        const processChildren = node => {
          if (typeof node === "string") {
            let processedNode = node;
            for (const [key, value] of window.rootStore.variableStore.values.entries()) {
              const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
              processedNode = processedNode.replaceAll(new RegExp(escapedKey, "g"), value);
            }
            return processedNode;
          } else if (Array.isArray(node)) {
            return node.map(processChildren);
          } else if (node && node.props && node.props.children) {
            return {
              ...node,
              props: {
                ...node.props,
                children: processChildren(node.props.children)
              }
            };
          }
          return node;
        };
        setProcessedChildren(processChildren(children));
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  return <CodeGroup dropdown={dropdown}>{processedChildren}</CodeGroup>;
};

The <Tooltip tip="Management API: A product to allow customers to perform administrative tasks." cta="View Glossary" href="/docs/glossary?term=Management+API">Management API</Tooltip> has several email-related endpoints which you can use to augment the standard email workflows. For example, you can:

* Send some email types (like MFA enrollment emails) on demand

* Create tickets, which are generated URLs for email workflow actions (like password resets), on demand

* Customize the behavior of tickets, like setting different **Return To** URLs for verification emails or configuring password reset tickets to verify the user's email address.

## Verification email endpoints

Outside of the email verification workflow, you can use the [Send an email address verification email endpoint](https://auth0.com/docs/api/management/v2/jobs/post_verification_email) to send these emails on demand.

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://{yourDomain}/api/v2/jobs/verification-email' \
    --header 'authorization: Bearer <YOUR_MANAGEMENT_API_TOKEN>' \
    --header 'content-type: application/json' \
    --data '{ "user_id": "{USER_ID_OF_EMAIL_RECIPIENT}", "client_id": "{YOUR_APP_CLIENT_ID}","identity": {"user_id": "5457edea1b8f22891a000004","provider": "google-oauth2"}, "organization_id": "{YOUR_ORGANIZATION_ID}" }'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{yourDomain}/api/v2/jobs/verification-email");
  var request = new RestRequest(Method.POST);
  request.AddHeader("content-type", "application/json");
  request.AddHeader("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}");
  request.AddParameter("application/json", "{ "user_id": "{USER_ID_OF_EMAIL_RECIPIENT}", "client_id": "{YOUR_APP_CLIENT_ID}","identity": {"user_id": "5457edea1b8f22891a000004","provider": "google-oauth2"}, "organization_id": "{YOUR_ORGANIZATION_ID}" }", ParameterType.RequestBody);
  IRestResponse response = client.Execute(request);
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "strings"
      "net/http"
      "io/ioutil"
  )

  func main() {
      url := "https://{yourDomain}/api/v2/jobs/verification-email"
      payload := strings.NewReader("{ "user_id": "{USER_ID_OF_EMAIL_RECIPIENT}", "client_id": "{YOUR_APP_CLIENT_ID}","identity": {"user_id": "5457edea1b8f22891a000004","provider": "google-oauth2"}, "organization_id": "{YOUR_ORGANIZATION_ID}" }")

      req, _ := http.NewRequest("POST", url, payload)
      req.Header.Add("content-type", "application/json")
      req.Header.Add("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")

      res, _ := http.DefaultClient.Do(req)
      defer res.Body.Close()
      body, _ := ioutil.ReadAll(res.Body)

      fmt.Println(res)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  HttpResponse<String> response = Unirest.post("https://{yourDomain}/api/v2/jobs/verification-email")
      .header("content-type", "application/json")
      .header("authorization", "Bearer <YOUR_MANAGEMENT_API_TOKEN>")
      .body("{ "user_id": "{USER_ID_OF_EMAIL_RECIPIENT}", "client_id": "{YOUR_APP_CLIENT_ID}","identity": {"user_id": "5457edea1b8f22891a000004","provider": "google-oauth2"}, "organization_id": "{YOUR_ORGANIZATION_ID}" }")
      .asString();
  ```

  ```javascript Node.JS theme={null}
  var axios = require("axios").default;

  var options = {
      method: 'POST',
      url: 'https://{yourDomain}/api/v2/jobs/verification-email',
      headers: {
          'content-type': 'application/json',
          authorization: 'Bearer {YOUR_MANAGEMENT_API_TOKEN}'
      },
      data: {
          user_id: '{USER_ID_OF_EMAIL_RECIPIENT}',
          client_id: '{YOUR_APP_CLIENT_ID}',
          identity: {user_id: '5457edea1b8f22891a000004', provider: 'google-oauth2'},
          organization_id: '{YOUR_ORGANIZATION_ID}'
      }
  };

  axios.request(options).then(function (response) {
      console.log(response.data);
  }).catch(function (error) {
      console.error(error);
  });
  ```

  ```objc Obj-C theme={null}
  #import <Foundation/Foundation.h>

  NSDictionary *headers = @{ @"content-type": @"application/json",
                             @"authorization": @"Bearer {YOUR_MANAGEMENT_API_TOKEN}" };
  NSDictionary *parameters = @{ @"user_id": @"{USER_ID_OF_EMAIL_RECIPIENT}",
                                @"client_id": @"{YOUR_APP_CLIENT_ID}",
                                @"identity": @{ @"user_id": @"5457edea1b8f22891a000004", @"provider": @"google-oauth2" },
                                @"organization_id": @"{YOUR_ORGANIZATION_ID}" };

  NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];

  NSMutableURLRequest *request = [NSMutableURLRequest
      requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/jobs/verification-email"]
      cachePolicy:NSURLRequestUseProtocolCachePolicy
      timeoutInterval:10.0
  ];

  [request setHTTPMethod:@"POST"];
  [request setAllHTTPHeaderFields:headers];
  [request setHTTPBody:postData];

  NSURLSession *session = [NSURLSession sharedSession];
  NSURLSessionDataTask *dataTask = [
      session dataTaskWithRequest:request
      completionHandler:^( NSData *data, NSURLResponse *response, NSError *error) {
          if (error) {
              NSLog(@"%@", error);
          } else {
              NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
              NSLog(@"%@", httpResponse);
          }
      }
  ];
  [dataTask resume];
  ```

  ```php PHP theme={null}
  $curl = curl_init();

  curl_setopt_array($curl, [
      CURLOPT_URL => "https://{yourDomain}/api/v2/jobs/verification-email",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "{ "user_id": "{USER_ID_OF_EMAIL_RECIPIENT}", "client_id": "{YOUR_APP_CLIENT_ID}","identity": {"user_id": "5457edea1b8f22891a000004","provider": "google-oauth2"}, "organization_id": "{YOUR_ORGANIZATION_ID}" }",
      CURLOPT_HTTPHEADER => [
          "authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}",
          "content-type: application/json"
      ],
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);

  if ($err) {
      echo "cURL Error #:" . $err;
  } else {
      echo $response;
  }
  ```

  ```python Python theme={null}
  import http.client

  conn = http.client.HTTPSConnection("")
  payload = "{ "user_id": "{USER_ID_OF_EMAIL_RECIPIENT}", "client_id": "{YOUR_APP_CLIENT_ID}","identity": {"user_id": "5457edea1b8f22891a000004","provider": "google-oauth2"}, "organization_id": "{YOUR_ORGANIZATION_ID}" }"
  headers = {
      'content-type': "application/json",
      'authorization': "Bearer {YOUR_MANAGEMENT_API_TOKEN}"
  }

  conn.request("POST", "/{yourDomain}/api/v2/jobs/verification-email", payload, headers)

  res = conn.getresponse()
  data = res.read()

  print(data.decode("utf-8"))
  ```

  ```ruby Ruby theme={null}
  require 'uri'
  require 'net/http'
  require 'openssl'

  url = URI("https://{yourDomain}/api/v2/jobs/verification-email")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  request = Net::HTTP::Post.new(url)
  request["content-type"] = 'application/json'
  request["authorization"] = 'Bearer {YOUR_MANAGEMENT_API_TOKEN}'
  request.body = "{ "user_id": "{USER_ID_OF_EMAIL_RECIPIENT}", "client_id": "{YOUR_APP_CLIENT_ID}","identity": {"user_id": "5457edea1b8f22891a000004","provider": "google-oauth2"}, "organization_id": "{YOUR_ORGANIZATION_ID}" }"

  response = http.request(request)
  puts response.read_body
  ```

  ```swift Swift theme={null}
  import Foundation

  let headers = [
      "content-type": "application/json",
      "authorization": "Bearer {YOUR_MANAGEMENT_API_TOKEN}"
  ]
  let parameters = [
      "user_id": "{USER_ID_OF_EMAIL_RECIPIENT}",
      "client_id": "{YOUR_APP_CLIENT_ID}",
      "identity": [
          "user_id": "5457edea1b8f22891a000004",
          "provider": "google-oauth2"
      ],
      "organization_id": "{YOUR_ORGANIZATION_ID}"
  ] as [String : Any]

  let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
  let request = NSMutableURLRequest(
      url: NSURL(string: "https://{yourDomain}/api/v2/jobs/verification-email")! as URL,
      cachePolicy: .useProtocolCachePolicy,
      timeoutInterval: 10.0
  )

  request.httpMethod = "POST"
  request.allHTTPHeaderFields = headers
  request.httpBody = postData as Data

  let session = URLSession.shared
  let dataTask = session.dataTask(
      with: request as URLRequest,
      completionHandler: { (data, response, error) -> Void in
          if (error != nil) {
              print(error)
          } else {
              let httpResponse = response as? HTTPURLResponse
              print(httpResponse)
          }
      }
  )

  dataTask.resume()
  ```
</AuthCodeGroup>

Additionally, you can use the [Create an email verification ticket](https://auth0.com/docs/api/management/v2/tickets/post-email-verification) endpoint to generate email verification tickets.

## Password change endpoints

Outside of the change password link workflow, you can use the [Create a password change ticket](https://auth0.com/docs/api/management/v2/tickets/post-password-change) endpoint to generate password change tickets.

The change password link template has a **Redirect To** field which supports variables, like the user's ID. For more granular control, you can email the user a password reset ticket that you generate using this endpoint and set the `result_url` based your own criteria.

This endpoint also lets you customize whether to verify the user's email or include the email address as part of the `return_url`.

## MFA enrollment endpoints

Outside of the MFA enrollment workflow, you can use the [Create a multi-factor authentication enrollment ticket](https://auth0.com/docs/api/management/v2/guardian/post-ticket) endpoint to generate MFA enrollment tickets and optionally send an email with the created ticket.

When using Universal Login, this endpoint also lets you specify which factor the user must enroll with and whether a user already enrolled with MFA can enroll with additional factors.
