Skip to content

MailSlurp\TemplateControllerApi

All URIs are relative to https://php.api.mailslurp.com.

Method HTTP request Description
createTemplate() POST /templates Create a Template
deleteTemplate() DELETE /templates/{templateId} Delete email template
getAllTemplates() GET /templates/paginated List templates
getTemplate() GET /templates/{templateId} Get template
getTemplatePreviewHtml() GET /templates/{templateId}/preview/html Get template preview HTML
getTemplatePreviewJson() GET /templates/{templateId}/preview/json Get template preview Json
getTemplates() GET /templates List templates
updateTemplate() PUT /templates/{templateId} Update template

createTemplate()

createTemplate($create_template_options): MailSlurpModelsTemplateDto

Create a Template

Create an email template with variables for use with templated transactional emails.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: API_KEY
$config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new MailSlurpApiTemplateControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`.
    // This is optional, `GuzzleHttpClient` will be used as default.
    new GuzzleHttpClient(),
    $config
);
$create_template_options = new MailSlurpModelsCreateTemplateOptions(); // MailSlurpModelsCreateTemplateOptions

try {
    $result = $apiInstance->createTemplate($create_template_options);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling TemplateControllerApi->createTemplate: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
create_template_options MailSlurpModelsCreateTemplateOptions

Return type

MailSlurpModelsTemplateDto

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: */*

[Back to top] [Back to API list] [Back to Model list] [Back to ]

deleteTemplate()

deleteTemplate($template_id)

Delete email template

Delete template

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: API_KEY
$config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new MailSlurpApiTemplateControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`.
    // This is optional, `GuzzleHttpClient` will be used as default.
    new GuzzleHttpClient(),
    $config
);
$template_id = 'template_id_example'; // string | Template ID

try {
    $apiInstance->deleteTemplate($template_id);
} catch (Exception $e) {
    echo 'Exception when calling TemplateControllerApi->deleteTemplate: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
template_id string Template ID

Return type

void (empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to ]

getAllTemplates()

getAllTemplates($page, $size, $sort, $since, $before): MailSlurpModelsPageTemplateProjection

List templates

Get all templates in paginated format

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: API_KEY
$config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new MailSlurpApiTemplateControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`.
    // This is optional, `GuzzleHttpClient` will be used as default.
    new GuzzleHttpClient(),
    $config
);
$page = 0; // int | Optional page  in list pagination
$size = 20; // int | Optional page size in list pagination
$sort = 'ASC'; // string | Optional createdAt sort direction ASC or DESC
$since = new DateTime("2013-10-20T19:20:30+01:00"); // DateTime | Filter by created at after the given timestamp
$before = new DateTime("2013-10-20T19:20:30+01:00"); // DateTime | Filter by created at before the given timestamp

try {
    $result = $apiInstance->getAllTemplates($page, $size, $sort, $since, $before);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling TemplateControllerApi->getAllTemplates: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
page int Optional page in list pagination [optional] [default to 0]
size int Optional page size in list pagination [optional] [default to 20]
sort string Optional createdAt sort direction ASC or DESC [optional] [default to 'ASC']
since DateTime Filter by created at after the given timestamp [optional]
before DateTime Filter by created at before the given timestamp [optional]

Return type

MailSlurpModelsPageTemplateProjection

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: */*

[Back to top] [Back to API list] [Back to Model list] [Back to ]

getTemplate()

getTemplate($template_id): MailSlurpModelsTemplateDto

Get template

Get email template

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: API_KEY
$config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new MailSlurpApiTemplateControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`.
    // This is optional, `GuzzleHttpClient` will be used as default.
    new GuzzleHttpClient(),
    $config
);
$template_id = 'template_id_example'; // string | Template ID

try {
    $result = $apiInstance->getTemplate($template_id);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling TemplateControllerApi->getTemplate: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
template_id string Template ID

Return type

MailSlurpModelsTemplateDto

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: */*

[Back to top] [Back to API list] [Back to Model list] [Back to ]

getTemplatePreviewHtml()

getTemplatePreviewHtml($template_id): string

Get template preview HTML

Get email template preview with passed template variables in HTML format for browsers. Pass template variables as query params.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: API_KEY
$config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new MailSlurpApiTemplateControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`.
    // This is optional, `GuzzleHttpClient` will be used as default.
    new GuzzleHttpClient(),
    $config
);
$template_id = 'template_id_example'; // string | Template ID

try {
    $result = $apiInstance->getTemplatePreviewHtml($template_id);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling TemplateControllerApi->getTemplatePreviewHtml: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
template_id string Template ID

Return type

string

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: text/html;charset=utf-8, text/html

[Back to top] [Back to API list] [Back to Model list] [Back to ]

getTemplatePreviewJson()

getTemplatePreviewJson($template_id): MailSlurpModelsTemplatePreview

Get template preview Json

Get email template preview with passed template variables in JSON format. Pass template variables as query params.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: API_KEY
$config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new MailSlurpApiTemplateControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`.
    // This is optional, `GuzzleHttpClient` will be used as default.
    new GuzzleHttpClient(),
    $config
);
$template_id = 'template_id_example'; // string | Template ID

try {
    $result = $apiInstance->getTemplatePreviewJson($template_id);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling TemplateControllerApi->getTemplatePreviewJson: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
template_id string Template ID

Return type

MailSlurpModelsTemplatePreview

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: */*

[Back to top] [Back to API list] [Back to Model list] [Back to ]

getTemplates()

getTemplates(): MailSlurpModelsTemplateProjection[]

List templates

Get all templates

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: API_KEY
$config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new MailSlurpApiTemplateControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`.
    // This is optional, `GuzzleHttpClient` will be used as default.
    new GuzzleHttpClient(),
    $config
);

try {
    $result = $apiInstance->getTemplates();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling TemplateControllerApi->getTemplates: ', $e->getMessage(), PHP_EOL;
}

Parameters

This endpoint does not need any parameter.

Return type

MailSlurpModelsTemplateProjection[]

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: */*

[Back to top] [Back to API list] [Back to Model list] [Back to ]

updateTemplate()

updateTemplate($template_id, $create_template_options): MailSlurpModelsTemplateDto

Update template

Update email template

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: API_KEY
$config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurpConfiguration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new MailSlurpApiTemplateControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`.
    // This is optional, `GuzzleHttpClient` will be used as default.
    new GuzzleHttpClient(),
    $config
);
$template_id = 'template_id_example'; // string | Template ID
$create_template_options = new MailSlurpModelsCreateTemplateOptions(); // MailSlurpModelsCreateTemplateOptions

try {
    $result = $apiInstance->updateTemplate($template_id, $create_template_options);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling TemplateControllerApi->updateTemplate: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
template_id string Template ID
create_template_options MailSlurpModelsCreateTemplateOptions

Return type

MailSlurpModelsTemplateDto

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: */*

[Back to top] [Back to API list] [Back to Model list] [Back to ]