Back

Mailjet API Essential Guide

Aug 14, 20246 minute read

What type of API does Mailjet provide?

Based on the search results provided, there is no specific information about Mailjet's API type. The search results discuss different API types like REST, GraphQL and SOAP in general, but do not mention Mailjet specifically.

To answer this question accurately, we would need to look at Mailjet's official documentation or other sources with information about their specific API. Without that information, I cannot definitively state what type of API Mailjet uses.

If you need to know Mailjet's API type, I would recommend checking their official API documentation or developer resources. Many modern APIs tend to use REST or GraphQL, but without confirming from an authoritative source, I cannot say for certain which type Mailjet implements.

Does the Mailjet API have webhooks?

Webhook Availability

Yes, the official Mailjet API does have webhook functionality.

Types of Events

Mailjet allows you to subscribe to the following types of email events via webhooks:

  • Sent
  • Open
  • Click
  • Bounce
  • Block
  • Spam
  • Unsubscribe

How Mailjet Processes Webhooks

  • Mailjet sends real-time notifications to your specified URL when email events occur.
  • You can receive each open, click, bounce, and block event right after it happens.
  • This allows you to detect issues immediately and take action, like if a high percentage of emails to a destination are blocked.

Setting Up Webhooks

There are two ways to set up webhooks with Mailjet:

  1. Using the Mailjet interface:

    • Log in to app.mailjet.com
    • Go to "Account settings"
    • Add one webhook for all events or set up specific ones for each event type
  2. Using the Mailjet API:

    • Make an API call to set up the URL you want to use

Key Points to Consider

  • Webhooks allow for real-time notifications and automated workflows.
  • You can use webhook data to create personalized dashboards or trigger automated email flows.
  • Mailjet attempts to deliver webhook notifications multiple times if the initial attempt fails.
  • You can group webhook events for high-volume senders to avoid overwhelming your systems.

Best Practices

  • Use real events for testing purposes rather than relying on the "Send test" function in the interface.
  • Monitor your webhook for any responses other than a 200 OK.
  • For high-volume senders, consider grouping webhook events (e.g., one notification per 10K emails sent).
  • Ensure your webhook endpoint is publicly accessible and belongs to your receiving system.

In summary, Mailjet offers comprehensive webhook functionality that allows you to receive real-time notifications for various email events, enabling you to create custom workflows, automate processes, and stay informed about your email campaign performance.

Rate Limits and other limitations

The Mailjet API has several rate limits that developers need to be aware of when integrating with the service. Here are the key points regarding Mailjet's API rate limits:

General API Rate Limits

  • Mailjet imposes rate limits on the number of API calls allowed per API key per second ^4.
  • If you exceed the rate limit, the API will return a 429 HTTP error code ^4.

Email Sending Rate Limits

  • Mailjet has sending limits in place to protect their infrastructure and maintain a good reputation for all users ^3.
  • These limits are based on factors such as account age, sending history, and reputation ^3.
  • New accounts typically start with lower limits that increase over time as the account establishes a good sending reputation ^3.

SMS API Rate Limits

  • The SMS API has a default limit of 6 requests per second ^2.
  • This limit applies to both single and bulk SMS sending ^2.
  • If you exceed this limit, you'll receive a 429 "Too Many Requests" error ^2.

Best Practices

  1. Implement proper error handling in your code to catch and respond to 429 errors ^4.
  2. Use exponential backoff when retrying after receiving a rate limit error ^2.
  3. If you consistently hit rate limits, consider spreading out your API calls over time or contacting Mailjet support for potential limit increases ^2.
  4. Monitor your API usage to stay within the limits and avoid disruptions to your service ^4.

Additional Considerations

  • Rate limits may vary depending on your Mailjet plan and account status ^3.
  • Mailjet may adjust rate limits without notice to protect their infrastructure ^2.
  • For high-volume senders, Mailjet offers options to increase limits based on your needs and sending patterns ^3.

