ACTIONS
  • Home
  • My Actions
  • My Projects
  • My Packages
Postmark -> Send Email With Template
Function Documentation: Postmark → Send Email with Template

Action summary

Postmark -> Send Email With Template

Xano

Function Documentation: Postmark → Send Email with Template

Overview

This function allows you to send emails using the Postmark API with a pre-defined template. You can specify the recipient email address, the template ID, and the data to populate the template placeholders.

Inputs

  1. postmark_base_url (registry|text) Required
    • Description: The base url for calling the Postmark API (e.g., "https://api.postmarkapp.com/").
  2. postmark_server_token (registry|text) Required Sensitive data
    • Description: This is the Postmark Server API Token (e.g., "14g8dce4-7054-47c9-a18a-2107e5cf4e41"). This is needed for authentication on endpoints.
  3. from_email (text) Required
    • Description: The email address that will appear as the sender.
    • Example: noreply@yourdomain.com
  4. to_emails (text) Required
    • Description: A list of email addresses to send the batch emails to.
    • Example: user1@example.com
  5. template_id (integer) Required
    • Description: The ID of the Postmark template to use.
    • Example: 12345
  6. template_model (json) Required
    • Description: The data to populate the template placeholders. The structure of this data depends on your specific Postmark template.
    • Example: Refer to Postmark documentation for template data structure.

Function Stack

1. Create Variable:

  • Create Variable: api_url
  • Purpose: Constructs the API URL for sending emails with templates.

2. Create Variable:

  • Create Variable: api_token
  • Purpose: Stores the Postmark API token.

3. Precondition:

  1. Precondition: from_email should not exceed 255 characters.
    • Purpose: Ensures the sender email address is not too long.
  2. Precondition: from_email is a valid email format.
    • Purpose: Ensures the sender email address is formatted correctly.
  3. Precondition: to_email is a valid email format and allows comma-separated values.
    • Purpose: Ensures recipient email addresses are formatted correctly and the list is not too long.
  4. Precondition: to_email should not exceed 50 email addresses.
    • Purpose: Limits the number of recipients per batch.

4. Postmask API Request:

  • API Request to: https://api.postmarkapp.com/email
  • Purpose: Sends a POST request to the api_url with the following payload:
{
  "from_email": "noreply@yourdomain.com",
  "to_email": "user@example.com",
  "template_id": 12345,
  "template_model": {
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
}

5. Create Variable:

  • Create Variable: postmark_response
  • Purpose: Stores the response from the Postmark API.

6. Create Variable:

  • Create Variable: response
  • Purpose: Creates a response object with the result from the Postmark API.

Response

  • The function returns the result from the Postmark API response.

Success response

{
  "To": "user1@example.com",
  "SubmittedAt": "2024-10-07T14:33:15.817Z",
  "MessageID": "message-id-1",
  "ErrorCode": 0,
  "Message": "OK"
},
{
  "To": "user2@example.com",
  "SubmittedAt": "2024-10-07T14:33:15.817Z",
  "MessageID": "message-id-2",
  "ErrorCode": 0,
  "Message": "OK"
}

Error response

{
    "ErrorCode": 401,
    "Message": "Unauthorized: Missing or incorrect API key."
}

Example

Input

{
  "from_email": "noreply@yourdomain.com",
  "to_email": "user@example.com",
  "template_id": 12345,
  "template_model": {
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
}

Output

{
  "To": "user@example.com",
  "SubmittedAt": "2024-10-07T14:33:15.817Z",
  "MessageID": "message-id-1",
  "ErrorCode": 0,
  "Message": "OK"
}

Version notes

2024-10-09 17:51:55
Current
2024-10-09T12:22:23.000+00:00

Function Documentation: Postmark → Send Email with Template

Overview

This function allows you to send emails using the Postmark API with a pre-defined template. You can specify the recipient email address, the template ID, and the data to populate the template placeholders.

Inputs

  1. postmark_base_url (registry|text) Required
    • Description: The base url for calling the Postmark API (e.g., "https://api.postmarkapp.com/").
  2. postmark_server_token (registry|text) Required Sensitive data
    • Description: This is the Postmark Server API Token (e.g., "14g8dce4-7054-47c9-a18a-2107e5cf4e41"). This is needed for authentication on endpoints.
  3. from_email (text) Required
    • Description: The email address that will appear as the sender.
    • Example: noreply@yourdomain.com
  4. to_emails (text) Required
    • Description: A list of email addresses to send the batch emails to.
    • Example: user1@example.com
  5. template_id (integer) Required
    • Description: The ID of the Postmark template to use.
    • Example: 12345
  6. template_model (json) Required
    • Description: The data to populate the template placeholders. The structure of this data depends on your specific Postmark template.
    • Example: Refer to Postmark documentation for template data structure.

Function Stack

1. Create Variable:

  • Create Variable: api_url
  • Purpose: Constructs the API URL for sending emails with templates.

2. Create Variable:

  • Create Variable: api_token
  • Purpose: Stores the Postmark API token.

3. Precondition:

  1. Precondition: from_email should not exceed 255 characters.
    • Purpose: Ensures the sender email address is not too long.
  2. Precondition: from_email is a valid email format.
    • Purpose: Ensures the sender email address is formatted correctly.
  3. Precondition: to_email is a valid email format and allows comma-separated values.
    • Purpose: Ensures recipient email addresses are formatted correctly and the list is not too long.
  4. Precondition: to_email should not exceed 50 email addresses.
    • Purpose: Limits the number of recipients per batch.

4. Postmask API Request:

  • API Request to: https://api.postmarkapp.com/email
  • Purpose: Sends a POST request to the api_url with the following payload:
{
  "from_email": "noreply@yourdomain.com",
  "to_email": "user@example.com",
  "template_id": 12345,
  "template_model": {
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
}

5. Create Variable:

  • Create Variable: postmark_response
  • Purpose: Stores the response from the Postmark API.

6. Create Variable:

  • Create Variable: response
  • Purpose: Creates a response object with the result from the Postmark API.

Response

  • The function returns the result from the Postmark API response.

Success response

{
  "To": "user1@example.com",
  "SubmittedAt": "2024-10-07T14:33:15.817Z",
  "MessageID": "message-id-1",
  "ErrorCode": 0,
  "Message": "OK"
},
{
  "To": "user2@example.com",
  "SubmittedAt": "2024-10-07T14:33:15.817Z",
  "MessageID": "message-id-2",
  "ErrorCode": 0,
  "Message": "OK"
}

Error response

{
    "ErrorCode": 401,
    "Message": "Unauthorized: Missing or incorrect API key."
}

Example

Input

{
  "from_email": "noreply@yourdomain.com",
  "to_email": "user@example.com",
  "template_id": 12345,
  "template_model": {
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
}

Output

{
  "To": "user@example.com",
  "SubmittedAt": "2024-10-07T14:33:15.817Z",
  "MessageID": "message-id-1",
  "ErrorCode": 0,
  "Message": "OK"
}