> Documentation index for AI agents: https://docs.pagerduty.com/llms.txt

# Render a template

`POST https://api.pagerduty.com/templates/{id}/render`

Render a template. This endpoint has a variable request body depending on the template type. For the `status_update` template type, the caller will provide the incident id, and a status update message.

Scoped OAuth requires: `templates.read`

## Authorization

- **api_key** (apiKey) — `Authorization` header. The API Key with format `Token token=<API_KEY>`

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | The ID of the resource. |

## Request body (`application/json`) — required

| Field | Type | Required | Description |
|---|---|---|---|
| `incident_id` | string |  | (option 1) The incident id to render the template for. |
| `status_update` | object |  | (option 1) |
| `status_update.message` | string |  | An optional status update message that will be sent to the template. |
| `external` |  |  | (option 1) An optional object collection that can be referenced in the template. |

Example: Request Example

```json
{
  "incident_id": "QT4KHLK034QWE34",
  "status_update": {
    "message": "Status update message"
  }
}
```

## Response 200

Successful operation

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `templated_fields` | object |  |  |
| `templated_fields.email_subject` | string |  | The rendered e-mail subject. |
| `templated_fields.email_body` | string |  | The rendered e-mail body. |
| `templated_fields.message` | string |  | The rendered short message (SMS, Push, Slack, etc) |
| `warnings` | object |  | List of render warnings messages for each rendered field. (Ex: ["{{incident.invalid_field}} does not exist."]) |
| `warnings.email_subject` | array of string |  | List of warnings for email_subject. |
| `warnings.email_body` | array of string |  | List of warnings for email_body. |
| `warnings.message` | array of string |  | List of warnings for message field. |
| `errors` | array of string |  | List of errors. |

Example: response

```json
{
  "templated_fields": {
    "email_subject": "Update: Status update message",
    "email_body": "<div class=\"test\">Status update message</div>",
    "message": "Update: Status update message"
  },
  "warnings": [
    {
      "email_body": [
        "{{incident.bad_value}} does not exist."
      ]
    }
  ],
  "errors": []
}
```

## Response 400

Caller provided invalid arguments. Please review the response for error details. Retrying with the same arguments will *not* work.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 402

Account does not have the abilities to perform the action. Please review the response for the required abilities.
You can also use the [Abilities API](#resource_Abilities) to determine what features are available to your account.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 403

Caller is not authorized to view the requested resource.
While your authentication is valid, the authenticated user or token does not have permission to perform this action.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 404

The requested resource was not found.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 500

Internal Server Error the PagerDuty server experienced an error.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Developer Agreement

Your access to and use of the PagerDuty Developer Services is governed by the [PagerDuty Developer Agreement](https://docs.pagerduty.com/developer/pagerduty-developer-agreement).
