# Template Events

Template event management

## Get template events

> Retrieve all events defined in a template.\
> \
> Required permissions, when user-scoped authentication is used: \`PRODUCT\_VIEW\`.<br>

```json
{"openapi":"3.0.3","info":{"title":"Blynk Platform API","version":"1.0.0"},"tags":[{"name":"Template Events","description":"Template event management"}],"servers":[{"url":"https://{server_address}","description":"Blynk Server","variables":{"server_address":{"default":"blynk.cloud","description":"Your Blynk server domain"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth2 Bearer token obtained from authentication endpoint"}},"schemas":{"TemplateEvent":{"type":"object","properties":{"id":{"type":"integer","format":"int32","description":"Event ID"},"name":{"type":"string","description":"Event name"},"eventCode":{"type":"string","description":"Event code for triggering"},"type":{"type":"string","description":"Event type","enum":["ONLINE","OFFLINE","INFORMATION","WARNING","CRITICAL","CONTENT","INACTIVE","LIFECYCLE","NOTE"]}},"required":["id","name","type"]},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}},"required":["message"]}},"required":["error"]}}},"paths":{"/api/v1/organization/template/events":{"get":{"tags":["Template Events"],"summary":"Get template events","description":"Retrieve all events defined in a template.\n\nRequired permissions, when user-scoped authentication is used: `PRODUCT_VIEW`.\n","operationId":"getTemplateEvents","parameters":[{"name":"templateId","in":"query","required":true,"schema":{"type":"integer","format":"int32"},"description":"Template ID"}],"responses":{"200":{"description":"List of events","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/TemplateEvent"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden"},"404":{"description":"Template not found or access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests"},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## Create template event

> Add a new event to a template.\
> \
> Only the original (root) template can be edited (the one with \`parentId = null\`).\
> Sub-organizations cannot modify templates that were created by a parent organization.\
> Event names and codes must be unique within the template.\
> \
> Required permissions, when user-scoped authentication is used: \`PRODUCT\_EDIT\`.\
> Also, when the user-scoped authentication is used, user should have developer mode enabled.<br>

```json
{"openapi":"3.0.3","info":{"title":"Blynk Platform API","version":"1.0.0"},"tags":[{"name":"Template Events","description":"Template event management"}],"servers":[{"url":"https://{server_address}","description":"Blynk Server","variables":{"server_address":{"default":"blynk.cloud","description":"Your Blynk server domain"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth2 Bearer token obtained from authentication endpoint"}},"schemas":{"TemplateEvent":{"type":"object","properties":{"id":{"type":"integer","format":"int32","description":"Event ID"},"name":{"type":"string","description":"Event name"},"eventCode":{"type":"string","description":"Event code for triggering"},"type":{"type":"string","description":"Event type","enum":["ONLINE","OFFLINE","INFORMATION","WARNING","CRITICAL","CONTENT","INACTIVE","LIFECYCLE","NOTE"]}},"required":["id","name","type"]},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}},"required":["message"]}},"required":["error"]}}},"paths":{"/api/v1/organization/template/event/create":{"post":{"tags":["Template Events"],"summary":"Create template event","description":"Add a new event to a template.\n\nOnly the original (root) template can be edited (the one with `parentId = null`).\nSub-organizations cannot modify templates that were created by a parent organization.\nEvent names and codes must be unique within the template.\n\nRequired permissions, when user-scoped authentication is used: `PRODUCT_EDIT`.\nAlso, when the user-scoped authentication is used, user should have developer mode enabled.\n","operationId":"createTemplateEvent","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"productId":{"type":"integer","format":"int32","description":"Template ID"},"type":{"type":"string","description":"Event type","enum":["INFORMATION","WARNING","CRITICAL","CONTENT","NOTE"]},"name":{"type":"string","description":"Event name. Can only contain letters, digits, spaces, underscores, backslashes and punctuations.","maxLength":200,"minLength":1},"code":{"type":"string","description":"Event code for triggering. Can only contain letters, digits, underscores and hyphens.","maxLength":200,"minLength":1},"color":{"type":"string","description":"Event color in HEX format (e.g.","minLength":1,"maxLength":200},"description":{"type":"string","description":"Event description.","maxLength":1024},"showInTimeline":{"type":"boolean","description":"Whether the event should be displayed in the timeline widget"}},"required":["productId","type","name","code","color"]}}}},"responses":{"201":{"description":"Event created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateEvent"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template not found or access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests"},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## Update template event

> Update an event in a template.\
> \
> Only the original (root) template can be edited (the one with \`parentId = null\`).\
> Sub-organizations cannot modify templates that were created by a parent organization.\
> Event names and codes must be unique within the template.\
> \
> Required permissions, when user-scoped authentication is used: \`PRODUCT\_EDIT\`.\
> Also, when the user-scoped authentication is used, user should have developer mode enabled.<br>

```json
{"openapi":"3.0.3","info":{"title":"Blynk Platform API","version":"1.0.0"},"tags":[{"name":"Template Events","description":"Template event management"}],"servers":[{"url":"https://{server_address}","description":"Blynk Server","variables":{"server_address":{"default":"blynk.cloud","description":"Your Blynk server domain"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth2 Bearer token obtained from authentication endpoint"}},"schemas":{"TemplateEvent":{"type":"object","properties":{"id":{"type":"integer","format":"int32","description":"Event ID"},"name":{"type":"string","description":"Event name"},"eventCode":{"type":"string","description":"Event code for triggering"},"type":{"type":"string","description":"Event type","enum":["ONLINE","OFFLINE","INFORMATION","WARNING","CRITICAL","CONTENT","INACTIVE","LIFECYCLE","NOTE"]}},"required":["id","name","type"]},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}},"required":["message"]}},"required":["error"]}}},"paths":{"/api/v1/organization/template/event":{"put":{"tags":["Template Events"],"summary":"Update template event","description":"Update an event in a template.\n\nOnly the original (root) template can be edited (the one with `parentId = null`).\nSub-organizations cannot modify templates that were created by a parent organization.\nEvent names and codes must be unique within the template.\n\nRequired permissions, when user-scoped authentication is used: `PRODUCT_EDIT`.\nAlso, when the user-scoped authentication is used, user should have developer mode enabled.\n","operationId":"updateTemplateEvent","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"productId":{"type":"integer","format":"int32","description":"Template ID"},"id":{"type":"integer","format":"int32","description":"Event ID, that should be updated"},"type":{"type":"string","description":"Event type","enum":["INFORMATION","WARNING","CRITICAL","CONTENT","NOTE"]},"name":{"type":"string","description":"Event name. Can only contain letters, digits, spaces, underscores, backslashes and punctuations.","maxLength":200,"minLength":1},"code":{"type":"string","description":"Event code for triggering. Can only contain letters, digits, underscores and hyphens.","maxLength":200,"minLength":1},"color":{"type":"string","description":"Event color in HEX format (e.g.","minLength":1,"maxLength":200},"description":{"type":"string","description":"Event description.","maxLength":1024},"showInTimeline":{"type":"boolean","description":"Whether the event should be displayed in the timeline widget"}},"required":["productId","id","type","name","code","color"]}}}},"responses":{"200":{"description":"Event updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateEvent"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template/event not found or access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests"},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## Delete template event

> Remove an event from a template.\
> \
> Only the original (root) template can be edited (the one with \`parentId = null\`).\
> Sub-organizations cannot modify templates that were created by a parent organization.\
> \
> Required permissions, when user-scoped authentication is used: \`PRODUCT\_EDIT\`.\
> Also, when the user-scoped authentication is used, user should have developer mode enabled.<br>

```json
{"openapi":"3.0.3","info":{"title":"Blynk Platform API","version":"1.0.0"},"tags":[{"name":"Template Events","description":"Template event management"}],"servers":[{"url":"https://{server_address}","description":"Blynk Server","variables":{"server_address":{"default":"blynk.cloud","description":"Your Blynk server domain"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth2 Bearer token obtained from authentication endpoint"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}},"required":["message"]}},"required":["error"]}}},"paths":{"/api/v1/organization/template/event":{"delete":{"tags":["Template Events"],"summary":"Delete template event","description":"Remove an event from a template.\n\nOnly the original (root) template can be edited (the one with `parentId = null`).\nSub-organizations cannot modify templates that were created by a parent organization.\n\nRequired permissions, when user-scoped authentication is used: `PRODUCT_EDIT`.\nAlso, when the user-scoped authentication is used, user should have developer mode enabled.\n","operationId":"deleteTemplateEvent","parameters":[{"name":"templateId","in":"query","required":true,"schema":{"type":"integer","format":"int32"},"description":"Template ID"},{"name":"eventId","in":"query","required":true,"schema":{"type":"integer","format":"int32"},"description":"Event ID"}],"responses":{"204":{"description":"Event deleted successfully"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Template/event not found or access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests"},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blynk.io/en/blynk.cloud/platform-https-api/template-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
