@lap v0.3
# Machine-readable API spec. Each @endpoint block is one API call.
@api Twilio SendGrid Templates API
@base https://api.sendgrid.com
@version 1.0.0
@auth Bearer bearer
@common_fields {on-behalf-of: str # The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be "account-id" followed by the customer account's ID (e.g., `on-behalf-of: account-id `). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: `). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.}
@endpoints 11
@toc templates(11)

@endpoint POST /v3/templates
@desc Create a transactional template.
@required {name: str # The name for the new transactional template.}
@optional {generation: str(legacy/dynamic)}
@returns(201) {id: str(uuid), name: str, generation: str, updated_at: str, versions: [map], warning: map{message: str}}

@endpoint GET /v3/templates
@desc Retrieve paged transactional templates.
@required {page_size: num # The number of templates to be returned in each page of results}
@optional {generations: str=legacy # Comma-delimited list specifying which generations of templates to return. Options are `legacy`, `dynamic` or `legacy,dynamic`., page_token: str # A token corresponding to a specific page of results, as provided by metadata}
@returns(200) {result: [map], _metadata: map{prev: str(uri), self: str(uri), next: str(uri), count: int}}
@errors {400}

@endpoint POST /v3/templates/{template_id}
@desc Duplicate a transactional template.
@optional {name: str # The name for the new transactional template.}
@returns(201) {id: str(uuid), name: str, generation: str, updated_at: str, versions: [map], warning: map{message: str}}

@endpoint GET /v3/templates/{template_id}
@desc Retrieve a single transactional template.
@returns(200) {id: str(uuid), name: str, generation: str, updated_at: str, versions: [map], warning: map{message: str}}

@endpoint PATCH /v3/templates/{template_id}
@desc Edit a transactional template.
@optional {name: str # The name of the transactional template.}
@returns(200) {id: str(uuid), name: str, generation: str, updated_at: str, versions: [map], warning: map{message: str}}

@endpoint DELETE /v3/templates/{template_id}
@desc Delete a template.
@returns(204)

@endpoint POST /v3/templates/{template_id}/versions
@desc Create a new transactional template version.
@required {name: str # Name of the transactional template version., subject: str # Subject of the new transactional template version.}
@optional {active: int(0/1), html_content: str # The HTML content of the version. Maximum of 1048576 bytes allowed., plain_content: str=<generated from html_content if left empty> # Text/plain content of the transactional template version. Maximum of 1048576 bytes allowed., generate_plain_content: bool=true # If true, plain_content is always generated from html_content. If false, plain_content is not altered., editor: str(code/design), test_data: str # For dynamic templates only, the mock json data that will be used for template preview and test sends.}
@returns(201) {warnings: [map], active: int, name: str, html_content: str, plain_content: str, generate_plain_content: bool, subject: str, editor: str, test_data: str, id: str(uuid), template_id: str, updated_at: str, thumbnail_url: str}

@endpoint GET /v3/templates/{template_id}/versions/{version_id}
@desc Retrieve a specific transactional template version.
@returns(200) {warnings: [map], active: int, name: str, html_content: str, plain_content: str, generate_plain_content: bool, subject: str, editor: str, test_data: str, id: str(uuid), template_id: str, updated_at: str, thumbnail_url: str}

@endpoint PATCH /v3/templates/{template_id}/versions/{version_id}
@desc Edit a transactional template version.
@required {name: str # Name of the transactional template version., subject: str # Subject of the new transactional template version.}
@optional {active: int(0/1), html_content: str # The HTML content of the version. Maximum of 1048576 bytes allowed., plain_content: str=<generated from html_content if left empty> # Text/plain content of the transactional template version. Maximum of 1048576 bytes allowed., generate_plain_content: bool=true # If true, plain_content is always generated from html_content. If false, plain_content is not altered., editor: str(code/design), test_data: str # For dynamic templates only, the mock json data that will be used for template preview and test sends.}
@returns(200) {warnings: [map], active: int, name: str, html_content: str, plain_content: str, generate_plain_content: bool, subject: str, editor: str, test_data: str, id: str(uuid), template_id: str, updated_at: str, thumbnail_url: str}

@endpoint DELETE /v3/templates/{template_id}/versions/{version_id}
@desc Delete a transactional template version.
@returns(204)

@endpoint POST /v3/templates/{template_id}/versions/{version_id}/activate
@desc Activate a transactional template version.
@returns(200) {warnings: [map], active: int, name: str, html_content: str, plain_content: str, generate_plain_content: bool, subject: str, editor: str, test_data: str, id: str(uuid), template_id: str, updated_at: str, thumbnail_url: str}

@end
