{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Mailjet Python SDK","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Install and use the official Mailjet Python wrapper: authentication, sending with Send API v3.1, payload builders, pagination, security guardrails and the Content API.","image":"https://dev.mailjet.com/og-image.png","lang":"en-US","keywords":["Mailjet API","Email API","Content API","SMTP Relay","transactional email","email delivery","Send API","email templates","developer documentation"],"meta":[{"name":"og:type","content":"website"},{"name":"og:site_name","content":"Mailjet Developer Documentation"},{"name":"twitter:card","content":"summary_large_image"},{"name":"robots","content":"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"},{"name":"googlebot","content":"index, follow, max-snippet:-1, max-image-preview:large"}],"jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://dev.mailjet.com/#organization","name":"Mailjet","alternateName":"Sinch Mailjet","url":"https://www.mailjet.com","logo":"https://assets.mailjet.com/lib/images/mailjetLogo/mj_logo_with_text_color.png","parentOrganization":{"@type":"Organization","name":"Sinch","url":"https://www.sinch.com"}},{"@type":"WebSite","@id":"https://dev.mailjet.com/#website","name":"Mailjet Developer Documentation","description":"Official developer documentation for the Mailjet Email API, Content API and SMTP Relay.","url":"https://dev.mailjet.com/","inLanguage":"en-US","publisher":{"@id":"https://dev.mailjet.com/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://dev.mailjet.com/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]},"llmstxt":{"hide":false,"title":"Mailjet Developer Documentation","description":"Developer documentation for the Mailjet Email API, Content API and SMTP Relay - guides, API references and code samples for sending, templating and tracking email at scale.","details":{"content":"Mailjet (part of Sinch) provides APIs for sending and managing email.\n\nThis documentation covers four main areas:\n\n- **Email API** - the Send API (v3 and v3.1) for transactional and marketing email,\n  plus contact management, segmentation, campaigns, statistics, webhooks, the Parse API\n  and the Mailjet Templating Language.\n- **Content API** - programmatic management of email templates, template contents,\n  images, labels and authentication tokens (v1).\n- **SMTP Relay** - sending through Mailjet's SMTP servers, including custom headers.\n- **API Reference** - the complete, generated reference for every endpoint, built directly\n  from the OpenAPI specifications.\n\nBase URL for all REST APIs: `https://api.mailjet.com`.\nAuthentication uses HTTP Basic auth with an API key and secret key.\n\n## Machine-readable entry points\n\nPrefer these when you need the API surface in as few requests as possible:\n\n- `/openapi/openapi-mailjet.md` - the **complete** Email API reference (every endpoint,\n  grouped by resource) as a single Markdown document.\n- `/openapi/openapi-passport.md` - the **complete** Content API reference as a single\n  Markdown document.\n- `/_bundle/openapi/openapi-mailjet.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Email API.\n- `/_bundle/openapi/openapi-passport.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Content API.\n- `/sitemap.xml` - every indexable URL on this site.\n\nEvery page on this site is also available as clean Markdown by appending `.md` to its URL."},"sections":[{"title":"Email API","description":"Sending, contacts, campaigns, statistics, webhooks and templating.","includeFiles":["docs/email-api/**/*.md"],"excludeFiles":[]},{"title":"Content API","description":"Manage templates, template contents, images, labels and tokens.","includeFiles":["docs/content-api/**/*.md","docs/content-api.md"],"excludeFiles":[]},{"title":"SMTP Relay","description":"Send email through Mailjet's SMTP servers.","includeFiles":["docs/smtp-relay/**/*.md"],"excludeFiles":[]},{"title":"API Reference","description":"Complete generated reference for every Mailjet API endpoint.","includeFiles":["openapi/openapi-mailjet.yaml","openapi/openapi-passport.yaml","docs/api-reference/**/*.md"],"excludeFiles":[]},{"title":"Migrating from Mandrill","description":"Guides for switching from Mandrill to Mailjet.","includeFiles":["docs/mandrill/**/*.md"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"python-sdk","__idx":0},"children":["Python SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The official Python wrapper for the Mailjet API is published on PyPI as ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["mailjet-rest"]}]}," and developed at ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-python"},"children":["mailjet/mailjet-apiv3-python"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"compatibility","__idx":1},"children":["Compatibility"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Python ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[">= 3.10, < 3.15"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Runtime dependency: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requests >= 2.33.0"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Build backend: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setuptools"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["wheel"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setuptools-scm"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Test dependency: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pytest >= 9.0.3"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"installation","__idx":2},"children":["Installation"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"python -m venv venv\nsource venv/bin/activate\npip install mailjet-rest\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"from-source","__idx":3},"children":["From source"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"git clone https://github.com/mailjet/mailjet-apiv3-python\ncd mailjet-apiv3-python\npip install .\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On Unix platforms, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["conda"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["make"]}," are also supported:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"make install\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"for-development","__idx":4},"children":["For development"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# minimal environment\nmake dev\nconda activate mailjet\n\n# full dev environment\nmake dev-full\nconda activate mailjet-dev\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The repository also ships a management script that wraps the common tasks:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"./manage.sh env_setup     # conda environment and pre-commit hooks\n./manage.sh test_all      # unit and integration tests\n./manage.sh perf_bench    # performance profilers\n./manage.sh format        # formatting\n./manage.sh lint          # linting\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"authentication","__idx":5},"children":["Authentication"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"export MJ_APIKEY_PUBLIC='your api key'\nexport MJ_APIKEY_PRIVATE='your api secret'\nexport MJ_CONTENT_TOKEN='your bearer token'   # optional, Content API v1\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"quick-start","__idx":6},"children":["Quick start"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use the client as a context manager."]}," This pools and closes the underlying TCP connections for you and prevents resource leaks:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import os\nfrom mailjet_rest import Client\n\napi_key = os.environ.get(\"MJ_APIKEY_PUBLIC\", \"\")\napi_secret = os.environ.get(\"MJ_APIKEY_PRIVATE\", \"\")\n\nwith Client(auth=(api_key, api_secret), version=\"v3.1\") as mailjet:\n    data = {\n        \"Messages\": [\n            {\n                \"From\": {\"Email\": \"pilot@example.com\", \"Name\": \"Mailjet Pilot\"},\n                \"To\": [{\"Email\": \"passenger1@example.com\", \"Name\": \"Passenger 1\"}],\n                \"Subject\": \"Your email flight plan!\",\n                \"TextPart\": \"Welcome to Mailjet! May the delivery force be with you!\",\n            }\n        ]\n    }\n    result = mailjet.send.create(data=data)\n    print(result.status_code)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Warning:"]}," if you do not use the context manager, you ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["must"]}," call ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["mailjet.close()"]}," on shutdown to release the sockets."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"configuration","__idx":7},"children":["Configuration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Overrides can be passed when the client is created, or per call:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"with Client(\n    auth=(api_key, api_secret),\n    version=\"v3.1\",\n    api_url=\"https://api.us.mailjet.com/\",\n    timeout=30,\n) as mailjet:\n    # override the timeout for a single heavy request\n    result = mailjet.contact.get(timeout=60)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-versioning","__idx":8},"children":["API versioning"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Version"},"children":["Version"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Scope"},"children":["Scope"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Email API"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3.1"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Send API v3.1 (latest send version)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Content API — templates, blocks, images"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Most Email API endpoints sit under ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3"]},", which is the default. For anything else, set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["version"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"base-url","__idx":9},"children":["Base URL"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The default base domain is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["api.mailjet.com"]},". Accounts on Mailjet's ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["US architecture"]}," must set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.us.mailjet.com"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"with Client(auth=(api_key, api_secret), api_url=\"https://api.us.mailjet.com/\") as mailjet:\n    ...\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"building-resource-paths","__idx":10},"children":["Building resource paths"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Python identifiers cannot contain slashes or dashes, so paths are translated:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["replace a slash ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/"]}," with an underscore ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["_"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["replace a dash ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["-"]}," by capitalising the next letter"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["statistics/link-click"]}," therefore becomes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["statistics_linkClick"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"with Client(auth=(api_key, api_secret)) as mailjet:\n    filters = {\"CampaignId\": \"xxxxxxx\"}\n    result = mailjet.statistics_linkClick.get(filters=filters)\n    print(result.json())\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Content API (v1)"]},", sub-actions are routed with slashes (for example ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["contents/lock"]},"), and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data_images"]}," maps specifically to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/v1/data/images"]}," to support media uploads."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"error-handling","__idx":11},"children":["Error handling"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Network-level exceptions are wrapped. Standard HTTP errors such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["404"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["400"]}," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["do not"]}," raise — they return the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requests.Response"]}," so you can inspect ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status_code"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".json()"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from mailjet_rest import CriticalApiError, TimeoutError, ApiError\n\ntry:\n    result = mailjet.contact.get()\n    if result.status_code != 200:\n        print(f\"API Error: {result.status_code} - {result.text}\")\n\nexcept TimeoutError:\n    print(\"The request to the Mailjet API timed out.\")\nexcept CriticalApiError as e:\n    print(f\"Network connection failed: {e}\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"logging-and-debugging","__idx":12},"children":["Logging and debugging"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK plugs into the standard ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["logging"]}," library. If your payload carries identifiers such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CustomID"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Campaign"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TemplateID"]},", they are extracted automatically and injected into the log line as a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Trace"]}," context, so local errors can be correlated with your Mailjet dashboard analytics:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import logging\nfrom mailjet_rest import Client\n\nlogging.getLogger(\"mailjet_rest.client\").setLevel(logging.DEBUG)\nlogging.basicConfig(format=\"%(levelname)s - %(message)s\")\n\nwith Client(auth=(api_key, api_secret), version=\"v3.1\") as mailjet:\n    mailjet.send.create(\n        data={\n            \"Messages\": [\n                {\n                    \"From\": {\"Email\": \"pilot@example.com\"},\n                    \"To\": [{\"Email\": \"passenger@example.com\"}],\n                    \"CustomID\": \"Promo_Black_Friday\",\n                }\n            ]\n        }\n    )\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Console output includes the trace: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DEBUG - Sending Request: POST ... | Trace: [CustomID=Promo_Black_Friday]"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ide-autocompletion","__idx":13},"children":["IDE autocompletion"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK dispatches URLs dynamically through ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["__getattr__"]},". To avoid accidentally dispatching internal Python methods as API requests, accessing private attributes or removed properties (such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["client.auth"]},") raises an explicit ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AttributeError"]}," instead of firing a ghost request."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Because of that dynamic dispatch, type checkers may report endpoints like ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["client.contact.create"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Any"]},". Under strict typing you can safely ignore those specific calls."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"typed-payloads","__idx":14},"children":["Typed payloads"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"strict-payload-builders","__idx":15},"children":["Strict payload builders"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Import the TypedDict schemas for IDE autocomplete and static checking instead of debugging ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["400 Bad Request"]}," responses caused by a typo:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from mailjet_rest.types import SendV31Payload, SendV31Message\n\nmessage: SendV31Message = {\n    \"From\": {\"Email\": \"pilot@example.com\", \"Name\": \"Mailjet Pilot\"},\n    \"To\": [{\"Email\": \"passenger1@example.com\", \"Name\": \"Passenger 1\"}],\n    \"Subject\": \"Your flight plan!\",\n    \"TextPart\": \"Dear passenger, welcome to Mailjet!\",\n}\n\npayload: SendV31Payload = {\"Messages\": [message]}\n\nmailjet.send.create(data=payload)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"messagebuilder-and-sendpayloadbuilder","__idx":16},"children":["MessageBuilder and SendPayloadBuilder"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For complex messages, the fluent builders handle structure, attachment encoding and validation:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from mailjet_rest import Client\nfrom mailjet_rest.builders import MessageBuilder, SendPayloadBuilder\n\nmessage = (\n    MessageBuilder()\n    .set_sender(\"pilot@example.com\", \"Mailjet Pilot\")\n    .add_recipient(\"passenger@example.com\", \"John Doe\")\n    .add_cc(\"copilot@example.com\")\n    .set_subject(\"Your Boarding Pass\")\n    .set_content(html=\"<h3>Welcome aboard!</h3>\")\n    .attach_file(\"tickets/pass.pdf\")     # encoded via a memory-efficient chunked streamer\n    .attach_inline(\"assets/logo.png\")\n    .build()\n)\n\npayload = SendPayloadBuilder().add_message(message).set_sandbox_mode(True).build()\n\nwith Client(auth=(api_key, api_secret), version=\"v3.1\") as mailjet:\n    result = mailjet.send.create(data=payload)\n    print(result.status_code)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"send-api-examples","__idx":17},"children":["Send API examples"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"send-a-basic-email","__idx":18},"children":["Send a basic email"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"data = {\n    \"Messages\": [\n        {\n            \"From\": {\"Email\": \"pilot@example.com\", \"Name\": \"Mailjet Pilot\"},\n            \"To\": [{\"Email\": \"passenger1@example.com\", \"Name\": \"Passenger 1\"}],\n            \"Subject\": \"Your email flight plan!\",\n            \"TextPart\": \"Dear passenger 1, welcome to Mailjet!\",\n            \"HTMLPart\": \"<h3>Dear passenger 1, welcome to Mailjet!</h3>\",\n        }\n    ]\n}\n\nwith Client(auth=(api_key, api_secret), version=\"v3.1\") as mailjet:\n    result = mailjet.send.create(data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"send-with-a-mailjet-template","__idx":19},"children":["Send with a Mailjet template"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pass ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Variables"]}," as a plain Python dictionary:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"data = {\n    \"Messages\": [\n        {\n            \"From\": {\"Email\": \"pilot@example.com\", \"Name\": \"Mailjet Pilot\"},\n            \"To\": [{\"Email\": \"passenger1@example.com\", \"Name\": \"Passenger 1\"}],\n            \"TemplateID\": 1234567,\n            \"TemplateLanguage\": True,\n            \"Subject\": \"Your email flight plan!\",\n            \"Variables\": {\"name\": \"John Doe\", \"custom_data\": \"Welcome aboard!\"},\n        }\n    ]\n}\n\nwith Client(auth=(api_key, api_secret), version=\"v3.1\") as mailjet:\n    result = mailjet.send.create(data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"rest-request-examples","__idx":20},"children":["REST request examples"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The examples below assume an open session: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["with Client(auth=(api_key, api_secret)) as mailjet:"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"post--create-an-object","__idx":21},"children":["POST — create an object"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"data = {\"Email\": \"passenger@example.com\"}\nresult = mailjet.contact.create(data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"post--endpoints-with-an-action","__idx":22},"children":["POST — endpoints with an action"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"data = {\n    \"ContactsLists\": [\n        {\"ListID\": list_id_1, \"Action\": \"addnoforce\"},\n        {\"ListID\": list_id_2, \"Action\": \"addforce\"},\n    ]\n}\nresult = mailjet.contact_managecontactslists.create(id=contact_id, data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"sandbox-mode-for-local-development","__idx":23},"children":["Sandbox mode for local development"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["dry_run=True"]}," intercepts every state-changing request (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DELETE"]},") and returns a mock ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["200 OK"]},", so local runs cannot reach real recipients:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"with Client(auth=(api_key, api_secret), dry_run=True) as dry_run_client:\n    dry_run_client.contact.create(data={\"Email\": \"real_user@example.com\"})\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--all-objects","__idx":24},"children":["GET — all objects"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"result = mailjet.contact.get()\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--a-single-object","__idx":25},"children":["GET — a single object"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"result = mailjet.contact.get(id=contact_id)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--with-filters","__idx":26},"children":["GET — with filters"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"filters = {\n    \"limit\": 40,\n    \"offset\": 50,\n    \"sort\": \"Email desc\",\n    \"IsExcludedFromCampaigns\": \"false\",\n}\nresult = mailjet.contact.get(filters=filters)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"pagination","__idx":27},"children":["Pagination"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Many list endpoints accept ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["limit"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["offset"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sort"]},":"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Meaning"},"children":["Meaning"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Default"},"children":["Default"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["limit"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["int"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["number of objects returned (max ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["1000"]},")"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["10"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["offset"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["int"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["starting position in the result list"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sort"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["str"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["property plus ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ASC"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DESC"]},"; not available for every property"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ID asc"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"lazy-pagination","__idx":28},"children":["Lazy pagination"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".stream()"]}," returns a generator and manages limit, offset and network pagination for you — no ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["while"]}," loop, and memory-safe on large lists:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"for contact in mailjet.contact.stream(chunk_size=500):\n    print(contact[\"Email\"])\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"put--update-an-object","__idx":29},"children":["PUT — update an object"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," in the Mailjet API behaves like a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PATCH"]},": only the properties you send are updated, and non-mandatory properties can be omitted."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"data = {\n    \"Data\": [\n        {\"Name\": \"first_name\", \"value\": \"John\"},\n        {\"Name\": \"last_name\", \"value\": \"Smith\"},\n    ]\n}\nresult = mailjet.contactdata.update(id=contact_id, data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"delete--remove-an-object","__idx":30},"children":["DELETE — remove an object"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A successful ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DELETE"]}," returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["204 No Content"]}," with no response body."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"result = mailjet.template.delete(id=template_id)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"email-api-ecosystem","__idx":31},"children":["Email API ecosystem"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"webhooks","__idx":32},"children":["Webhooks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Subscribe to real-time events (open, click, bounce, …) through the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventcallbackurl"]}," resource:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"data = {\n    \"EventType\": \"open\",\n    \"Url\": \"https://www.example.com/webhook\",\n    \"Status\": \"alive\",\n}\nresult = mailjet.eventcallbackurl.create(data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"parse-api","__idx":33},"children":["Parse API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Route inbound email for a domain to your own webhook:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"data = {\"Url\": \"https://www.example.com/mj_parse.php\"}\nresult = mailjet.parseroute.create(data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"segmentation","__idx":34},"children":["Segmentation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Build expressions that filter contacts dynamically:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"data = {\n    \"Description\": \"Will send only to contacts under 35 years of age.\",\n    \"Expression\": \"(age<35)\",\n    \"Name\": \"Customers under 35\",\n}\nresult = mailjet.contactfilter.create(data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"statistics","__idx":35},"children":["Statistics"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"filters = {\n    \"CounterSource\": \"APIKey\",\n    \"CounterTiming\": \"Message\",\n    \"CounterResolution\": \"Lifetime\",\n}\nresult = mailjet.statcounters.get(filters=filters)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"content-api","__idx":36},"children":["Content API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Content API (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1"]},") manages templates, tokens and images. Set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["version=\"v1\""]}," and authenticate with Basic Auth or a bearer token. The SDK adds the required ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/REST/"]}," prefix for most resources automatically and maps ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data_images"]}," to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/data/"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"generate-a-token","__idx":37},"children":["Generate a token"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"with Client(auth=(api_key, api_secret), version=\"v1\") as client:\n    data = {\n        \"Name\": \"My Access Token\",\n        \"Permissions\": [\"read_template\", \"create_template\"],\n    }\n    result = client.token.create(data=data)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"upload-an-image","__idx":38},"children":["Upload an image"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data_images"]}," resource and remove the default ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Content-Type"]}," header so ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requests"]}," can generate the multipart boundaries:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import base64\n\nb64_string = \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=\"\nimage_bytes = base64.b64decode(b64_string)\n\nfiles_payload = {\n    \"metadata\": (None, '{\"name\": \"logo.png\", \"Status\": \"open\"}', \"application/json\"),\n    \"file\": (\"logo.png\", image_bytes, \"image/png\"),\n}\n\nresult = client.data_images.create(headers={\"Content-Type\": None}, files=files_payload)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"lock-template-content","__idx":39},"children":["Lock template content"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sub-actions are routed with slashes — ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["template_contents_lock"]}," becomes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["template/{id}/contents/lock"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"result = client.template_contents_lock.create(id=template_id)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"security-guardrails","__idx":40},"children":["Security guardrails"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK ships active protections based on defence-in-depth principles:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["SSRF and open redirects"]}," — automatic redirects are disabled and hostname validation is enforced."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["CRLF injection"]}," — header injection through compromised bearer tokens or custom headers is blocked."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Downgrade attacks"]}," — TLS 1.2 minimum is enforced via a custom ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SecureHTTPAdapter"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Idempotency fingerprinting"]}," — SHA-256 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Idempotency-Key"]}," headers are generated for ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DELETE"]}," to prevent duplicate mutations."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["SpamGuard analysis"]}," — a pre-flight HTML analyser blocks XSS vectors (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<script>"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onerror="]},") before dispatch."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Secret obfuscation"]}," — a custom ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SecretAuth"]}," transport adapter and redacting filter keep credentials out of tracebacks, logs and memory dumps."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Punycode IDN support"]}," — internationalised domain names are normalised to prevent homograph attacks."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The vulnerability disclosure policy and supported versions are in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-python/blob/master/SECURITY.md"},"children":["SECURITY.md"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"local-first-validation","__idx":41},"children":["Local-first validation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Rather than waiting for a server round trip, strictly typed models (such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SendV31Payload"]},") catch mass assignment and invalid formats locally in microseconds."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"runtime-security-pep-578","__idx":42},"children":["Runtime security (PEP 578)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For SecOps environments the SDK acts as a sensor, emitting native ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sys.audit"]}," events for outbound network egress and explicit TLS bypass attempts. Opt in to pipe them into your logging infrastructure:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from mailjet_rest import Client, Config\n\ncfg = Config(enable_security_audit=True)\n\nwith Client(auth=(api_key, api_secret), config=cfg) as mailjet:\n    ...\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"network-resilience-and-retries","__idx":43},"children":["Network resilience and retries"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["JitterRetry"]}," connection-pooling policy handles transient drops, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["5xx"]}," errors and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["429"]}," rate limits using exponential backoff with randomised full jitter, which avoids a thundering herd on Mailjet's upstream during high-throughput batching."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Retries are configured out of the box, but you can mount your own adapter:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import random\nfrom urllib3.util.retry import Retry\nfrom requests.adapters import HTTPAdapter\nfrom mailjet_rest import Client\n\n\nclass CustomJitterRetry(Retry):\n    \"\"\"Stateless retry policy with full jitter.\"\"\"\n\n    def get_backoff_time(self) -> float:\n        backoff = super().get_backoff_time()\n        return random.uniform(0, backoff) if backoff > 0 else 0\n\n\ncustom_retry_strategy = CustomJitterRetry(\n    total=5,\n    backoff_factor=0.5,\n    status_forcelist=[429, 500, 502, 503, 504],\n    raise_on_status=False,  # let the client raise Mailjet exceptions instead\n)\n\nwith Client(auth=(api_key, api_secret)) as mailjet:\n    mailjet.session.mount(\"https://\", HTTPAdapter(max_retries=custom_retry_strategy))\n    result = mailjet.contact.get()\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"performance","__idx":44},"children":["Performance"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Since ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1.6.0"]}," the SDK is optimised for high concurrency and memory-constrained environments such as AWS Lambda: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["__slots__"]}," for memory density, immutable ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MappingProxyType"]}," headers for zero-allocation merging, and O(1) dynamic endpoint caching. Benchmarks and profiling instructions are in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-python/blob/master/PERFORMANCE.md"},"children":["performance guide"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"deprecation-warnings","__idx":45},"children":["Deprecation warnings"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Legacy arguments (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ensure_ascii"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data_encoding"]},"), obsolete helpers (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parse_response"]},") and ambiguous routing (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1"]}," with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/template"]},") do not break your code. The request still executes, but a non-breaking ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DeprecationWarning"]}," is emitted so you can migrate gradually."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"executable-readme","__idx":46},"children":["Executable README"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The repository ships a script that creates, exercises and cleans up all the resources used in the examples — a quick way to verify credentials and network access:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"python samples/smoke_readme_runner.py\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Further samples live in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-python/tree/master/samples"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/samples"]}]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"contribute","__idx":47},"children":["Contribute"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The wrapper is open source and MIT-licensed. Fork the repository, branch, implement your fix or feature, document it, and open a pull request at ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-python"},"children":["mailjet/mailjet-apiv3-python"]},". Documentation improvements belong in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/api-documentation"},"children":["API documentation repo"]},"."]}]},"headings":[{"value":"Python SDK","id":"python-sdk","depth":1},{"value":"Compatibility","id":"compatibility","depth":2},{"value":"Installation","id":"installation","depth":2},{"value":"From source","id":"from-source","depth":3},{"value":"For development","id":"for-development","depth":3},{"value":"Authentication","id":"authentication","depth":2},{"value":"Quick start","id":"quick-start","depth":2},{"value":"Configuration","id":"configuration","depth":2},{"value":"API versioning","id":"api-versioning","depth":3},{"value":"Base URL","id":"base-url","depth":3},{"value":"Building resource paths","id":"building-resource-paths","depth":2},{"value":"Error handling","id":"error-handling","depth":2},{"value":"Logging and debugging","id":"logging-and-debugging","depth":2},{"value":"IDE autocompletion","id":"ide-autocompletion","depth":3},{"value":"Typed payloads","id":"typed-payloads","depth":2},{"value":"Strict payload builders","id":"strict-payload-builders","depth":3},{"value":"MessageBuilder and SendPayloadBuilder","id":"messagebuilder-and-sendpayloadbuilder","depth":3},{"value":"Send API examples","id":"send-api-examples","depth":2},{"value":"Send a basic email","id":"send-a-basic-email","depth":3},{"value":"Send with a Mailjet template","id":"send-with-a-mailjet-template","depth":3},{"value":"REST request examples","id":"rest-request-examples","depth":2},{"value":"POST — create an object","id":"post--create-an-object","depth":3},{"value":"POST — endpoints with an action","id":"post--endpoints-with-an-action","depth":3},{"value":"Sandbox mode for local development","id":"sandbox-mode-for-local-development","depth":3},{"value":"GET — all objects","id":"get--all-objects","depth":3},{"value":"GET — a single object","id":"get--a-single-object","depth":3},{"value":"GET — with filters","id":"get--with-filters","depth":3},{"value":"Pagination","id":"pagination","depth":3},{"value":"Lazy pagination","id":"lazy-pagination","depth":4},{"value":"PUT — update an object","id":"put--update-an-object","depth":3},{"value":"DELETE — remove an object","id":"delete--remove-an-object","depth":3},{"value":"Email API ecosystem","id":"email-api-ecosystem","depth":2},{"value":"Webhooks","id":"webhooks","depth":3},{"value":"Parse API","id":"parse-api","depth":3},{"value":"Segmentation","id":"segmentation","depth":3},{"value":"Statistics","id":"statistics","depth":3},{"value":"Content API","id":"content-api","depth":2},{"value":"Generate a token","id":"generate-a-token","depth":3},{"value":"Upload an image","id":"upload-an-image","depth":3},{"value":"Lock template content","id":"lock-template-content","depth":3},{"value":"Security guardrails","id":"security-guardrails","depth":2},{"value":"Local-first validation","id":"local-first-validation","depth":3},{"value":"Runtime security (PEP 578)","id":"runtime-security-pep-578","depth":3},{"value":"Network resilience and retries","id":"network-resilience-and-retries","depth":3},{"value":"Performance","id":"performance","depth":2},{"value":"Deprecation warnings","id":"deprecation-warnings","depth":2},{"value":"Executable README","id":"executable-readme","depth":2},{"value":"Contribute","id":"contribute","depth":2}],"frontmatter":{"title":"Mailjet Python SDK","seo":{"title":"Mailjet Python SDK","description":"Install and use the official Mailjet Python wrapper: authentication, sending with Send API v3.1, payload builders, pagination, security guardrails and the Content API."}},"lastModified":"2026-08-26T16:26:02.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/developer-tools/python","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}