{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":539,"path":"api-reference/rest-apis/response-templates-api.md","title":"Response Templates API","bundle":null,"doc_type":null,"release":"australia","body":"\n# Response Templates API\n\nThe Response Templates API provides endpoints to handle records in the Response Templates \\[sn\\_templated\\_snip\\_note\\_template\\] table.\n\nThis script include requires the Templated Responses plugin \\(com.sn\\_templated\\_snip\\), which is activated by default, and runs within the `sn_templated_snip` namespace.\n\nFor additional information on response templates, see [Response templates](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/servicenow-platform/response-templates-templated-snippets.md).\n\n**Parent Topic:**[REST API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/api-rest.md)\n\n## Response Templates - POST /response\\_templates/get\\_templates\n\nReturns records from the Response Templates \\[sn\\_templated\\_snip\\_note\\_template\\] table.\n\n### URL format\n\nDefault URL: `/api/sn_templated_snip/response_templates/get_templates`\n\n### Supported request parameters\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n<table class=\"rest_api_request_body\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nerrorFormat\n\n</td><td>\n\nHTML formatting to use for errors. Data type: String\n\n Default: `\"<span style='color:#ff0000'>${%s}</span>\"`\n\n</td></tr><tr><td>\n\nincludeEvaluatedBody\n\n</td><td>\n\nFlag that indicates whether to render the template variables.Valid values:\n\n -   false: Do not render the template variables. The response contains the message variables.\n\nFor example:\n\n    ```\nPlease note that your case ${number} has been escalated to ${assignment_group}.\n    ```\n\n-   true: Renders the template variables and returns **evaluated\\_response** in the return results.\n\nFor example:\n\n    ```\nPlease note that your case INC100001 has been escalated to Facilities.\n    ```\n\n\n Data type: Boolean\n\n Default: false\n\n</td></tr><tr><td>\n\nlimit\n\n</td><td>\n\nMaximum number of response templates to return.Data type: Number\n\n Default: 50\n\n</td></tr><tr><td>\n\noffset\n\n</td><td>\n\nFor pagination, the index at which to start the search.Data type: Number\n\n Default: 0\n\n</td></tr><tr><td>\n\nopts\n\n</td><td>\n\nParameters to pass to the sn\\_templated\\_snip.response\\_template extension point. The format and content of these parameters are dependent on the implementation of the extension point. For additional information on extension points, see [Using extension points to extend application functionality](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/web-services/extension-points.md).Data type: Object\n\n</td></tr><tr><td>\n\nrecordId\n\n</td><td>\n\nRequired. Sys\\_id of the record to use to render the variables in the response template.Data type: String\n\n</td></tr><tr><td>\n\nsearchTerm\n\n</td><td>\n\nText to use to filter the list of matching response templates.The endpoint performs a CONTAINS search of this text on the name and body fields and a STARTS WITH search on the short name field. For example, if the search term is \"crash\", the endpoint returns any response template that matches the query criteria and has crash in the name or body or the short name starts with crash.\n\n Response templates with exact matches on short name appear first in the return results. All other returned response templates are sorted by name.\n\n Data type: String\n\n Default: Return all matching response templates.\n\n</td></tr><tr><td>\n\ntableName\n\n</td><td>\n\nRequired. Name of the table to use to search the Response Templates table to locate corresponding response templates. For example, \"incident\" or \"sn\\_hr\\_core\\_case\".Data type: String\n\n</td></tr></tbody>\n</table>### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Header|Description|\n|------|-----------|\n|Accept|Data format of the response body. Only supports **application/json**.|\n|Content-Type|Data format of the request body. Only supports **application/json**.|\n\n|Header|Description|\n|------|-----------|\n|None| |\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nresult\n\n</td><td>\n\nArray of objects that list all of the templates that match the specified search criteria.\n\n Data type: Array\n\n ```\n\"result\": [\n  {Object}\n]\n```\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;\n\n</td><td>\n\nResponse templates with exact matches on short name appear first in the return results. All other returned response templates are sorted by name.\n\n Data type: Object\n\n ```\n{\n  \"evaluated_response\": [Array],\n  \"name\": \"String\",\n  \"short_name\": \"String\",\n  \"short_name_match\": Boolean,\n  \"sys_id\": \"String\",\n  \"template_body\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.evaluated\\_response\n\n</td><td>\n\nArray that lists the results of the template evaluation.\n\n Data type: Array\n\n ```\n\"elevated_response\":[\n  \"error\": [Array],\n  \"evaluated_body\": \"String\",\n  \"success\": Boolean\n]\n```\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.evaluated\\_response.error\n\n</td><td>\n\nList of entries for each evaluation error that occurred.\n\n Data type: Array\n\n ```\n\"error\":[\n  \"inAccessibleVariables\": \"String\",\n  \"message\": \"String\",\n  \"unEvaluatedVariables\": \"String\"\n]\n```\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.evaluated\\_response.error.inAccessibleVariables\n\n</td><td>\n\nVariables in the response template body that could not be resolved.Data type: String\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.evaluated\\_response.error.message\n\n</td><td>\n\nError message.Data type: String\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.evaluated\\_response.error.unEvaluatedVariables\n\n</td><td>\n\nVariables in the response template body that were not evaluated.Data type: String\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.evaluated\\_response.evaluated\\_body\n\n</td><td>\n\nEvaluated response template body in HTML.Data type: String\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.evaluated\\_response.success\n\n</td><td>\n\nFlag that indicates whether all of the variables rendered properly.\n\n Possible values:\n\n-   true: All variables rendered properly.\n-   false: Variables did not render properly.\n\n Data type: Boolean\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.name\n\n</td><td>\n\nName of the response template.Data type: String\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.short\\_name\n\n</td><td>\n\nShort name of the response template.Data type: String\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.short\\_name\\_match\n\n</td><td>\n\nFlag that indicates whether an exact match occurred on the short name of the response template.\n\n Possible values:\n\n-   true: Search term is an exact match.\n-   false: Search term is not an exact match.\n\n Data type: Boolean\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.sys\\_id\n\n</td><td>\n\nSys\\_id of the response template.Data type: String\n\n</td></tr><tr><td>\n\nresult.&lt;object&gt;.template\\_body\n\n</td><td>\n\nResponse template body in HTML.Data type: String\n\n</td></tr></tbody>\n</table>### Sample cURL request\n\n```\ncurl \"https://instance.service-now.com/api/sn_templated_snip/response_templates/get_templates\" \\\n--request POST \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--data \"{\n  \\\"tableName\\\": \\\"sn_hr_core_case_total_rewards\\\",\n  \\\"recordId\\\": \\\"2c9e43320b30220097432da0d5673a9c\\\"\n}\" \\\n--user \"username\":\"password\"\n```\n\n```\n{\n   \"result\": [\n      {\n         \"sys_id\": \"2552c4ec0b03320036e62c7885673a5a\",\n         \"name\": \"Escalation Notes - Total Rewards\",\n         \"short_name\": \"Escalation Notes - Total Rewards\",\n         \"template_body\": \"<p>Dear ${subject_person},<\\/p>\\n<p>Please note that your case ${number} has been escalated to ${assignment_group}. An agent will be assigned on your case and will keep you updated. If you have more questions please reach out to our team.<\\/p>\\n<p>Regards,<\\/p>\\n<p>${sys_updated_by}<\\/p>\"\n      },\n      {\n         \"sys_id\": \"698388ec0b03320036e62c7885673ab5\",\n         \"name\": \"Resolution Notes - Phone Inquiry\",\n         \"short_name\": \"Resolution Notes - Phone Inquiry\",\n         \"template_body\": \"<p>Thank you ${subject_person} for reaching out to the Global HR Services Team for your inquiry. As discussed over the phone, we have resolved your case ${number}.<\\/p>\\n<p>We are happy to help if you have more questions for our team. Please reach out and mention the case number ${number} on the call.<\\/p>\\n<p>Regards,<\\/p>\\n<p>${assigned_to}<\\/p>\"\n      }\n   ]\n}\n```\n\n"}}