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:
Templates support sending attachments. Attachments have the following structure:
Note: The
content
field in an attachment is expected to be base64 encoded.
Get Templates
GET
https://localhost:3333/api/templates
Returns a list of templates.
Headers
Get Template
GET
https://localhost:3333/api/templates/:id
Returns a template with the provided ID.Returns a 404: Not Found error if the specified template doesn't exist.
Path Parameters
Headers
Create Template
POST
https://localhost:3333/api/templates/
Creates a new template from the provided JSON request body.
Headers
Request Body
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.
Modify Template
PUT
https://localhost:3333/api/templates/:id
Modifies an existing template.
Path Parameters
Headers
Request Body
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 Template
DELETE
https://localhost:3333/api/templates/:id
Deletes a template by ID.
Path Parameters
Returns a 404 error if the specified template isn't found.
This method returns a status message indicating the template was deleted successfully.
Import Template
POST
https://localhost:3333/api/import/email
Imports an email as a template.
Headers
Request Body
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:
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.
Last updated