{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition","tabs","tab"]},"type":"markdown"},"seo":{"title":"Manage your exclusion list","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Block Mailjet contacts from marketing campaigns via IsExcludedFromCampaigns; they still receive transactional Send API messages.","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":"manage-your-exclusion-list","__idx":0},"children":["Manage your exclusion list"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"exclusion-list-overview","__idx":1},"children":["Exclusion list overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Whenever you have contacts subscribed to multiple lists, it’s tedious to unsubscribe them from every single one, in case they don’t want to receive any marketing emails. You would also want an easy way to prevent a sending in case you accidentally subscribed a contact to a new list."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This is why Campaign Exclusion List was created - it helps you prevent an accidental sending of a marketing campaign to users. You can add users to this exclusion list and they will be automatically blocked from receiving marketing emails."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Contacts in the exclusion list will still be able to receive messages sent via the Send API."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"single-contact-exclusion","__idx":2},"children":["Single contact exclusion"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To add a single contact to the exclusion list, you simply need to modify its IsExcludedFromCampaigns property to true with a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT /contact/{contact_id_or_email}"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example","__idx":3},"children":["Example"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# Call to add contact to exclusion list\ncurl -s \\\n\t-X PUT \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/contact/$ID_OR_EMAIL \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n\t\t\"IsExcludedFromCampaigns\":\"true\"\n\t}'\n","lang":"shell"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"PHP","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\n/*\nCall to add contact to exclusion list\n*/\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));\n$body = [\n    'IsExcludedFromCampaigns' => \"true\"\n];\n$response = $mj->put(Resources::$Contact, ['id' => $id, 'body' => $body]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * Call to add contact to exclusion list\n *\n */\nconst mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.put(\"contact\")\n\t.id($ID_OR_EMAIL)\n\t.request({\n\t\t\"IsExcludedFromCampaigns\":\"true\"\n\t})\nrequest\n\t.then((result) => {\n\t\tconsole.log(result.body)\n\t})\n\t.catch((err) => {\n\t\tconsole.log(err.statusCode)\n\t})\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ruby","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# Call to add contact to exclusion list\nrequire 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']  \nend\ntarget = Mailjet::Contact.find($ID_OR_EMAIL)\ntarget.update_attributes(is_excluded_from_campaigns: \"true\"\n)\np variable.attributes['Data']\n","lang":"ruby"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nCall to add contact to exclusion list\n\"\"\"\nfrom mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret))\nid = '$ID_OR_EMAIL'\ndata = {\n  'IsExcludedFromCampaigns': 'true'\n}\nresult = mailjet.contact.update(id=id, data=data)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.resource.Contact;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    /**\n     * Call to add contact to exclusion list\n     */\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"));\n      request = new MailjetRequest(Contact.resource, ID)\n\t\t\t.property(Contact.ISEXCLUDEDFROMCAMPAIGNS, \"true\");\n      response = client.put(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"/*\nCall to add contact to exclusion list\n*/\npackage main\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\tmailjet \"github.com/mailjet/mailjet-apiv3-go\"\n\t\"github.com/mailjet/mailjet-apiv3-go/resources\"\n)\nfunc main () {\n\tmailjetClient := NewMailjetClient(os.Getenv(\"MJ_APIKEY_PUBLIC\"), os.Getenv(\"MJ_APIKEY_PRIVATE\"))\n\tmr := &Request{\n\t  Resource: \"contact\",\n\t  ID: RESOURCE_ID,\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.Contact {\n      IsExcludedFromCampaigns: \"true\",\n    },\n\t}\n\terr := mailjetClient.Put(fmr)\n\tif err != nil {\n\t  fmt.Println(err)\n\t}\n}\n","lang":"go"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n   class Program\n   {\n      /// <summary>\n      /// Call to add contact to exclusion list\n      /// </summary>\n      static void Main(string[] args)\n      {\n         RunAsync().Wait();\n      }\n      static async Task RunAsync()\n      {\n         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"));\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Contact.Resource,\n            ResourceId = ResourceId.Numeric(ID)\n         }\n            .Property(Contact.IsExcludedFromCampaigns, \"true\");\n         MailjetResponse response = await client.PutAsync(request);\n         if (response.IsSuccessStatusCode)\n         {\n            Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n            Console.WriteLine(response.GetData());\n         }\n         else\n         {\n            Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n            Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n            Console.WriteLine(response.GetData());\n            Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n         }\n      }\n   }\n}\n","lang":"csharp"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response","__idx":4},"children":["API Response"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n\t\"Count\": 1,\n\t\"Data\": [\n\t\t{\n\t\t\t\"CreatedAt\": \"2014-06-10T08:30:32Z\",\n\t\t\t\"DeliveredCount\": \"\",\n\t\t\t\"Email\": \"Mister@mailjet.com\",\n\t\t\t\"ExclusionFromCampaignsUpdatedAt\": \"2014-06-10T08:47:28Z\",\n\t\t\t\"ID\": \"1\",\n\t\t\t\"IsExcludedFromCampaigns\": \"true\",\n\t\t\t\"IsOptInPending\": \"false\",\n\t\t\t\"IsSpamComplaining\": \"false\",\n\t\t\t\"LastActivityAt\": \"2014-06-10T08:47:28Z\",\n\t\t\t\"LastUpdateAt\": \"2014-12-31T11:00:46Z\",\n\t\t\t\"Name\": \"John\",\n\t\t\t\"UnsubscribedAt\": \"\",\n\t\t\t\"UnsubscribedBy\": \"\"\n\t\t}\n\t],\n\t\"Total\": 1\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"bulk-exclusion","__idx":5},"children":["Bulk exclusion"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In case you want to exclude multiple contacts, you have a couple of options to do that:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Using ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/contact/managemanycontacts"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Using ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/csvimport"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"using-contactmanagemanycontacts","__idx":6},"children":["Using /contact/managemanycontacts"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When doing the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]}," call, simply set the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["IsExcludedFromCampaigns"]}," to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," for the contacts you want to exclude."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-1","__idx":7},"children":["Example"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# Create : Manage the details of a Contact.\ncurl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/contact/managemanycontacts \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n\t\t\"Contacts\":[\n\t\t\t\t{\n\t\t\t\t\t\t\"Email\": \"jimsmith@example.com\",\n\t\t\t\t\t\t\"Name\": \"Jim\",\n\t\t\t\t\t\t\"IsExcludedFromCampaigns\": true,\n\t\t\t\t\t\t\"Properties\": {\n\t\t\t\t\t\t\t\t\"Property1\": \"value\",\n\t\t\t\t\t\t\t\t\"Property2\": \"value2\"\n\t\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\t\"Email\": \"janetdoe@example.com\",\n\t\t\t\t\t\t\"Name\": \"Janet\",\n\t\t\t\t\t\t\"IsExcludedFromCampaigns\": true,\n\t\t\t\t\t\t\"Properties\": {\n\t\t\t\t\t\t\t\t\"Property1\": \"value\",\n\t\t\t\t\t\t\t\t\"Property2\": \"value2\"\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t]\n\t}'\n","lang":"shell"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"PHP","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));\n$body = [\n    'Contacts' => [\n        [\n            'Email' => \"jimsmith@example.com\",\n            'Name' => \"Jim\",\n            'IsExcludedFromCampaigns' => true,\n            'Properties' => [\n                'Property1' => \"value\",\n                'Property2' => \"value2\"\n            ]\n        ],\n        [\n            'Email' => \"janetdoe@example.com\",\n            'Name' => \"Janet\",\n            'IsExcludedFromCampaigns' => true,\n            'Properties' => [\n                'Property1' => \"value\",\n                'Property2' => \"value2\"\n            ]\n        ]\n    ]\n];\n$response = $mj->post(Resources::$ContactManagemanycontacts, ['body' => $body]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * Create : Manage the details of a Contact.\n *\n */\nconst mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"contact\")\n\t.action(\"managemanycontacts\")\n\t.request({\n\t\t\"Contacts\":[\n\t\t\t\t{\n\t\t\t\t\t\t\"Email\": \"jimsmith@example.com\",\n\t\t\t\t\t\t\"Name\": \"Jim\",\n\t\t\t\t\t\t\"IsExcludedFromCampaigns\": true,\n\t\t\t\t\t\t\"Properties\": {\n\t\t\t\t\t\t\t\t\"Property1\": \"value\",\n\t\t\t\t\t\t\t\t\"Property2\": \"value2\"\n\t\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\t\"Email\": \"janetdoe@example.com\",\n\t\t\t\t\t\t\"Name\": \"Janet\",\n\t\t\t\t\t\t\"IsExcludedFromCampaigns\": true,\n\t\t\t\t\t\t\"Properties\": {\n\t\t\t\t\t\t\t\t\"Property1\": \"value\",\n\t\t\t\t\t\t\t\t\"Property2\": \"value2\"\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t]\n\t})\nrequest\n\t.then((result) => {\n\t\tconsole.log(result.body)\n\t})\n\t.catch((err) => {\n\t\tconsole.log(err.statusCode)\n\t})\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ruby","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# Create : Manage the details of a Contact.\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.default_from = 'your default sending address'\nend\nvariable = Mailjet::Contact_managemanycontacts.create(contacts: [{ 'Email'=> 'jimsmith@example.com', 'Name'=> 'Jim', 'IsExcludedFromCampaigns'=> true, 'Properties'=> { 'Property1'=> 'value', 'Property2'=> 'value2' }}, { 'Email'=> 'janetdoe@example.com', 'Name'=> 'Janet', 'IsExcludedFromCampaigns'=> true, 'Properties'=> { 'Property1'=> 'value', 'Property2'=> 'value2' }}])\n","lang":"ruby"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nCreate : Manage the details of a Contact.\n\"\"\"\nfrom mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret))\ndata = {\n  'Contacts': [\n\t\t\t\t{\n\t\t\t\t\t\t\"Email\": \"jimsmith@example.com\",\n\t\t\t\t\t\t\"Name\": \"Jim\",\n\t\t\t\t\t\t\"IsExcludedFromCampaigns\": \"true\",\n\t\t\t\t\t\t\"Properties\": {\n\t\t\t\t\t\t\t\t\"Property1\": \"value\",\n\t\t\t\t\t\t\t\t\"Property2\": \"value2\"\n\t\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\t\"Email\": \"janetdoe@example.com\",\n\t\t\t\t\t\t\"Name\": \"Janet\",\n\t\t\t\t\t\t\"IsExcludedFromCampaigns\": \"true\",\n\t\t\t\t\t\t\"Properties\": {\n\t\t\t\t\t\t\t\t\"Property1\": \"value\",\n\t\t\t\t\t\t\t\t\"Property2\": \"value2\"\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t]\n}\nresult = mailjet.contact_managemanycontacts.create(data=data)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.resource.ContactManagemanycontacts;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    /**\n     * Create : Manage the details of a Contact.\n     */\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"));\n      request = new MailjetRequest(ContactManagemanycontacts.resource)\n\t\t\t\t\t\t.property(ContactManagemanycontacts.CONTACTS, new JSONArray()\n                                                                .put(new JSONObject()\n                                                                    .put(\"Email\", \"jimsmith@example.com\")\n                                                                    .put(\"Name\", \"Jim\")\n                                                                    .put(\"IsExcludedFromCampaigns\", \"true\")\n                                                                    .put(\"Properties\", new JSONObject()\n                                                                        .put(\"Property1\", \"value\")\n                                                                        .put(\"Property2\", \"value2\")))\n                                                                .put(new JSONObject()\n                                                                    .put(\"Email\", \"janetdoe@example.com\")\n                                                                    .put(\"Name\", \"Janet\")\n                                                                    .put(\"IsExcludedFromCampaigns\", \"true\")\n                                                                    .put(\"Properties\", new JSONObject()\n                                                                        .put(\"Property1\", \"value\")\n                                                                        .put(\"Property2\", \"value2\"))));\n      response = client.post(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"/*\nCreate : Manage the details of a Contact.\n*/\npackage main\nimport (\n\t\"fmt\"\n\t. \"github.com/mailjet/mailjet-apiv3-go\"\n\t\"github.com/mailjet/mailjet-apiv3-go/resources\"\n\t\"os\"\n)\nfunc main () {\n\tmailjetClient := NewMailjetClient(os.Getenv(\"MJ_APIKEY_PUBLIC\"), os.Getenv(\"MJ_APIKEY_PRIVATE\"))\n\tvar data []resources.ContactManagemanycontacts\n\tmr := &Request{\n\t  Resource: \"contact\",\n\t  Action: \"managemanycontacts\",\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.ContactManagemanycontacts {\n      Contacts: []MailjetContact {\n        MailjetContact {\n          Email: \"jimsmith@example.com\",\n          Name: \"Jim\",\n          IsExcludedFromCampaigns: true,\n          Properties: MyPropertiesStruct {\n            Property1: \"value\",\n            Property2: \"value2\",\n          },\n        },\n        MailjetContact {\n          Email: \"janetdoe@example.com\",\n          Name: \"Janet\",\n          IsExcludedFromCampaigns: true,\n          Properties: MyPropertiesStruct {\n            Property1: \"value\",\n            Property2: \"value2\",\n          },\n        },\n      },\n    },\n\t}\n\terr := mailjetClient.Post(fmr, &data)\n\tif err != nil {\n\t  fmt.Println(err)\n\t}\n\tfmt.Printf(\"Data array: %+v\\n\", data)\n}\n","lang":"go"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n    class Program\n    {\n\t/// <summary>\n\t/// Create : Manage the details of a Contact.\n\t/// </summary>\n\tstatic void Main(string[] args)\n        {\n            RunAsync().Wait();\n        }\n        static async Task RunAsync()\n        {\n            MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"));\n            MailjetRequest request = new MailjetRequest\n            {\n                Resource = ContactManagemanycontacts.Resource,\n            }\n\t\t.Property(ContactManagemanycontacts.Contacts, new JArray {\n                new JObject {\n                 {\"Email\", \"jimsmith@example.com\"},\n                 {\"Name\", \"Jim\"},\n                 {\"IsExcludedFromCampaigns\", \"true\"},\n                 {\"Properties\", new JObject {\n                  {\"Property1\", \"value\"},\n                  {\"Property2\", \"value2\"}\n                  }}\n                 },\n                new JObject {\n                 {\"Email\", \"janetdoe@example.com\"},\n                 {\"Name\", \"Janet\"},\n                 {\"IsExcludedFromCampaigns\", \"true\"},\n                 {\"Properties\", new JObject {\n                  {\"Property1\", \"value\"},\n                  {\"Property2\", \"value2\"}\n                  }}\n                 }\n                });\n            MailjetResponse response = await client.PostAsync(request);\n            if (response.IsSuccessStatusCode)\n            {\n                Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n                Console.WriteLine(response.GetData());\n            }\n            else\n            {\n                Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n                Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n                Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n            }\n\t}\n    }\n}\n","lang":"csharp"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"using-csvimport","__idx":8},"children":["Using /csvimport"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Using the CSV Upload methodology, you can upload a list of contacts to add them to or remove them from the exclusion list. To do that, you need to set the Method property to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["excludemarketing"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["includemarketing"]},", respectively."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The JSON payload sent to /csvimport should NOT contain the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ContactsListID"]}," property. If it does, the following error will appear:",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[" MJ08 Property ContactsList is invalid: Exclusion of contacts from marketing campaign is a global status and can not be applied to a list"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-2","__idx":9},"children":["Example"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# Create: A wrapper for the CSV importer\ncurl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/csvimport \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n\t\t\"DataID\":\"$ID_DATA\",\n\t\t\"Method\":\"excludemarketing\"\n\t}'\n","lang":"shell"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"PHP","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\n/*\nCreate: A wrapper for the CSV importer\n*/\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));\n$body = [\n    'DataID' => \"$ID_DATA\",\n    'Method' => \"excludemarketing\"\n];\n$response = $mj->post(Resources::$Csvimport, ['body' => $body]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * Create: A wrapper for the CSV importer\n *\n */\nconst mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"csvimport\")\n\t.request({\n\t\t\"DataID\":\"$ID_DATA\",\n\t\t\"Method\":\"excludemarketing\"\n\t})\nrequest\n\t.then((result) => {\n\t\tconsole.log(result.body)\n\t})\n\t.catch((err) => {\n\t\tconsole.log(err.statusCode)\n\t})\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ruby","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# Create: A wrapper for the CSV importer\nrequire 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']  \nend\nvariable = Mailjet::Csvimport.create(data_id: \"$ID_DATA\",\nmethod: \"excludemarketing\"\n)\np variable.attributes['Data']\n","lang":"ruby"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nCreate: A wrapper for the CSV importer\n\"\"\"\nfrom mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret))\ndata = {\n  'DataID': '$ID_DATA',\n  'Method': 'excludemarketing'\n}\nresult = mailjet.csvimport.create(data=data)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.resource.Csvimport;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    /**\n     * Create: A wrapper for the CSV importer\n     */\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"));\n      request = new MailjetRequest(Csvimport.resource)\n\t\t\t.property(Csvimport.DATAID, \"$ID_DATA\")\n\t\t\t.property(Csvimport.METHOD, \"excludemarketing\");\n      response = client.post(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"/*\nCreate: A wrapper for the CSV importer\n*/\npackage main\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\tmailjet \"github.com/mailjet/mailjet-apiv3-go\"\n\t\"github.com/mailjet/mailjet-apiv3-go/resources\"\n)\nfunc main () {\n\tmailjetClient := NewMailjetClient(os.Getenv(\"MJ_APIKEY_PUBLIC\"), os.Getenv(\"MJ_APIKEY_PRIVATE\"))\n\tvar data []resources.Csvimport\n\tmr := &Request{\n\t  Resource: \"csvimport\",\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.Csvimport {\n      DataID: \"$ID_DATA\",\n      Method: \"excludemarketing\",\n    },\n\t}\n\terr := mailjetClient.Post(fmr, &data)\n\tif err != nil {\n\t  fmt.Println(err)\n\t}\n\tfmt.Printf(\"Data array: %+v\\n\", data)\n}\n","lang":"go"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n   class Program\n   {\n      /// <summary>\n      /// Create: A wrapper for the CSV importer\n      /// </summary>\n      static void Main(string[] args)\n      {\n         RunAsync().Wait();\n      }\n      static async Task RunAsync()\n      {\n         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"));\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Csvimport.Resource,\n         }\n            .Property(Csvimport.DataID, \"$ID_DATA\")\n            .Property(Csvimport.Method, \"excludemarketing\");\n         MailjetResponse response = await client.PostAsync(request);\n         if (response.IsSuccessStatusCode)\n         {\n            Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n            Console.WriteLine(response.GetData());\n         }\n         else\n         {\n            Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n            Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n            Console.WriteLine(response.GetData());\n            Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n         }\n      }\n   }\n}\n","lang":"csharp"},"children":[]}]}]}]},"headings":[{"value":"Manage your exclusion list","id":"manage-your-exclusion-list","depth":1},{"value":"Exclusion list overview","id":"exclusion-list-overview","depth":2},{"value":"Single contact exclusion","id":"single-contact-exclusion","depth":2},{"value":"Example","id":"example","depth":3},{"value":"API Response","id":"api-response","depth":3},{"value":"Bulk exclusion","id":"bulk-exclusion","depth":2},{"value":"Using /contact/managemanycontacts","id":"using-contactmanagemanycontacts","depth":3},{"value":"Example","id":"example-1","depth":3},{"value":"Using /csvimport","id":"using-csvimport","depth":3},{"value":"Example","id":"example-2","depth":3}],"frontmatter":{"title":"Mailjet Send Contact Management","seo":{"description":"Block Mailjet contacts from marketing campaigns via IsExcludedFromCampaigns; they still receive transactional Send API messages.","title":"Manage your exclusion list"}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/contact-management/manage-exclusion-list","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}