
# Official Mailjet Python Wrapper
[](https://img.shields.io/github/v/release/mailjet/mailjet-apiv3-python)
[](https://img.shields.io/github/v/release/mailjet/mailjet-apiv3-python)
[](https://github.com/mailjet/mailjet-apiv3-python)
[](https://github.com/mailjet/mailjet-apiv3-python/blob/main/LICENSE)
[](https://img.shields.io/pypi/dm/mailjet-rest)
[](https://github.com/mailjet/mailjet-apiv3-python/actions)
[](https://img.shields.io/github/stars/mailjet/mailjet-apiv3-python)
[](https://img.shields.io/github/issues/mailjet/mailjet-apiv3-python)
[](https://img.shields.io/github/issues-pr/mailjet/mailjet-apiv3-python)
## Overview
Welcome to the [Mailjet] official Python API wrapper!
Check out all the resources and Python code examples in the official [Mailjet Documentation][doc].
## Table of contents
- [Compatibility](#compatibility)
- [Requirements](#requirements)
- [Build backend dependencies](#build-backend-dependencies)
- [Runtime dependnecies](#runtime-dependencies)
- [Test dependencies](#test-dependencies)
- [Installation](#installation)
- [pip install](#pip-install)
- [git clone & pip install locally](#git-clone--pip-install-locally)
- [conda & make](#conda--make)
- [For development](#for-development)
- [Using conda](#using-conda)
- [Authentication](#authentication)
- [Make your first call](#make-your-first-call)
- [Client / Call configuration specifics](#client--call-configuration-specifics)
- [API versioning](#api-versioning)
- [Base URL](#base-url)
- [URL path](#url-path)
- [Request examples](#request-examples)
- [Full list of supported endpoints](#full-list-of-supported-endpoints)
- [POST request](#post-request)
- [Simple POST request](#simple-post-request)
- [Using actions](#using-actions)
- [GET request](#get-request)
- [Retrieve all objects](#retrieve-all-objects)
- [Using filtering](#using-filtering)
- [Using pagination](#using-pagination)
- [Retrieve a single object](#retrieve-a-single-object)
- [PUT request](#put-request)
- [DELETE request](#delete-request)
- [License](#license)
- [Contribute](#contribute)
- [Contributors](#contributors)
## Compatibility
This library `mailjet_rest` officially supports the following Python versions:
- Python >=3.10,\<3.14
It's tested up to 3.13 (including).
## Requirements
### Build backend dependencies
To build the `mailjet_rest` package from the sources you need `setuptools` (as a build backend), `wheel`, and `setuptools-scm`.
### Runtime dependencies
At runtime the package requires only `requests >=2.32.4`.
### Test dependencies
For running test you need `pytest >=7.0.0` at least.
Make sure to provide the environment variables from [Authentication](#authentication).
## Installation
### pip install
Use the below code to install the the wrapper:
```bash
pip install mailjet-rest
```
#### git clone & pip install locally
Use the below code to install the wrapper locally by cloning this repository:
```bash
git clone https://github.com/mailjet/mailjet-apiv3-python
cd mailjet-apiv3-python
```
```bash
pip install .
```
#### conda & make
Use the below code to install it locally by `conda` and `make` on Unix platforms:
```bash
make install
```
### For development
#### Using conda
on Linux or macOS:
- A basic environment with a minimum number of dependencies:
```bash
make dev
conda activate mailjet
```
- A full dev environment:
```bash
make dev-full
conda activate mailjet-dev
```
## Authentication
The Mailjet Email API uses your API and Secret keys for authentication. [Grab][api_credential] and save your Mailjet API credentials.
```bash
export MJ_APIKEY_PUBLIC='your api key'
export MJ_APIKEY_PRIVATE='your api secret'
```
Initialize your [Mailjet] client:
```python
# import the mailjet wrapper
from mailjet_rest import Client
import os
# Get your environment Mailjet keys
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
```
## Make your first call
Here's an example on how to send an email:
```python
from mailjet_rest import Client
import os
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
data = {
"FromEmail": "$SENDER_EMAIL",
"FromName": "$SENDER_NAME",
"Subject": "Your email flight plan!",
"Text-part": "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
"Html-part": '<h3>Dear passenger, welcome to <a href="https://www.mailjet.com/">Mailjet</a>!<br />May the delivery force be with you!',
"Recipients": [{"Email": "$RECIPIENT_EMAIL"}],
}
result = mailjet.send.create(data=data)
print(result.status_code)
print(result.json())
```
## Client / Call Configuration Specifics
### API Versioning
The Mailjet API is spread among three distinct versions:
- `v3` - The Email API
- `v3.1` - Email Send API v3.1, which is the latest version of our Send API
- `v4` - SMS API (not supported in Python)
Since most Email API endpoints are located under `v3`, it is set as the default one and does not need to be specified when making your request. For the others you need to specify the version using `version`. For example, if using Send API `v3.1`:
```python
# import the mailjet wrapper
from mailjet_rest import Client
import os
# Get your environment Mailjet keys
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret), version="v3.1")
```
For additional information refer to our [API Reference](https://dev.mailjet.com/reference/overview/versioning/).
### Base URL
The default base domain name for the Mailjet API is `api.mailjet.com`. You can modify this base URL by setting a value for `api_url` in your call:
```python
mailjet = Client(auth=(api_key, api_secret), api_url="https://api.us.mailjet.com/")
```
If your account has been moved to Mailjet's **US architecture**, the URL value you need to set is `https://api.us.mailjet.com`.
### URL path
According to python special characters limitations we can't use slashes `/` and dashes `-` which is acceptable for URL path building. Instead python client uses another way for path building. You should replace slashes `/` by underscore `_` and dashes `-` by capitalizing next letter in path.
For example, to reach `statistics/link-click` path you should call `statistics_linkClick` attribute of python client.
```python
# GET `statistics/link-click`
mailjet = Client(auth=(api_key, api_secret))
filters = {"CampaignId": "xxxxxxx"}
result = mailjet.statistics_linkClick.get(filters=filters)
print(result.status_code)
print(result.json())
```
## Request examples
### Full list of supported endpoints
> [!IMPORTANT]\
> This is a full list of supported endpoints this wrapper provides [samples](samples)
### POST request
#### Simple POST request
```python
"""
Create a new contact:
"""
from mailjet_rest import Client
import os
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
data = {"Email": "Mister@mailjet.com"}
result = mailjet.contact.create(data=data)
print(result.status_code)
print(result.json())
```
#### Using actions
```python
"""
Manage the subscription status of a contact to multiple lists:
"""
from mailjet_rest import Client
import os
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
id = "$ID"
data = {
"ContactsLists": [
{"ListID": "$ListID_1", "Action": "addnoforce"},
{"ListID": "$ListID_2", "Action": "addforce"},
]
}
result = mailjet.contact_managecontactslists.create(id=id, data=data)
print(result.status_code)
print(result.json())
```
### GET Request
#### Retrieve all objects
```python
"""
Retrieve all contacts:
"""
from mailjet_rest import Client
import os
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.contact.get()
print(result.status_code)
print(result.json())
```
#### Using filtering
```python
"""
Retrieve all contacts that are not in the campaign exclusion list:
"""
from mailjet_rest import Client
import os
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
filters = {
"IsExcludedFromCampaigns": "false",
}
result = mailjet.contact.get(filters=filters)
print(result.status_code)
print(result.json())
```
#### Using pagination
Some requests (for example [GET /contact](https://dev.mailjet.com/email/reference/contacts/contact/#v3_get_contact)) has `limit`, `offset` and `sort` query string parameters. These parameters could be used for pagination.
`limit` `int` Limit the response to a select number of returned objects. Default value: `10`. Maximum value: `1000`
`offset` `int` Retrieve a list of objects starting from a certain offset. Combine this query parameter with `limit` to retrieve a specific section of the list of objects. Default value: `0`
`sort` `str` Sort the results by a property and select ascending (ASC) or descending (DESC) order. The default order is ascending. Keep in mind that this is not available for all properties. Default value: `ID asc`
Next example returns 40 contacts starting from 51th record sorted by `Email` field descendally:
```python
import os
from mailjet_rest import Client
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
filters = {
"limit": 40,
"offset": 50,
"sort": "Email desc",
}
result = mailjet.contact.get(filters=filters)
print(result.status_code)
print(result.json())
```
#### Retrieve a single object
```python
"""
Retrieve a specific contact ID:
"""
from mailjet_rest import Client
import os
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
id_ = "Contact_ID"
result = mailjet.contact.get(id=id_)
print(result.status_code)
print(result.json())
```
### PUT request
A `PUT` request in the Mailjet API will work as a `PATCH` request - the update will affect only the specified properties. The other properties of an existing resource will neither be modified, nor deleted. It also means that all non-mandatory properties can be omitted from your payload.
Here's an example of a `PUT` request:
```python
"""
Update the contact properties for a contact:
"""
from mailjet_rest import Client
import os
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
id_ = "$CONTACT_ID"
data = {
"Data": [
{"Name": "first_name", "value": "John"},
{"Name": "last_name", "value": "Smith"},
]
}
result = mailjet.contactdata.update(id=id_, data=data)
print(result.status_code)
print(result.json())
```
### DELETE request
Upon a successful `DELETE` request the response will not include a response body, but only a `204 No Content` response code.
Here's an example of a `DELETE` request:
```python
"""
Delete an email template:
"""
from mailjet_rest import Client
import os
api_key = os.environ["MJ_APIKEY_PUBLIC"]
api_secret = os.environ["MJ_APIKEY_PRIVATE"]
mailjet = Client(auth=(api_key, api_secret))
id_ = "Template_ID"
result = mailjet.template.delete(id=id_)
print(result.status_code)
print(result.json())
```
## License
[MIT](https://choosealicense.com/licenses/mit/)
## Contribute
Mailjet loves developers. You can be part of this project!
This wrapper is a great introduction to the open source world, check out the code!
Feel free to ask anything, and contribute:
- Fork the project.
- Create a new branch.
- Implement your feature or bug fix.
- Add documentation to it.
- Commit, push, open a pull request and voila.
If you have suggestions on how to improve the guides, please submit an issue in our [Official API Documentation repo](https://github.com/mailjet/api-documentation).
## Contributors
- [@diskovod](https://github.com/diskovod)
- [@DanyilNefodov](https://github.com/DanyilNefodov)
- [@skupriienko](https://github.com/skupriienko)
[api_credential]: https://app.mailjet.com/account/apikeys
[doc]: https://dev.mailjet.com/email/guides/?python#
[mailjet]: (https://www.mailjet.com)
Raw data
{
"_id": null,
"home_page": null,
"name": "mailjet-rest",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Serhii Kupriienko <kupriienko.serhii@gmail.com>",
"keywords": "Mailjet API v3 / v3.1 Python Wrapper, wrapper, email python-wrapper, transactional-emails, mailjet, mailjet-api",
"author": null,
"author_email": "starenka <starenka0@gmail.com>, Mailjet <api@mailjet.com>",
"download_url": "https://files.pythonhosted.org/packages/77/66/b6ff0ed1c8cde8b07ea7ae42ea3ce0dda86f2d07537185b6e6569b410777/mailjet_rest-1.5.0.tar.gz",
"platform": null,
"description": "\n\n# Official Mailjet Python Wrapper\n\n[](https://img.shields.io/github/v/release/mailjet/mailjet-apiv3-python)\n[](https://img.shields.io/github/v/release/mailjet/mailjet-apiv3-python)\n[](https://github.com/mailjet/mailjet-apiv3-python)\n[](https://github.com/mailjet/mailjet-apiv3-python/blob/main/LICENSE)\n[](https://img.shields.io/pypi/dm/mailjet-rest)\n[](https://github.com/mailjet/mailjet-apiv3-python/actions)\n\n[](https://img.shields.io/github/stars/mailjet/mailjet-apiv3-python)\n[](https://img.shields.io/github/issues/mailjet/mailjet-apiv3-python)\n[](https://img.shields.io/github/issues-pr/mailjet/mailjet-apiv3-python)\n\n## Overview\n\nWelcome to the [Mailjet] official Python API wrapper!\n\nCheck out all the resources and Python code examples in the official [Mailjet Documentation][doc].\n\n## Table of contents\n\n- [Compatibility](#compatibility)\n- [Requirements](#requirements)\n - [Build backend dependencies](#build-backend-dependencies)\n - [Runtime dependnecies](#runtime-dependencies)\n - [Test dependencies](#test-dependencies)\n- [Installation](#installation)\n - [pip install](#pip-install)\n - [git clone & pip install locally](#git-clone--pip-install-locally)\n - [conda & make](#conda--make)\n - [For development](#for-development)\n - [Using conda](#using-conda)\n- [Authentication](#authentication)\n- [Make your first call](#make-your-first-call)\n- [Client / Call configuration specifics](#client--call-configuration-specifics)\n - [API versioning](#api-versioning)\n - [Base URL](#base-url)\n - [URL path](#url-path)\n- [Request examples](#request-examples)\n - [Full list of supported endpoints](#full-list-of-supported-endpoints)\n - [POST request](#post-request)\n - [Simple POST request](#simple-post-request)\n - [Using actions](#using-actions)\n - [GET request](#get-request)\n - [Retrieve all objects](#retrieve-all-objects)\n - [Using filtering](#using-filtering)\n - [Using pagination](#using-pagination)\n - [Retrieve a single object](#retrieve-a-single-object)\n - [PUT request](#put-request)\n - [DELETE request](#delete-request)\n- [License](#license)\n- [Contribute](#contribute)\n- [Contributors](#contributors)\n\n## Compatibility\n\nThis library `mailjet_rest` officially supports the following Python versions:\n\n- Python >=3.10,\\<3.14\n\nIt's tested up to 3.13 (including).\n\n## Requirements\n\n### Build backend dependencies\n\nTo build the `mailjet_rest` package from the sources you need `setuptools` (as a build backend), `wheel`, and `setuptools-scm`.\n\n### Runtime dependencies\n\nAt runtime the package requires only `requests >=2.32.4`.\n\n### Test dependencies\n\nFor running test you need `pytest >=7.0.0` at least.\nMake sure to provide the environment variables from [Authentication](#authentication).\n\n## Installation\n\n### pip install\n\nUse the below code to install the the wrapper:\n\n```bash\npip install mailjet-rest\n```\n\n#### git clone & pip install locally\n\nUse the below code to install the wrapper locally by cloning this repository:\n\n```bash\ngit clone https://github.com/mailjet/mailjet-apiv3-python\ncd mailjet-apiv3-python\n```\n\n```bash\npip install .\n```\n\n#### conda & make\n\nUse the below code to install it locally by `conda` and `make` on Unix platforms:\n\n```bash\nmake install\n```\n\n### For development\n\n#### Using conda\n\non Linux or macOS:\n\n- A basic environment with a minimum number of dependencies:\n\n```bash\nmake dev\nconda activate mailjet\n```\n\n- A full dev environment:\n\n```bash\nmake dev-full\nconda activate mailjet-dev\n```\n\n## Authentication\n\nThe Mailjet Email API uses your API and Secret keys for authentication. [Grab][api_credential] and save your Mailjet API credentials.\n\n```bash\nexport MJ_APIKEY_PUBLIC='your api key'\nexport MJ_APIKEY_PRIVATE='your api secret'\n```\n\nInitialize your [Mailjet] client:\n\n```python\n# import the mailjet wrapper\nfrom mailjet_rest import Client\nimport os\n\n# Get your environment Mailjet keys\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\n\nmailjet = Client(auth=(api_key, api_secret))\n```\n\n## Make your first call\n\nHere's an example on how to send an email:\n\n```python\nfrom mailjet_rest import Client\nimport os\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\ndata = {\n \"FromEmail\": \"$SENDER_EMAIL\",\n \"FromName\": \"$SENDER_NAME\",\n \"Subject\": \"Your email flight plan!\",\n \"Text-part\": \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\",\n \"Html-part\": '<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!',\n \"Recipients\": [{\"Email\": \"$RECIPIENT_EMAIL\"}],\n}\nresult = mailjet.send.create(data=data)\nprint(result.status_code)\nprint(result.json())\n```\n\n## Client / Call Configuration Specifics\n\n### API Versioning\n\nThe Mailjet API is spread among three distinct versions:\n\n- `v3` - The Email API\n- `v3.1` - Email Send API v3.1, which is the latest version of our Send API\n- `v4` - SMS API (not supported in Python)\n\nSince most Email API endpoints are located under `v3`, it is set as the default one and does not need to be specified when making your request. For the others you need to specify the version using `version`. For example, if using Send API `v3.1`:\n\n```python\n# import the mailjet wrapper\nfrom mailjet_rest import Client\nimport os\n\n# Get your environment Mailjet keys\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\n\nmailjet = Client(auth=(api_key, api_secret), version=\"v3.1\")\n```\n\nFor additional information refer to our [API Reference](https://dev.mailjet.com/reference/overview/versioning/).\n\n### Base URL\n\nThe default base domain name for the Mailjet API is `api.mailjet.com`. You can modify this base URL by setting a value for `api_url` in your call:\n\n```python\nmailjet = Client(auth=(api_key, api_secret), api_url=\"https://api.us.mailjet.com/\")\n```\n\nIf your account has been moved to Mailjet's **US architecture**, the URL value you need to set is `https://api.us.mailjet.com`.\n\n### URL path\n\nAccording to python special characters limitations we can't use slashes `/` and dashes `-` which is acceptable for URL path building. Instead python client uses another way for path building. You should replace slashes `/` by underscore `_` and dashes `-` by capitalizing next letter in path.\nFor example, to reach `statistics/link-click` path you should call `statistics_linkClick` attribute of python client.\n\n```python\n# GET `statistics/link-click`\nmailjet = Client(auth=(api_key, api_secret))\nfilters = {\"CampaignId\": \"xxxxxxx\"}\nresult = mailjet.statistics_linkClick.get(filters=filters)\nprint(result.status_code)\nprint(result.json())\n```\n\n## Request examples\n\n### Full list of supported endpoints\n\n> [!IMPORTANT]\\\n> This is a full list of supported endpoints this wrapper provides [samples](samples)\n\n### POST request\n\n#### Simple POST request\n\n```python\n\"\"\"\nCreate a new contact:\n\"\"\"\n\nfrom mailjet_rest import Client\nimport os\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\ndata = {\"Email\": \"Mister@mailjet.com\"}\nresult = mailjet.contact.create(data=data)\nprint(result.status_code)\nprint(result.json())\n```\n\n#### Using actions\n\n```python\n\"\"\"\nManage the subscription status of a contact to multiple lists:\n\"\"\"\n\nfrom mailjet_rest import Client\nimport os\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\nid = \"$ID\"\ndata = {\n \"ContactsLists\": [\n {\"ListID\": \"$ListID_1\", \"Action\": \"addnoforce\"},\n {\"ListID\": \"$ListID_2\", \"Action\": \"addforce\"},\n ]\n}\nresult = mailjet.contact_managecontactslists.create(id=id, data=data)\nprint(result.status_code)\nprint(result.json())\n```\n\n### GET Request\n\n#### Retrieve all objects\n\n```python\n\"\"\"\nRetrieve all contacts:\n\"\"\"\n\nfrom mailjet_rest import Client\nimport os\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\nresult = mailjet.contact.get()\nprint(result.status_code)\nprint(result.json())\n```\n\n#### Using filtering\n\n```python\n\"\"\"\nRetrieve all contacts that are not in the campaign exclusion list:\n\"\"\"\n\nfrom mailjet_rest import Client\nimport os\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\nfilters = {\n \"IsExcludedFromCampaigns\": \"false\",\n}\nresult = mailjet.contact.get(filters=filters)\nprint(result.status_code)\nprint(result.json())\n```\n\n#### Using pagination\n\nSome requests (for example [GET /contact](https://dev.mailjet.com/email/reference/contacts/contact/#v3_get_contact)) has `limit`, `offset` and `sort` query string parameters. These parameters could be used for pagination.\n`limit` `int` Limit the response to a select number of returned objects. Default value: `10`. Maximum value: `1000`\n`offset` `int` Retrieve a list of objects starting from a certain offset. Combine this query parameter with `limit` to retrieve a specific section of the list of objects. Default value: `0`\n`sort` `str` Sort the results by a property and select ascending (ASC) or descending (DESC) order. The default order is ascending. Keep in mind that this is not available for all properties. Default value: `ID asc`\nNext example returns 40 contacts starting from 51th record sorted by `Email` field descendally:\n\n```python\nimport os\nfrom mailjet_rest import Client\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\n\nfilters = {\n \"limit\": 40,\n \"offset\": 50,\n \"sort\": \"Email desc\",\n}\nresult = mailjet.contact.get(filters=filters)\nprint(result.status_code)\nprint(result.json())\n```\n\n#### Retrieve a single object\n\n```python\n\"\"\"\nRetrieve a specific contact ID:\n\"\"\"\n\nfrom mailjet_rest import Client\nimport os\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\nid_ = \"Contact_ID\"\nresult = mailjet.contact.get(id=id_)\nprint(result.status_code)\nprint(result.json())\n```\n\n### PUT request\n\nA `PUT` request in the Mailjet API will work as a `PATCH` request - the update will affect only the specified properties. The other properties of an existing resource will neither be modified, nor deleted. It also means that all non-mandatory properties can be omitted from your payload.\n\nHere's an example of a `PUT` request:\n\n```python\n\"\"\"\nUpdate the contact properties for a contact:\n\"\"\"\n\nfrom mailjet_rest import Client\nimport os\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\nid_ = \"$CONTACT_ID\"\ndata = {\n \"Data\": [\n {\"Name\": \"first_name\", \"value\": \"John\"},\n {\"Name\": \"last_name\", \"value\": \"Smith\"},\n ]\n}\nresult = mailjet.contactdata.update(id=id_, data=data)\nprint(result.status_code)\nprint(result.json())\n```\n\n### DELETE request\n\nUpon a successful `DELETE` request the response will not include a response body, but only a `204 No Content` response code.\n\nHere's an example of a `DELETE` request:\n\n```python\n\"\"\"\nDelete an email template:\n\"\"\"\n\nfrom mailjet_rest import Client\nimport os\n\napi_key = os.environ[\"MJ_APIKEY_PUBLIC\"]\napi_secret = os.environ[\"MJ_APIKEY_PRIVATE\"]\nmailjet = Client(auth=(api_key, api_secret))\nid_ = \"Template_ID\"\nresult = mailjet.template.delete(id=id_)\nprint(result.status_code)\nprint(result.json())\n```\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\n## Contribute\n\nMailjet loves developers. You can be part of this project!\n\nThis wrapper is a great introduction to the open source world, check out the code!\n\nFeel free to ask anything, and contribute:\n\n- Fork the project.\n- Create a new branch.\n- Implement your feature or bug fix.\n- Add documentation to it.\n- Commit, push, open a pull request and voila.\n\nIf you have suggestions on how to improve the guides, please submit an issue in our [Official API Documentation repo](https://github.com/mailjet/api-documentation).\n\n## Contributors\n\n- [@diskovod](https://github.com/diskovod)\n- [@DanyilNefodov](https://github.com/DanyilNefodov)\n- [@skupriienko](https://github.com/skupriienko)\n\n[api_credential]: https://app.mailjet.com/account/apikeys\n[doc]: https://dev.mailjet.com/email/guides/?python#\n[mailjet]: (https://www.mailjet.com)\n",
"bugtrack_url": null,
"license": null,
"summary": "Mailjet V3 API wrapper",
"version": "1.5.0",
"project_urls": {
"Documentation": "https://dev.mailjet.com",
"Homepage": "https://dev.mailjet.com",
"Issue Tracker": "https://github.com/mailjet/mailjet-apiv3-python/issues",
"Repository": "https://github.com/mailjet/mailjet-apiv3-python"
},
"split_keywords": [
"mailjet api v3 / v3.1 python wrapper",
" wrapper",
" email python-wrapper",
" transactional-emails",
" mailjet",
" mailjet-api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "df55aa3eebf9607c81cc0bbec55ee9d76f6eddc76cf2f44e5b19225ec06858ea",
"md5": "a3e23409ba7ba44bf1b9a3d6c5776f24",
"sha256": "bf30aefe12b9b3adb370d839e3fa24f7a7bfbbcf7ce04d018fb613d9c2e8a122"
},
"downloads": -1,
"filename": "mailjet_rest-1.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a3e23409ba7ba44bf1b9a3d6c5776f24",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 28664,
"upload_time": "2025-07-11T21:10:09",
"upload_time_iso_8601": "2025-07-11T21:10:09.377775Z",
"url": "https://files.pythonhosted.org/packages/df/55/aa3eebf9607c81cc0bbec55ee9d76f6eddc76cf2f44e5b19225ec06858ea/mailjet_rest-1.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7766b6ff0ed1c8cde8b07ea7ae42ea3ce0dda86f2d07537185b6e6569b410777",
"md5": "99bc9d56ef55df1b6c18ad08ee5d8993",
"sha256": "e1f50255415c57508313b1ec0be143d942e6e147318cb56532d1ecbf9b97f332"
},
"downloads": -1,
"filename": "mailjet_rest-1.5.0.tar.gz",
"has_sig": false,
"md5_digest": "99bc9d56ef55df1b6c18ad08ee5d8993",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 42411,
"upload_time": "2025-07-11T21:10:10",
"upload_time_iso_8601": "2025-07-11T21:10:10.811514Z",
"url": "https://files.pythonhosted.org/packages/77/66/b6ff0ed1c8cde8b07ea7ae42ea3ce0dda86f2d07537185b6e6569b410777/mailjet_rest-1.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-11 21:10:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mailjet",
"github_project": "mailjet-apiv3-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mailjet-rest"
}