Templates

A "Template" is the content of the emails that are sent to targets. They can be imported from an existing email, or created from scratch.
Additionally, templates can contain tracking images so that gophish knows when the user opens the email.
Templates have the following structure:
{
id : int64
name : string
subject : string
text : string
html : string
modified_date : string(datetime)
attachments : list(attachment)
}
Templates support sending attachments. Attachments have the following structure:
content: string
type : string
name : string
Note: The content field in an attachment is expected to be base64 encoded.
get
https://localhost:3333
/api/templates
Get Templates
get
https://localhost:3333
/api/templates/:id
Get Template
post
https://localhost:3333
/api/templates/
Create Template
This method expects the template to be provided in JSON format. You must provide a template name and the text and/or html for the template.
Importing an Existing Email
What better way to make pixel-perfect emails than by importing an existing email you already have in your inbox?
Using the Import Email endpoint, you can take a raw email and parse it as a valid Gophish template.
To add tracking, make sure you specify a {{.Tracker}} in the html field. The UI adds this automatically, but it needs to be specified if you're using the API.
This method returns the JSON representation of the template that was created.
put
https://localhost:3333
/api/templates/:id
Modify Template
This method expects the template to be provided in JSON format. You must provide a full template, not just the fields you want to update.
This method returns the JSON representation of the template that was modified.
delete
https://localhost:3333
/api/templates/:id
Delete Template
Returns a 404 error if the specified template isn't found.
This method returns a status message indicating the template was deleted successfully.
post
https://localhost:3333
/api/import/email
Import Template
Gophish provides the ability to parse an existing email to be used as a template. This makes it easy to repurpose legitimate emails for your phishing assessments.
This endpoint expects the raw email content in RFC 2045 format, including the original headers. Usually, this is found using the "Show Original" feature of email clients.
The request body for this endpoint is a JSON request in the form of:
{
content: string
convert_links: boolean
}
By setting the convert_links attribute to true, Gophish will automatically change all the links in the email to {{.URL}}.
Note: This method doesn't fully import the email as a template. Instead, it parses the email, returning a response that can be used with the "Create Template" endpoint.