openapi: "3.0.3" info: title: Mailbadger API version: "1.0" contact: name: Mailbadger support team email: support@mailbadger.io description: | The Mailbadger [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) API. license: name: “Commons Clause” License Condition v1.0 url: https://github.com/mailbadger/app/blob/master/LICENSE servers: - url: https://app.mailbadger.io/api tags: - name: templates description: Template operations - name: campaigns description: Campaign operations - name: subscribers description: Subscriber operations - name: groups description: Subscriber groups operations paths: /templates: get: tags: - templates operationId: getTemplates summary: List templates description: | Returns a list of templates in a paginated manner. Each object in the `collection` represents a Template. This endpoint should always return a result even if there are zero templates in the collection. parameters: - $ref: "#/components/parameters/perPage" - $ref: "#/components/parameters/endingBefore" - $ref: "#/components/parameters/startingAfter" - $ref: "#/components/parameters/scopes" responses: "200": description: OK content: application/json: schema: allOf: - $ref: "#/components/schemas/PaginationMeta" - type: object properties: collection: type: array items: $ref: "#/components/schemas/BaseTemplate" example: - id: 111 name: HelloWorld subject_part: Hello World! created_at: "2021-05-19T20:48:50.378Z" updated_at: "2021-05-19T20:48:50.378Z" - id: 222 name: Welcome subject_part: Welcome to Mailbadger {{name}}! created_at: "2021-05-19T20:48:50.378Z" updated_at: "2021-05-19T20:48:50.378Z" "401": $ref: "#/components/responses/Unauthorized" default: $ref: "#/components/responses/UnexpectedError" post: tags: - templates operationId: addTemplate summary: Add a new template description: | Add a new template to be used in the e-mail campaigns. The template's parts (subject, html and text) can contain tags which are used to personalize the campaign's content. The tag names are defined between two curly brackets e.g. `{{name}}`. requestBody: $ref: "#/components/requestBodies/TemplateParams" responses: "201": description: OK content: application/json: schema: $ref: "#/components/schemas/Template" "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: oneOf: - $ref: "#/components/schemas/Message" - $ref: "#/components/schemas/ValidationErrors" examples: validationErrors: summary: Invalid parameters value: message: Invalid parameters, please try again errors: name: Template name is required and must not be empty. html_part: Content must be html. message: summary: Bad request value: message: Template could not be created, please try again. "422": description: Unprocessable entity content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Template name is not unique. default: $ref: "#/components/responses/UnexpectedError" /templates/{id}: get: tags: - templates operationId: getTemplate summary: Get template by ID description: Returns a single template object parameters: - $ref: "#/components/parameters/id" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Template" "401": $ref: "#/components/responses/Unauthorized" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Template not found. default: $ref: "#/components/responses/UnexpectedError" put: tags: - templates operationId: updateTemplate summary: Update an existing template description: Update an existing template parameters: - $ref: "#/components/parameters/id" requestBody: $ref: "#/components/requestBodies/TemplateParams" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Template" "401": $ref: "#/components/responses/Unauthorized" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Template not found. "400": description: Bad request content: application/json: schema: oneOf: - $ref: "#/components/schemas/Message" - $ref: "#/components/schemas/ValidationErrors" examples: validationErrors: summary: Invalid parameters value: message: Invalid parameters, please try again errors: name: Template name is required and must not be empty. html_part: Content must be html. message: summary: Bad request value: message: Template could not be created, please try again. "422": description: Unprocessable entity content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Template name is not unique. default: $ref: "#/components/responses/UnexpectedError" delete: tags: - templates operationId: deleteTemplate summary: Delete a template description: Delete a template. parameters: - $ref: "#/components/parameters/id" responses: "204": description: The template was deleted successfully. "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Invalid ID supplied. default: $ref: "#/components/responses/UnexpectedError" /campaigns: get: tags: - campaigns operationId: getCampaigns summary: List campaigns description: | Returns a list of campaigns in a paginated manner. Each object in the `collection` represents a Campaign. This endpoint should always return a result even if there are zero campaigns in the collection. parameters: - $ref: "#/components/parameters/perPage" - $ref: "#/components/parameters/endingBefore" - $ref: "#/components/parameters/startingAfter" - $ref: "#/components/parameters/scopes" responses: "200": description: OK content: application/json: schema: allOf: - $ref: "#/components/schemas/PaginationMeta" - type: object properties: collection: type: array items: $ref: "#/components/schemas/Campaign" "401": $ref: "#/components/responses/Unauthorized" default: $ref: "#/components/responses/UnexpectedError" post: tags: - campaigns operationId: addCampaign summary: Add a new campaign description: | Add a new campaign. When the campaign is firstly created, it has a `draft` status. After a campaign has been created it can either be sent, scheduled or deleted. In order to send a campaign you will need to connect your AWS account. requestBody: $ref: "#/components/requestBodies/CampaignParams" responses: "201": description: OK content: application/json: schema: $ref: "#/components/schemas/Campaign" "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: oneOf: - $ref: "#/components/schemas/Message" - $ref: "#/components/schemas/ValidationErrors" examples: validationErrors: summary: Invalid parameters value: message: Invalid parameters, please try again errors: name: Campaign name is required and must not be empty. message: summary: Bad request value: message: Campaign could not be created, please try again. "422": description: Unprocessable entity content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Campaign name is not unique. default: $ref: "#/components/responses/UnexpectedError" /campaigns/{id}: get: tags: - campaigns operationId: getCampaign summary: Get campaign by ID description: Returns a single campaign object parameters: - $ref: "#/components/parameters/id" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Campaign" "401": $ref: "#/components/responses/Unauthorized" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Campaign not found. default: $ref: "#/components/responses/UnexpectedError" put: tags: - campaigns operationId: updateCampaign summary: Update an existing campaign description: Update an existing campaign parameters: - $ref: "#/components/parameters/id" requestBody: $ref: "#/components/requestBodies/CampaignParams" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Campaign" "401": $ref: "#/components/responses/Unauthorized" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Campaign not found. "400": description: Bad request content: application/json: schema: oneOf: - $ref: "#/components/schemas/Message" - $ref: "#/components/schemas/ValidationErrors" examples: validationErrors: summary: Invalid parameters value: message: Invalid parameters, please try again errors: name: Campaign name is required and must not be empty. template_name: Template name is required and must not be empty. message: summary: Bad request value: message: Campaign could not be created, please try again. "422": description: Unprocessable entity content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Campaign with that name already exist. default: $ref: "#/components/responses/UnexpectedError" delete: tags: - campaigns operationId: deleteCampaign summary: Delete a campaign description: Delete a campaign. parameters: - $ref: "#/components/parameters/id" responses: "204": description: The campaign was deleted successfully. "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Invalid ID supplied. default: $ref: "#/components/responses/UnexpectedError" /campaigns/{id}/start: post: tags: - campaigns operationId: startCampaign summary: Start a campaign description: Start a campaign. This action will begin sending the e-mails to subscribers immediately. parameters: - $ref: "#/components/parameters/id" requestBody: $ref: "#/components/requestBodies/StartCampaignParams" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Message" example: message: The campaign has started. You can track the progress in the campaign details page. "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Invalid ID supplied. default: $ref: "#/components/responses/UnexpectedError" /campaigns/{id}/schedule: parameters: - $ref: "#/components/parameters/id" patch: tags: - campaigns operationId: scheduleCampaign summary: Schedule a campaign description: Schedule a campaign. requestBody: $ref: "#/components/requestBodies/ScheduleCampaignParams" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Message" example: message: The campaign was successfully scheduled. "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Invalid ID supplied. default: $ref: "#/components/responses/UnexpectedError" delete: tags: - campaigns operationId: deleteCampaignSchedule summary: Delete a campaign's schedule description: Delete a campaign's schedule. responses: "204": description: The campaign's schedule was deleted successfully. "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Invalid ID supplied. default: $ref: "#/components/responses/UnexpectedError" /subscribers: get: tags: - subscribers operationId: getSubscribers summary: List subscribers description: | Returns a list of subscribers in a paginated manner. Each object in the `collection` represents a Subscriber. This endpoint should always return a result even if there are zero subscribers in the collection. parameters: - $ref: "#/components/parameters/perPage" - $ref: "#/components/parameters/endingBefore" - $ref: "#/components/parameters/startingAfter" - $ref: "#/components/parameters/scopes" responses: "200": description: OK content: application/json: schema: allOf: - $ref: "#/components/schemas/PaginationMeta" - type: object properties: collection: type: array items: $ref: "#/components/schemas/BaseSubscriber" "401": $ref: "#/components/responses/Unauthorized" default: $ref: "#/components/responses/UnexpectedError" post: tags: - subscribers operationId: addSubscriber summary: Add a new subscriber description: Add a new subscriber to the list. requestBody: $ref: "#/components/requestBodies/SubscriberParams" responses: "201": description: OK content: application/json: schema: $ref: "#/components/schemas/Subscriber" "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: oneOf: - $ref: "#/components/schemas/Message" - $ref: "#/components/schemas/ValidationErrors" examples: validationErrors: summary: Invalid parameters value: message: Invalid parameters, please try again errors: email: The email has an invalid format. message: summary: Bad request value: message: Subscriber could not be created, please try again. "422": description: Unprocessable entity content: application/json: schema: $ref: "#/components/schemas/Message" example: message: A subscriber with that email already exists. default: $ref: "#/components/responses/UnexpectedError" /subscribers/{id}: parameters: - $ref: "#/components/parameters/id" get: tags: - subscribers operationId: getSubscriber summary: Get subscriber by ID description: Returns a single subscriber object responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Subscriber" "401": $ref: "#/components/responses/Unauthorized" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Subscriber not found. default: $ref: "#/components/responses/UnexpectedError" put: tags: - subscribers operationId: updateSubscriber summary: Update an existing subscriber description: Update an existing subscriber. requestBody: $ref: "#/components/requestBodies/UpdateSubscriberParams" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Subscriber" "401": $ref: "#/components/responses/Unauthorized" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Subscriber not found. "400": description: Bad request content: application/json: schema: oneOf: - $ref: "#/components/schemas/Message" - $ref: "#/components/schemas/ValidationErrors" examples: validationErrors: summary: Invalid parameters value: message: Invalid parameters, please try again errors: name: The subscriber name is too long. message: summary: Bad request value: message: Subscriber could not be created, please try again. "422": description: Unprocessable entity content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Subscriber with that email already exist. default: $ref: "#/components/responses/UnexpectedError" delete: tags: - subscribers operationId: deleteSubscriber summary: Delete a subscriber description: Delete a subscriber. responses: "204": description: The subscriber was deleted successfully. "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Invalid ID supplied. default: $ref: "#/components/responses/UnexpectedError" /segments: get: tags: - groups operationId: getGroups summary: List groups description: | Returns a list of groups in a paginated manner. Each object in the `collection` represents a Group. This endpoint should always return a result even if there are zero groups in the collection. parameters: - $ref: "#/components/parameters/perPage" - $ref: "#/components/parameters/endingBefore" - $ref: "#/components/parameters/startingAfter" - $ref: "#/components/parameters/scopes" responses: "200": description: OK content: application/json: schema: allOf: - $ref: "#/components/schemas/PaginationMeta" - type: object properties: collection: type: array items: $ref: "#/components/schemas/Group" "401": $ref: "#/components/responses/Unauthorized" default: $ref: "#/components/responses/UnexpectedError" post: tags: - groups operationId: addGroup summary: Add a new group description: Add a new group. requestBody: $ref: "#/components/requestBodies/GroupParams" responses: "201": description: OK content: application/json: schema: $ref: "#/components/schemas/BaseGroup" "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: oneOf: - $ref: "#/components/schemas/Message" - $ref: "#/components/schemas/ValidationErrors" examples: validationErrors: summary: Invalid parameters value: message: Invalid parameters, please try again errors: name: The name is required and should not be empty. message: summary: Bad request value: message: Group could not be created, please try again. "422": description: Unprocessable entity content: application/json: schema: $ref: "#/components/schemas/Message" example: message: A group with that name already exists. default: $ref: "#/components/responses/UnexpectedError" /segments/{id}: parameters: - $ref: "#/components/parameters/id" get: tags: - groups operationId: getGroup summary: Get group by ID description: Returns a single group object responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/ExtendedGroupWithTotalSubs" "401": $ref: "#/components/responses/Unauthorized" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Group not found. default: $ref: "#/components/responses/UnexpectedError" put: tags: - groups operationId: updateGroup summary: Update an existing group description: Update an existing group. requestBody: $ref: "#/components/requestBodies/GroupParams" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/BaseGroup" "401": $ref: "#/components/responses/Unauthorized" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Group not found. "400": description: Bad request content: application/json: schema: oneOf: - $ref: "#/components/schemas/Message" - $ref: "#/components/schemas/ValidationErrors" examples: validationErrors: summary: Invalid parameters value: message: Invalid parameters, please try again errors: name: The group name is too long. message: summary: Bad request value: message: Group could not be created, please try again. "422": description: Unprocessable entity content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Group with that name already exist. default: $ref: "#/components/responses/UnexpectedError" delete: tags: - groups operationId: deleteGroup summary: Delete a group description: Delete a group. responses: "204": description: The group was deleted successfully. "401": $ref: "#/components/responses/Unauthorized" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/Message" example: message: Invalid ID supplied. default: $ref: "#/components/responses/UnexpectedError" security: - api_key: [] components: requestBodies: TemplateParams: description: Template parameters for the form content: application/json: schema: type: object required: - name - subject_part - html_part - text_part properties: name: type: string example: HelloWorld description: The name of the new template, must be unique. maxLength: 191 subject_part: type: string example: Welcome {{name}} to mailbadger.io! description: The subject part maxLength: 191 html_part: description: The HTML content used in the e-mail campaign. type: string example: