# TemplatesApi

All URIs are relative to *http://localhost:8889/api*

|Method | HTTP request | Description|
|------------- | ------------- | -------------|
|[**_delete**](#_delete) | **DELETE** /templates/{templateId} | Delete an existing template|
|[**createTemplate**](#createtemplate) | **POST** /templates | Create a new template|
|[**getByTemplateId**](#getbytemplateid) | **GET** /templates/{templateId} | Get template by id|
|[**updateTemplate**](#updatetemplate) | **PATCH** /templates/{templateId} | Update an existing template|

# **_delete**
> _delete()

This endpoint deletes an existing webhook template identified by the provided <code>templateId</code>.   

### Example

```typescript
import {
    TemplatesApi,
    Configuration
} from './api';

const configuration = new Configuration();
const apiInstance = new TemplatesApi(configuration);

let templateId: string; //The ID of the template to be deleted. (default to undefined)

const { status, data } = await apiInstance._delete(
    templateId
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **templateId** | [**string**] | The ID of the template to be deleted. | defaults to undefined|


### Return type

void (empty response body)

### Authorization

[basic](../README.md#basic)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/vnd.mambu.v2+json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**204** | The template was successfully deleted. |  -  |
|**400** | A validation error occurred |  -  |
|**401** | Unauthorized |  -  |
|**403** | Forbidden |  -  |
|**404** | The template could not be found. |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **createTemplate**
> BaseTemplateConfiguration createTemplate(baseTemplateConfiguration)

This endpoint creates a new template, performing all necessary validations.  Note: Currently, only Webhook templates are supported.

### Example

```typescript
import {
    TemplatesApi,
    Configuration,
    BaseTemplateConfiguration
} from './api';

const configuration = new Configuration();
const apiInstance = new TemplatesApi(configuration);

let baseTemplateConfiguration: BaseTemplateConfiguration; //Object which contains the values of the to-be-created template.

const { status, data } = await apiInstance.createTemplate(
    baseTemplateConfiguration
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **baseTemplateConfiguration** | **BaseTemplateConfiguration**| Object which contains the values of the to-be-created template. | |


### Return type

**BaseTemplateConfiguration**

### Authorization

[basic](../README.md#basic)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/vnd.mambu.v2+json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**201** | The template was successfully created. |  -  |
|**400** | A validation error occurred |  -  |
|**401** | Unauthorized |  -  |
|**403** | Forbidden |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **getByTemplateId**
> BaseTemplateConfiguration getByTemplateId()

This endpoint retrieves a specific template, regardless of its type (webhook, SMS, or email), based on the provided <code>templateId</code>.   

### Example

```typescript
import {
    TemplatesApi,
    Configuration
} from './api';

const configuration = new Configuration();
const apiInstance = new TemplatesApi(configuration);

let templateId: string; //The ID of the template to be retrieved. (default to undefined)

const { status, data } = await apiInstance.getByTemplateId(
    templateId
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **templateId** | [**string**] | The ID of the template to be retrieved. | defaults to undefined|


### Return type

**BaseTemplateConfiguration**

### Authorization

[basic](../README.md#basic)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/vnd.mambu.v2+json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**200** | The template was successfully retrieved. |  -  |
|**400** | A validation error occurred |  -  |
|**401** | Unauthorized |  -  |
|**403** | Forbidden |  -  |
|**404** | The template could not be found. |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **updateTemplate**
> BaseTemplateConfiguration updateTemplate(patchOperation)

This endpoint updates an existing template, performing all necessary validations on the updated object.   Note: Currently, only Webhook templates are supported.     A valid PATCH request contains an array of PATCH operation objects.<br></br><br></br><details><summary>Click for more details on the PATCH Request Object Structure</summary><p>These objects can be:</p><ul><li>For <code>REPLACE</code> Operation:<br/><code>{<br/>&nbsp;&nbsp;\\\"op\\\": \\\"REPLACE\\\",<br/>&nbsp;&nbsp;\\\"path\\\": \\\"&lt;path for replacement&gt;\\\",<br/>&nbsp;&nbsp;\\\"value\\\": \\\"&lt;new value for the property&gt;\\\"<br/>}</code><ul><li><code>path</code>: Can be an editable property of the webhook template or the ID of a filter constraint or request header (<code>\\\"path\\\": \\\"&lt;nested object id&gt;/&lt;nested object property to be edited&gt;\\\"</code>) along with the property to be edited.</li><li><code>value</code>: Mandatory.</li></ul></li><li>For <code>REMOVE</code> Operation:<br/><code>{<br/>&nbsp;&nbsp;\\\"op\\\": \\\"REMOVE\\\",<br/>&nbsp;&nbsp;\\\"path\\\": \\\"&lt;path_for_removal&gt;\\\"<br/>}</code><ul><li><code>path</code>: Can be a nullable property of the webhook template or the ID (<code>\\\"path\\\": \\\"&lt;nested object id&gt;\\\"</code>) of an existing filter constraint or request header.</li><li>No <code>value</code> should be set.</li></ul></li><li>For <code>ADD</code> operation<ul><li>For simple properties:<br/><code>{<br/>&nbsp;&nbsp;\\\"op\\\": \\\"ADD\\\",<br/>&nbsp;&nbsp;\\\"path\\\": \\\"&lt;property_to_add_value_for&gt;\\\",<br/>&nbsp;&nbsp;\\\"value\\\": \\\"&lt;value_for_the_property&gt;\\\"<br/>}</code><ul><li><code>path</code>: Can be a template property.</li></ul></li><li>For new request headers or filter constraints:<br/><code>{<br/>&nbsp;&nbsp;\\\"op\\\": \\\"ADD\\\",<br/>&nbsp;&nbsp;\\\"path\\\": \\\"headers/&lt;header property&gt;\\\",<br/>&nbsp;&nbsp;\\\"value\\\": \\\"&lt;value to be added for specified property for the new header&gt;\\\"<br/>}</code></li><li><code>{<br/>&nbsp;&nbsp;\\\"op\\\": \\\"ADD\\\",<br/>&nbsp;&nbsp;\\\"path\\\": \\\"filterConstraints/&lt;filter constraint property&gt;\\\",<br/>&nbsp;&nbsp;\\\"value\\\": \\\"&lt;value to be added for specified property for the new filter constraint&gt;\\\"<br/>}</code></li></ul></li><li>In a single <code>PATCH</code> call, you can add only one new request header and one new filter constraint. If multiple attempts are made to add within the same array, only the last value for each type will be populated in the newly added nested object of each type.</li><li>For nested objects inside the template with <code>PATCH</code>, <code>ADD</code> works for addition only (given the custom syntax with the <code>headers</code> or <code>filterConstraints</code> identifiers) and <code>REPLACE</code> is the one used for the replacement of the values of the nested objects\' properties.</li></ul></details>\"

### Example

```typescript
import {
    TemplatesApi,
    Configuration
} from './api';

const configuration = new Configuration();
const apiInstance = new TemplatesApi(configuration);

let templateId: string; //The ID of the template to be updated. (default to undefined)
let patchOperation: Array<PatchOperation>; //Patch operations to be applied to a resource.

const { status, data } = await apiInstance.updateTemplate(
    templateId,
    patchOperation
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **patchOperation** | **Array<PatchOperation>**| Patch operations to be applied to a resource. | |
| **templateId** | [**string**] | The ID of the template to be updated. | defaults to undefined|


### Return type

**BaseTemplateConfiguration**

### Authorization

[basic](../README.md#basic)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/vnd.mambu.v2+json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**200** | The template was successfully updated. |  -  |
|**400** | A validation error occurred |  -  |
|**401** | Unauthorized |  -  |
|**403** | Forbidden |  -  |
|**404** | The template could not be found. |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