It's important to note that these rate limits are subject to change, and it's always best to refer to the official Mailjet documentation for the most up-to-date information on API rate limits and best practices for working within these constraints.

Latest API Version

Based on the search results provided, here are the key points about the most recent version of the Mailjet API:

API Versions

The Mailjet API has multiple versions:

  • v3: The Email API
  • v3.1: Email Send API v3.1, which is the latest version of the Send API
  • v4: SMS API, contacts delete API, etc.

Latest Version for Email Sending

The most recent version for sending emails is v3.1. Specifically, the search results state:

"v3.1 : ApiVersion.V3_1 - Email Send API v3.1, which is the latest version of our Send API"

Client Wrapper Behavior

The client wrapper will automatically determine which API version to call under the hood.

Key Points

  • The base URL for the Mailjet API is https://api.mailjet.com, but this can be customized if needed.
  • Authentication uses API and Secret keys for the Email API.
  • The SMS API uses token-based authentication instead.
  • The latest version (v3.1) is used specifically for the Email Send functionality.

Best Practices

  • Use the latest v3.1 version for sending emails to take advantage of the most up-to-date features.
  • Let the client wrapper handle API version selection automatically when possible.
  • Ensure you're using the correct authentication method depending on whether you're using the Email API or SMS API.

In summary, while Mailjet has multiple API versions for different purposes, the most recent version specifically for sending emails is v3.1.

How to get a Mailjet developer account and API Keys?

To get a developer account for Mailjet and create an API integration, follow these steps:

  1. Sign up for a Mailjet account:

    • Visit the Mailjet website (www.mailjet.com)
    • Click on the "Sign Up" or "Get Started" button
    • Fill in the required information to create your account
  2. Access the API section:

    • Once logged in, navigate to the API section of your Mailjet dashboard
  3. Generate API keys:

    • In the API section, you'll find options to generate API keys
    • Mailjet typically provides two types of keys: API Key and Secret Key
  4. Choose your integration method:

    • Mailjet offers multiple ways to integrate their API:
      • RESTful API
      • SMTP relay
      • Ready-to-use libraries for various programming languages (PHP, Ruby, Python, C#, Java, Node.js, etc.)
  5. Review the documentation:

    • Mailjet provides comprehensive API documentation to help you get started
    • Familiarize yourself with the available endpoints and functionalities

What can you do with the Mailjet API?

Here are the main data models you can interact with using the Mailjet API, along with key capabilities for each:

Contacts

  • Create new contacts
  • Update existing contact information
  • Delete contacts
  • Retrieve contact details
  • Manage contact properties/attributes
  • Add contacts to lists
  • Remove contacts from lists

Contact Lists

  • Create new contact lists
  • Update list details
  • Delete lists
  • Retrieve list information
  • Add/remove contacts to/from lists
  • Manage list properties

Campaigns

  • Create email campaigns
  • Update campaign details
  • Delete campaigns
  • Retrieve campaign information
  • Schedule campaigns
  • Send test emails
  • Trigger campaign sending

Templates

  • Create email templates
  • Update template content and settings
  • Delete templates
  • Retrieve template details
  • Use templates in campaigns

Statistics

  • Retrieve sending statistics (opens, clicks, bounces, etc.)
  • Get campaign performance metrics
  • Access contact engagement data

Sender Addresses/Domains

  • Add and verify sender email addresses
  • Add and verify sender domains
  • Manage SPF/DKIM settings

API Keys

  • Create API keys
  • Manage API key permissions
  • Delete API keys

Webhooks

  • Create webhooks for events (opens, clicks, bounces, etc.)
  • Update webhook settings
  • Delete webhooks

Transactional Emails

  • Send single transactional emails
  • Retrieve transactional email details
  • Access transactional email statistics

This covers the core data models and capabilities exposed through the Mailjet API. The API allows you to programmatically manage your email marketing and transactional email operations across these different entities.