openapi: 3.1.0 security: - BearerAuth: [] info: title: Twilio SendGrid Mail Settings API summary: The Twilio SendGrid Mail Settings API allows you to retrieve and configure the various Mail Settings available. description: "The Twilio SendGrid Mail Settings API allows you to retrieve and configure\ \ the various Mail Settings available. Mail Settings instruct SendGrid to apply\ \ specific settings to every email that you send over [SendGrid\u2019s Web API](https://docs.sendgrid.com/api-reference/mail-send/v3-mail-send)\ \ or [SMTP relay](https://sendgrid.com/docs/for-developers/sending-email/building-an-x-smtpapi-header/).\ \ These settings include how to embed a custom footer, how to manage blocks, spam,\ \ and bounces, and more.\n\nFor a full list of Twilio SendGrid's Mail Settings,\ \ and what each one does, see [**Mail Settings**](https://sendgrid.com/docs/ui/account-and-settings/mail/).\n\ \nYou can also manage your Mail Settings in the Twilio SendGrid application user\ \ interface." termsOfService: https://www.twilio.com/legal/tos contact: name: Twilio SendGrid Support url: https://support.sendgrid.com/hc/en-us license: name: MIT url: https://code.hq.twilio.com/twilio/sendgrid-oas/blob/main/LICENSE version: 1.0.0 x-sendgrid: libraryPackage: mail_settings servers: - url: https://api.sendgrid.com description: for global users and subusers - url: https://api.eu.sendgrid.com description: for EU regional subusers paths: /v3/mail_settings: get: operationId: ListMailSetting summary: Retrieve all mail settings tags: - Mail Settings description: '**This endpoint allows you to retrieve a paginated list of all mail settings.** Each setting will be returned with an `enabled` status set to `true` or `false` and a short description that explains what the setting does. You can use the `limit` query parameter to set the page size. If your list contains more items than the page size permits, you can make multiple requests. Use the `offset` query parameter to control the position in the list from which to start retrieving additional items.' parameters: - name: limit in: query description: '`limit` sets the page size, i.e. maximum number of items from the list to be returned for a single API request. If omitted, the default page size is used.' schema: type: integer - $ref: '#/components/parameters/PaginationCommonOffset' - $ref: '#/components/parameters/OnBehalfOf' responses: '200': description: '' content: application/json: schema: type: object properties: result: type: array description: The list of all mail settings. items: type: object properties: title: type: string description: The title of the mail setting. enabled: type: boolean description: Indicates if this mail setting is currently enabled. name: type: string description: The name of the mail setting. description: type: string description: A description of the mail setting. required: - title - enabled - name - description required: - result examples: response: value: result: - title: Address Whitelist enabled: false name: address_whitelist description: Address / domains that should never have email suppressed. - title: Bounce Purge enabled: false name: bounce_purge description: Allows you to automatically purge bounce records from SendGrid after a specified number of days. - title: Event Notification enabled: true name: event_notify description: Controls notifications for events, such as bounces, clicks, and opens. - title: Footer enabled: false name: footer description: Allows you to add a custom footer to outgoing email. - title: Forward Bounce enabled: true name: forward_bounce description: Allows you to forward bounces to a specific email address. - title: Forward Spam enabled: false name: forward_spam description: Allows for a copy of spam reports to be forwarded to an email address. - title: Legacy Email Template enabled: true name: template description: Allows you to customize your outgoing HTML emails. - title: Plain Content enabled: false name: plain_content description: Convert your plain text emails to HTML. - title: Spam Checker enabled: true name: spam_check description: Check outbound messages for spam content. '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' /v3/mail_settings/address_whitelist: patch: operationId: UpdateAddressWhitelist summary: Update address whitelist mail settings tags: - Mail Settings description: '**This endpoint allows you to update your current email address whitelist settings.** You can select whether or not this setting should be enabled by assigning the `enabled` field a `true` or `false` value. Passing only the `enabled` field to this endpoint will not alter your current `list` of whitelist entries. However, any modifications to your `list` of entries will overwrite the entire list. For this reason, you must included all existing entries you wish to retain in your `list` in addition to any new entries you intend to add. To remove one or more `list` entries, pass a `list` with only the entries you wish to retain. You should not add generic domains such as `gmail.com` or `yahoo.com` in your `list` because your emails will not honor recipients'' unsubscribes. This may cause a legal violation of [CAN-SPAM](https://sendgrid.com/docs/glossary/can-spam/) and could damage your sending reputation. The Address Whitelist setting allows you to specify email addresses or domains for which mail should never be suppressed. For example, if you own the domain `example.com`, and one or more of your recipients use `email@example.com` addresses, placing `example.com` in the address whitelist setting instructs Twilio SendGrid to ignore all bounces, blocks, and unsubscribes logged for that domain. In other words, all bounces, blocks, and unsubscribes will still be sent to `example.com` as if they were sent under normal sending conditions.' parameters: - $ref: '#/components/parameters/OnBehalfOf' requestBody: content: application/json: schema: type: object properties: enabled: type: boolean description: Indicates if your email address whitelist is enabled. list: type: array description: Either a single email address that you want whitelisted or a domain, for which all email addresses belonging to this domain will be whitelisted. items: type: string example: enabled: true list: - email1@example.com - example.com responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsAddressWhitelabel200' examples: response: value: enabled: true list: - email1@example.com '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' get: operationId: ListAddressWhitelist summary: Retrieve address whitelist mail settings tags: - Mail Settings description: '**This endpoint allows you to retrieve your current email address whitelist settings.** The Address Whitelist setting allows you to specify email addresses or domains for which mail should never be suppressed. For example, if you own the domain `example.com`, and one or more of your recipients use `email@example.com` addresses, placing `example.com` in the address whitelist setting instructs Twilio SendGrid to ignore all bounces, blocks, and unsubscribes logged for that domain. In other words, all bounces, blocks, and unsubscribes will still be sent to `example.com` as if they were sent under normal sending conditions.' parameters: - $ref: '#/components/parameters/OnBehalfOf' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsAddressWhitelabel200' examples: response: value: enabled: true list: - example.com - jane_doe@example1.com '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' /v3/mail_settings/bounce_purge: patch: operationId: UpdateBouncePurge summary: Update Bounce Purge Mail Settings tags: - Mail Settings description: '**This endpoint allows you to update your current Bounce Purge mail settings.** The Bounce Purge mail metting allows you to configure the maximum age of contacts in your hard and soft bounce suppressions lists. All contacts older than their respective configured age are deleted. A hard bounce occurs when an email message has been returned to the sender because the recipient''s address is invalid. A hard bounce might occur because the domain name doesn''t exist or because the recipient is unknown. A soft bounce occurs when an email message reaches the recipient''s mail server but is bounced back undelivered before it actually reaches the recipient. A soft bounce might occur because the recipient''s inbox is full. You can also manage this setting in the [Mail Settings section of the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings). You can manage your bounces manually using the [Bounces API](https://docs.sendgrid.com/api-reference/bounces-api) or the [Bounces menu in the Twilio SendGrid App](https://app.sendgrid.com/suppressions/bounces).' parameters: - $ref: '#/components/parameters/OnBehalfOf' requestBody: content: application/json: schema: $ref: '#/components/schemas/MailSettingsBouncePurge' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsBouncePurge' examples: response: value: enabled: false hard_bounces: 5 soft_bounces: 5 '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' get: operationId: ListBouncePurge summary: Retrieve Bounce Purge Mail Settings tags: - Mail Settings description: '**This endpoint allows you to retrieve your current Bounce Purge mail settings.** The Bounce Purge mail setting allows you to configure the maximum age of contacts in your hard and soft bounce suppressions lists. All contacts older than their respective configured age are deleted. A hard bounce occurs when an email message has been returned to the sender because the recipient''s address is invalid. A hard bounce might occur because the domain name doesn''t exist or because the recipient is unknown. A soft bounce occurs when an email message reaches the recipient''s mail server but is bounced back undelivered before it actually reaches the recipient. A soft bounce might occur because the recipient''s inbox is full. You can also manage this setting in the [Mail Settings section of the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings). You can manage your bounces manually using the [Bounces API](https://docs.sendgrid.com/api-reference/bounces-api) or the [Bounces menu in the Twilio SendGrid App](https://app.sendgrid.com/suppressions/bounces).' parameters: - $ref: '#/components/parameters/OnBehalfOf' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsBouncePurge' examples: response: value: enabled: false soft_bounces: 5 hard_bounces: 5 '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' /v3/mail_settings/footer: patch: operationId: UpdateFooter summary: Update footer mail settings tags: - Mail Settings description: '**This endpoint allows you to update your current Footer mail settings.** The Footer setting will insert a custom footer at the bottom of your text and HTML email message bodies. You can insert your HTML or plain text directly using this endpoint, or you can create the footer using the [Mail Settings menu in the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings).' parameters: - $ref: '#/components/parameters/OnBehalfOf' requestBody: content: application/json: schema: $ref: '#/components/schemas/MailSettingsFooter' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsFooter' examples: response: value: enabled: true html_content: '
' plain_content: '' '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' get: operationId: ListFooter summary: Retrieve footer mail settings tags: - Mail Settings description: '**This endpoint allows you to retrieve your current Footer mail settings.** The Footer setting will insert a custom footer at the bottom of your text and HTML email message bodies. You can insert your HTML or plain text directly using the "Update footer mail settings" endpoint, or you can create the footer using the [Mail Settings menu in the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings).' parameters: - $ref: '#/components/parameters/OnBehalfOf' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsFooter' examples: response: value: enabled: true html_content: ' ' plain_content: '' '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' /v3/mail_settings/forward_bounce: patch: operationId: UpdateForwardBounce summary: Update forward bounce mail settings tags: - Mail Settings description: '**This endpoint allows you to update your current bounce forwarding mail settings.** Enabling the Forward Bounce setting allows you to specify an `email` address to which bounce reports will be forwarded. You can also configure the Forward Spam mail settings in the [Mail Settings section of the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings).' parameters: - $ref: '#/components/parameters/OnBehalfOf' requestBody: content: application/json: schema: $ref: '#/components/schemas/MailSettingsForwardBounce' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsForwardBounce' examples: response: value: email: bounces@example.com enabled: true '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' get: operationId: ListForwardBounce summary: Retrieve forward bounce mail settings tags: - Mail Settings description: '**This endpoint allows you to retrieve your current bounce forwarding mail settings.** Enabling the Forward Bounce setting allows you to specify `email` addresses to which bounce reports will be forwarded. This endpoint returns the email address you have set to receive forwarded bounces and an `enabled` status indicating if the setting is active.' parameters: - $ref: '#/components/parameters/OnBehalfOf' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsForwardBounce' examples: response: value: enabled: true email: bounces@example.com '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' /v3/mail_settings/forward_spam: patch: operationId: UpdateForwardSpam summary: Update forward spam mail settings tags: - Mail Settings description: "**This endpoint allows you to update your current Forward Spam\ \ mail settings.**\n\nEnabling the Forward Spam setting allows you to specify\ \ `email` addresses to which spam reports will be forwarded. You can set multiple\ \ addresses by passing this endpoint a comma separated list of emails in a\ \ single string.\n\n```\n{\n \"email\": \"address1@example.com, address2@exapmle.com\"\ ,\n \"enabled\": true\n}\n```\n\nThe Forward Spam setting may also be used\ \ to receive emails sent to `abuse@` and `postmaster@` role addresses if you\ \ have authenticated your domain.\n\nFor example, if you authenticated `example.com`\ \ as your root domain and set a custom return path of `sub` for that domain,\ \ you could turn on Forward Spam, and any emails sent to `abuse@sub.example.com`\ \ or `postmaster@sub.example.com` would be forwarded to the email address\ \ you entered in the `email` field.\n\nYou can authenticate your domain using\ \ the \"Authenticate a domain\" endpoint or in the [Sender Authentication\ \ section of the Twilio SendGrid App](https://app.sendgrid.com/settings/sender_auth).\ \ You can also configure the Forward Spam mail settings in the [Mail Settings\ \ section of the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings)." parameters: - $ref: '#/components/parameters/OnBehalfOf' requestBody: content: application/json: schema: $ref: '#/components/schemas/MailSettingsForwardSpam' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsForwardSpam' examples: response: value: email: abuse@example.com enabled: true '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' get: operationId: ListForwardSpam summary: Retrieve forward spam mail settings tags: - Mail Settings description: '**This endpoint allows you to retrieve your current Forward Spam mail settings.** Enabling the Forward Spam setting allows you to specify `email` addresses to which spam reports will be forwarded. This endpoint returns any email address(es) you have set to receive forwarded spam and an `enabled` status indicating if the setting is active.' parameters: - $ref: '#/components/parameters/OnBehalfOf' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsForwardSpam' examples: response: value: email: abuse@example.com enabled: true '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' /v3/mail_settings/template: patch: operationId: UpdateTemplate summary: Update template mail settings tags: - Mail Settings description: '**This endpoint allows you to update your current legacy email template settings.** This setting refers to our original email templates. We currently support more fully featured [Dynamic Transactional Templates](https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/). The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages. For instructions on using legacy templates, see how to ["Create and Edit Legacy Transactional Templates](https://sendgrid.com/docs/ui/sending-email/create-and-edit-legacy-transactional-templates/). For help migrating to our current template system, see ["Migrating from Legacy Templates"](https://sendgrid.com/docs/ui/sending-email/migrating-from-legacy-templates/).' parameters: - $ref: '#/components/parameters/OnBehalfOf' requestBody: content: application/json: schema: type: object properties: enabled: type: boolean description: Indicates if you want to enable the legacy email template mail setting. html_content: type: string description: The new HTML content for your legacy email template. example: enabled: true html_content: <% body %> responses: '200': description: '' content: application/json: schema: type: object properties: enabled: type: boolean description: Indicates if the legacy email template mail setting is enabled. html_content: type: string description: The HTML content of your legacy email template. required: - enabled - html_content examples: response: value: enabled: false html_content: '<% body %>Example
' '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' get: operationId: ListTemplate summary: Retrieve legacy template mail settings tags: - Mail Settings description: '**This endpoint allows you to retrieve your current legacy email template settings.** This setting refers to our original email templates. We currently support more fully featured [Dynamic Transactional Templates](https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/). The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages. For instructions on using legacy templates, see how to ["Create and Edit Legacy Transactional Templates](https://sendgrid.com/docs/ui/sending-email/create-and-edit-legacy-transactional-templates/). For help migrating to our current template system, see ["Migrating from Legacy Templates"](https://sendgrid.com/docs/ui/sending-email/migrating-from-legacy-templates/).' parameters: - $ref: '#/components/parameters/OnBehalfOf' responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MailSettingsTemplate200' examples: response: value: enabled: false html_content: '<% body %>Example
' '400': $ref: '#/components/responses/MailSettingsError400' '401': $ref: '#/components/responses/MailSettingsError401' '403': $ref: '#/components/responses/MailSettingsError403' '404': $ref: '#/components/responses/MailSettingsError404' '500': $ref: '#/components/responses/MailSettingsError500' components: schemas: MailSettingsAddressWhitelabel200: title: 'Mail Settings: Address Whitelabel' type: object properties: enabled: type: boolean description: 'Indicates if you have an email address whitelist enabled. ' list: type: array description: All email addresses that are currently on the whitelist. items: type: string example: enabled: true list: - email1@example.com - example.com MailSettingsBouncePurge: title: 'Mail Settings: Bounce Purge' type: object properties: enabled: type: boolean description: Indicates if the Bounce Purge mail setting is enabled. soft_bounces: description: The number of days after which SendGrid will purge all contacts from your soft bounces suppression lists. nullable: true type: integer hard_bounces: description: The number of days after which SendGrid will purge all contacts from your hard bounces suppression lists. nullable: true type: integer example: enabled: false soft_bounces: 1234 hard_bounces: 1234 MailSettingsFooter: title: 'Mail Settings: Footer' type: object properties: enabled: type: boolean description: Indicates if the Footer mail setting is currently enabled. html_content: type: string description: The custom HTML content of your email footer. plain_content: type: string description: The plain text content of your email footer. example: enabled: true html_content: Example HTML content plain_content: Example plain content MailSettingsForwardBounce: title: 'Mail Settings: Forward Bounce' type: object properties: email: description: The email address that you would like your bounce reports forwarded to. nullable: true type: string enabled: type: boolean description: Indicates if the bounce forwarding mail setting is enabled. example: enabled: false email: email@example.com MailSettingsForwardSpam: title: 'Mail Settings: Forward Spam' type: object properties: email: type: string description: The email address where you would like the spam reports to be forwarded. enabled: type: boolean description: Indicates if the Forward Spam setting is enabled. example: email: '' enabled: true MailSettingsTemplate200: title: 'Mail Settings: Template' type: object properties: enabled: type: boolean description: Indicates if the legacy email template setting is enabled. html_content: type: string description: The HTML content that you want to use for your legacy email template. example: enabled: false html_content: '<% body %>Example
' responses: MailSettingsError400: description: '' content: application/json: schema: type: object properties: errors: type: array items: type: object properties: error_id: type: string description: The ID associated with the error. field: description: The field that generated the error. nullable: true type: string message: type: string description: The error message. parameter: type: string required: - message MailSettingsError401: description: '' content: application/json: schema: type: object properties: errors: type: array items: type: object properties: error_id: type: string description: The ID associated with the error. field: description: The field that generated the error. nullable: true type: string message: type: string description: The error message. parameter: type: string required: - message MailSettingsError403: description: '' content: application/json: schema: type: object properties: errors: type: array items: type: object properties: error_id: type: string description: The ID associated with the error. field: description: The field that generated the error. nullable: true type: string message: type: string description: The error message. parameter: type: string required: - message MailSettingsError404: description: '' content: application/json: schema: type: object properties: errors: type: array items: type: object properties: error_id: type: string description: The ID associated with the error. field: description: The field that generated the error. nullable: true type: string message: type: string description: The error message. parameter: type: string required: - message MailSettingsError500: description: '' content: application/json: schema: type: object properties: errors: type: array items: type: object properties: error_id: type: string description: The ID associated with the error. field: description: The field that generated the error. nullable: true type: string message: type: string description: The error message. parameter: type: string required: - message parameters: OnBehalfOf: name: on-behalf-of in: header description: '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