# Segment Manager Public API (1.0)

## [tag/Segment-Templates](https://docs.audience.kevel.com/http-docs/adstax-segment-manager-public-api-docs.html#tag/Segment-Templates) Segment Templates

## [tag/Segment-Templates/operation/getSegment-templates](https://docs.audience.kevel.com/http-docs/adstax-segment-manager-public-api-docs.html#tag/Segment-Templates/operation/getSegment-templates) List available templates

Lists all templates available for segment creation. Returned templated definitions include the required user input which will then be interpolated into the templated attributes and segment definition in order to create the needed resources. See the `applyTemplate` endpoint for more details on how to.

##### Authorizations:

_httpAuth_

### Responses

**200**

**401**

Malformed or invalid credentials.

get/segment-templates

https://docs.audience.kevel.com/segment-templates

### Response samples

- 200
- 401

Content type

application/json

```json
[  
    {  
        "id": "new_to_brand",  
        "name": "New to Brand",  
        "userInput": {  
            "brand": {  
                "type": "string"  
            },  
            "days": {  
                "type": "int"  
            }  
        },  
        "attributes": [  
            {  
                "key": "new_to_brand_attribute",  
                "name": "New to {{brand}}",  
                "matchRule": "meta[\"type\"] == \"orderPlace\" && exists(x:views[\"products\"], x[\"brand\"] == \"{{brand}}\")",  
                "attrPaths": [  
                    "$.meta.timestampMillis"  
                ],  
                "aggregation": {  
                    "type": "most-recent"  
                },  
                "periodDays": "{{days}}"  
            }  
        ],  
        "segment": {  
            "name": "New to {{brand}}",  
            "description": "Customers who are entering the brand for the first time or re-engaging after a long absence",  
            "category": "New buyer",  
            "rule": "not({{keys.new_to_brand_attribute}} after {{days}} days ago)"  
        }  
    }  
]
```

## [tag/Segment-Templates/operation/postSegment-templatesIdApply](https://docs.audience.kevel.com/http-docs/adstax-segment-manager-public-api-docs.html#tag/Segment-Templates/operation/postSegment-templatesIdApply) Create or reuse segment from template

Creates or reuses a segment and the respective attributes that feed it by applying user input to the template with the ID specified in the endpoint's path. The network ID is also required in order for the segment to be associated with the Kevel Native Segments destination for that network.

The response contains the ID of the created or reused segment, along with the template that was used.

##### Authorizations:

_httpAuth_

##### path Parameters

|     |     |
| --- | --- |
| id<br>required | string<br>The template ID to use for segment creation. |

##### Request Body schema: application/json  required

|     |     |
| --- | --- |
| networkId<br>required | integer <int32> <br>The network ID to associate the segment with in the respective KevelNativeSegments destination. |
| advertiserId<br>required | integer <int64> <br>The ID of the advertiser creating this segment. |
| userInputs<br>required | object (Map_Json) <br>Map of user inputs to interpolate into the template. These will be validated in accordance with the expected type attributed to the input in the template's definition. |

### Responses

**201**

**400**

**401**

Malformed or invalid credentials.

**404**

post/segment-templates/{id}/apply

https://docs.audience.kevel.com/segment-templates/{id}/apply

### Request samples

- Payload

Content type

application/json

```json
{  
    "networkId": 10000,  
    "advertiserId": 2712478,  
    "userInputs": {  
        "brand": "Kevel",  
        "days": 5  
    }  
}
```

### Response samples

- 201
- 400
- 401
- 404

Content type

application/json

```json
{  
    "segmentId": 0,  
    "template": {  
        "id": "new_to_brand",  
        "name": "New to Brand",  
        "userInput": {  
            "brand": {  
                "type": "string"  
            },  
            "days": {  
                "type": "int"  
            }  
        },  
        "attributes": [  
            {  
                "key": "new_to_brand_attribute",  
                "name": "New to {{brand}}",  
                "matchRule": "meta[\"type\"] == \"orderPlace\" && exists(x:views[\"products\"], x[\"brand\"] == \"{{brand}}\")",  
                "attrPaths": [  
                    "$.meta.timestampMillis"  
                ],  
                "aggregation": {  
                    "type": "most-recent"  
                },  
                "periodDays": "{{days}}"  
            }  
        ],  
        "segment": {  
            "name": "New to {{brand}}",  
            "description": "Customers who are entering the brand for the first time or re-engaging after a long absence",  
            "category": "New buyer",  
            "rule": "not({{keys.new_to_brand_attribute}} after {{days}} days ago)"  
        }  
    }  
}
```

## [tag/Segment-Templates/operation/getSegment-templatesIdInstantiations](https://docs.audience.kevel.com/http-docs/adstax-segment-manager-public-api-docs.html#tag/Segment-Templates/operation/getSegment-templatesIdInstantiations) List most recent template instantiations

Lists up to the 10 most recent instantiations for the given template, ordered by application time (most recent first). Each entry includes the resulting segment and attributes (with their content-hash IDs and whether they were reused) and the user inputs provided.

##### Authorizations:

_httpAuth_

##### path Parameters

|     |     |
| --- | --- |
| id<br>required | string<br>The template ID whose instantiations to list. |

### Responses

**200**

**401**

Malformed or invalid credentials.

**404**

get/segment-templates/{id}/instantiations

https://docs.audience.kevel.com/segment-templates/{id}/instantiations

### Response samples

- 200
- 401
- 404

Content type

application/json

```json
[  
    {  
        "id": 0,  
        "templateId": "string",  
        "timestamp": 0,  
        "details": {  
            "networkId": 0,  
            "advertiserId": 0,  
            "segmentRule": {  
                "id": "string",  
                "managementId": 0,  
                "reused": true  
            },  
            "attributes": [  
                {  
                    "key": "string",  
                    "id": "string",  
                    "reused": true  
                }  
            ],  
            "userInputs": {  
                "property1": null,  
                "property2": null  
            }  
        }  
    }  
]
```
