{"id":4623,"library":"mailjet-rest","title":"Mailjet REST API Client","description":"mailjet-rest is the official Python wrapper for the Mailjet Email API (v3 and v3.1). It simplifies sending transactional and marketing emails, managing contacts, and retrieving statistics. The library is currently at version 1.5.1 and receives regular updates and maintenance.","status":"active","version":"1.5.1","language":"en","source_language":"en","source_url":"https://github.com/mailjet/mailjet-apiv3-python","tags":["email","api client","transactional email","marketing email","mailjet"],"install":[{"cmd":"pip install mailjet-rest","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for making HTTP requests to the Mailjet API.","package":"requests","optional":false},{"reason":"Requires Python 3.10 or newer.","package":"python","optional":false}],"imports":[{"symbol":"Client","correct":"from mailjet_rest import Client"}],"quickstart":{"code":"import os\nfrom mailjet_rest import Client\n\n# Mailjet API keys can be found at https://app.mailjet.com/account/api_keys\n# It's highly recommended to store these in environment variables.\napi_key = os.environ.get('MJ_APIKEY_PUBLIC', 'your_public_api_key_here')\napi_secret = os.environ.get('MJ_APIKEY_PRIVATE', 'your_private_api_secret_here')\n\n# Initialize the Mailjet client, specifying API version v3.1 for the Send API.\nmailjet = Client(auth=(api_key, api_secret), version='v3.1')\n\n# Prepare the email data\ndata = {\n  'Messages': [\n    {\n      \"From\": {\n        \"Email\": \"pilot@mailjet.com\", # Must be a verified sender in your Mailjet account\n        \"Name\": \"Mailjet Pilot\"\n      },\n      \"To\": [\n        {\n          \"Email\": \"passenger@mailjet.com\",\n          \"Name\": \"Passenger 1\"\n        }\n      ],\n      \"Subject\": \"Your email flight plan!\",\n      \"TextPart\": \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\",\n      \"HTMLPart\": \"<h3>Dear passenger, welcome to <a href=\\\"https://www.mailjet.com/\\\">Mailjet</a>!</h3><br />May the delivery force be with you!\"\n    }\n  ]\n}\n\n# Send the email\nresult = mailjet.send.create(data=data)\n\n# Print the response status and content\nprint(f\"Status Code: {result.status_code}\")\nprint(f\"Response: {result.json()}\")\n\n# Check for common API errors\nif result.status_code >= 400:\n    print(f\"Error details: {result.json()}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the Mailjet client and send a basic email. Ensure your Mailjet API public and private keys are set as environment variables (MJ_APIKEY_PUBLIC, MJ_APIKEY_PRIVATE) or replaced with actual keys. The 'From' email address must be a verified sender in your Mailjet account. The example uses the v3.1 Send API for more robust messaging features."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or a later supported version.","message":"Support for Python 3.9 was dropped in mailjet-rest v1.5.0. Ensure your environment uses Python 3.10 or newer for full compatibility and continued updates.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Upgrade to mailjet-rest v1.5.0 or later to resolve CSV import issues.","message":"Prior to v1.5.0, users experienced `csvimport error 'List index (0) out of bounds'` when attempting CSV imports. This was fixed in v1.5.0.","severity":"gotcha","affected_versions":"<1.5.0"},{"fix":"Verify your API keys on your Mailjet account dashboard and ensure they are correctly configured in your application.","message":"Incorrect Mailjet API keys (public and private) will lead to `401 Unauthorized` errors. Always double-check your credentials and ensure they are active.","severity":"gotcha","affected_versions":"All"},{"fix":"Be aware that PUT operations are partial updates. Only include the fields you intend to modify in your payload.","message":"Mailjet API PUT requests behave like PATCH requests, meaning they only update the specified properties and do not overwrite the entire resource. Other existing properties will remain unchanged.","severity":"gotcha","affected_versions":"All"},{"fix":"Implement retry logic with exponential backoff and consider using batch sending for high volumes of emails to stay within rate limits.","message":"Mailjet's API has rate limits (e.g., typically 30 calls/second for some endpoints). Exceeding these limits will result in `429 Too Many Requests` errors.","severity":"gotcha","affected_versions":"All"},{"fix":"Choose either `Recipients` for individual, hidden messages or `To`/`Cc`/`Bcc` for group visibility, but do not combine them in a single send request.","message":"The `Recipients` property in the email payload sends a separate, individualized message to each recipient without revealing other recipients. In contrast, `To`, `Cc`, and `Bcc` will show other recipients as expected in a standard email client. Mixing `Recipients` with `To`, `Cc`, or `Bcc` is not allowed.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}