public function EmailTemplates::create in Auth0 Single Sign On 8.2
Create an email template by name. See docs @link below for valid names and fields. Required scope: "create:email_templates"
@link https://auth0.com/docs/api/management/v2#!/Email_Templates/post_email_te...
Parameters
string $template - the template name to create (see constants defined for this class).:
boolean $enabled - is the email template enabled?:
string $from - the email address the email should come from.:
string $subject - the email subject.:
string $body - the email body in the syntax indicated below.:
string $syntax - the email body syntax to use.:
string $resultUrl - URL where a click-through should land.:
integer $urlLifetime - URL lifetime, in seconds.:
Return value
mixed|string
Throws
\Exception - if a 200 response was not returned from the API.
File
- vendor/
auth0/ auth0-php/ src/ API/ Management/ EmailTemplates.php, line 135
Class
- EmailTemplates
- Class EmailTemplates. Handles requests to the Email Templates endpoint of the v2 Management API.
Namespace
Auth0\SDK\API\ManagementCode
public function create($template, $enabled, $from, $subject, $body, $syntax = 'liquid', $resultUrl = '', $urlLifetime = 0) {
// Required fields
$data = [
'template' => (string) $template,
'enabled' => (bool) $enabled,
'from' => (string) $from,
'subject' => (string) $subject,
'body' => (string) $body,
'syntax' => (string) $syntax,
'urlLifetimeInSeconds' => abs((int) $urlLifetime),
];
if (!empty($resultUrl)) {
$data['resultUrl'] = filter_var($resultUrl, FILTER_SANITIZE_URL);
}
return $this->apiClient
->method('post')
->addPath('email-templates')
->withBody(json_encode($data))
->call();
}