{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab","admonition"]},"type":"markdown"},"seo":{"title":"Single Contact Management","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Create, retrieve, and update individual Mailjet contacts via the /contact REST resource, including setting email, display name, and campaign exclusion status.","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":"single-contact-management","__idx":0},"children":["Single Contact Management"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"create-a-contact","__idx":1},"children":["Create a contact"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can create new contacts with a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]}," request on the contact resource."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example","__idx":2},"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":"curl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/contact \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n      \"IsExcludedFromCampaigns\":\"true\",\n      \"Name\":\"New Contact\",\n      \"Email\":\"passenger@mailjet.com\"\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'),true,['version' => 'v3']);\n$body = [\n  'IsExcludedFromCampaigns' => \"true\",\n  'Name' => \"New Contact\",\n  'Email' => \"passenger@mailjet.com\"\n];\n$response = $mj->post(Resources::$Contact, ['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":"const mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"contact\", {'version': 'v3'})\n\t.request({\n      \"IsExcludedFromCampaigns\":\"true\",\n      \"Name\":\"New Contact\",\n      \"Email\":\"passenger@mailjet.com\"\n    })\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":"require 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.api_version = \"v3\"\nend\nvariable = Mailjet::Contact.create(\n  is_excluded_from_campaigns: \"true\",\n  name: \"New Contact\",\n  email: \"passenger@mailjet.com\"\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":"from 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), version='v3')\ndata = {\n  'IsExcludedFromCampaigns': \"true\",\n  'Name': \"New Contact\",\n  'Email': \"passenger@mailjet.com\"\n}\nresult = mailjet.contact.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.ClientOptions;\nimport com.mailjet.client.resource.Contact;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\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\"), new ClientOptions(\"v3\"));\n      request = new MailjetRequest(Contact.resource)\n            .property(Contact.ISEXCLUDEDFROMCAMPAIGNS, \"true\")\n            .property(Contact.NAME, \"New Contact\")\n            .property(Contact.EMAIL, \"passenger@mailjet.com\")\n      );\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":"package 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.Contact\n\tmr := &Request{\n\t  Resource: \"contact\",\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.Contact { \n\t  IsExcludedFromCampaigns:\"true\",\n\t  Name:\"New Contact\",\n\t  Email:\"passenger@mailjet.com\"\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      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         {\n            Version = ApiVersion.V3,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Contact.Resource,\n         }\n             .Property(Contact.IsExcludedFromCampaigns, \"true\")\n             .Property(Contact.Name, \"New Contact\")\n             .Property(Contact.Email, \"passenger@mailjet.com\");\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":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response","__idx":3},"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\"IsExcludedFromCampaigns\": true,\n\t\t\t\"Name\": \"New Contact\",\n\t\t\t\"CreatedAt\": \"2018-01-01T00:00:00\",\n\t\t\t\"DeliveredCount\": 10,\n\t\t\t\"Email\": \"passenger@mailjet.com\",\n\t\t\t\"ExclusionFromCampaignsUpdatedAt\": \"2018-01-01T00:00:00\",\n\t\t\t\"ID\": 123456789,\n\t\t\t\"IsOptInPending\": false,\n\t\t\t\"IsSpamComplaining\": false,\n\t\t\t\"LastActivityAt\": \"2018-01-01T00:00:00\",\n\t\t\t\"LastUpdateAt\": \"2018-01-01T00:00:00\",\n\t\t\t\"UnsubscribedAt\": \"2018-01-01T00:00:00\",\n\t\t\t\"UnsubscribedBy\": \"2018-01-01T00:00:00\"\n\t\t}\n\t],\n\t\"Total\": 1\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"manage-contact-properties","__idx":4},"children":["Manage Contact Properties"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you want to add more granular details about your contacts, Mailjet provides the capability to add custom data to contacts. This additional data can help you personalize the emails you are sending, and allows you to target specific sections of your customers using segmentation."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The addition of custom data starts with the definition of the extra information to store with the contacts (It could be for example the country the contacts live in, how old the contacts are, their current income, the value of their purchases on your site...) and how this data will be stored (string, number, boolean...)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To define custom contact data, perform a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]}," on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/contactmetadata"]}," with the following properties:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Name"]}," : the name of the custom data field"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DataType"]}," : the type of data that is being stored (this can be either a str, int, float, datetime or bool)"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NameSpace"]}," : this can be either ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["static"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["historic"]}," (legacy)"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Keep in mind that the accepted formats for a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["datetime"]}," data type are Unix timestamp ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["(e.g. 1514764800)"]},"and RFC3339 (e.g. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2018-01-01T00:00:00"]},")"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-1","__idx":5},"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":"curl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/contactmetadata \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n      \"Datatype\":\"str\",\n      \"Name\":\"first_name\",\n      \"NameSpace\":\"static\"\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'),true,['version' => 'v3']);\n$body = [\n  'Datatype' => \"str\",\n  'Name' => \"first_name\",\n  'NameSpace' => \"static\"\n];\n$response = $mj->post(Resources::$Contactmetadata, ['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":"const mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"contactmetadata\", {'version': 'v3'})\n\t.request({\n      \"Datatype\":\"str\",\n      \"Name\":\"first_name\",\n      \"NameSpace\":\"static\"\n    })\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":"require 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.api_version = \"v3\"\nend\nvariable = Mailjet::Contactmetadata.create(\n  datatype: \"str\",\n  name: \"first_name\",\n  name_space: \"static\"\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":"from 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), version='v3')\ndata = {\n  'Datatype': \"str\",\n  'Name': \"first_name\",\n  'NameSpace': \"static\"\n}\nresult = mailjet.contactmetadata.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.ClientOptions;\nimport com.mailjet.client.resource.Contactmetadata;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\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\"), new ClientOptions(\"v3\"));\n      request = new MailjetRequest(Contactmetadata.resource)\n            .property(Contactmetadata.DATATYPE, \"str\")\n            .property(Contactmetadata.NAME, \"first_name\")\n            .property(Contactmetadata.NAMESPACE, \"static\")\n      );\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":"package 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.Contactmetadata\n\tmr := &Request{\n\t  Resource: \"contactmetadata\",\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.Contactmetadata { \n\t  Datatype:\"str\",\n\t  Name:\"first_name\",\n\t  NameSpace:\"static\"\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      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         {\n            Version = ApiVersion.V3,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Contactmetadata.Resource,\n         }\n             .Property(Contactmetadata.Datatype, \"str\")\n             .Property(Contactmetadata.Name, \"first_name\")\n             .Property(Contactmetadata.NameSpace, \"static\");\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":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response-1","__idx":6},"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\"Datatype\": \"str\",\n\t\t\t\"ID\": 4321,\n\t\t\t\"Name\": \"first_name\",\n\t\t\t\"NameSpace\": \"static\"\n\t\t}\n\t],\n\t\"Total\": 1\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To add, edit or update the data saved for a specific contact, do a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," request on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/contactdata/{contact_ID or contact_email}"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-2","__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":"curl -s \\\n\t-X PUT \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/contactdata/$contact_ID \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n      \"Data\":[\n        {\n          \"Name\":\"first_name\",\n          \"Value\":\"John\"\n        }\n      ]\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'),true,['version' => 'v3']);\n$body = [\n  'Data' => [\n    [\n      'Name' => \"first_name\",\n      'Value' => \"John\"\n    ]\n  ]\n];\n$response = $mj->put(Resources::$Contactdata, ['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":"const mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.put(\"contactdata\", {'version': 'v3'})\n\t.id($contact_ID)\n\t.request({\n      \"Data\":[\n        {\n          \"Name\":\"first_name\",\n          \"Value\":\"John\"\n        }\n      ]\n    })\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":"require 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.api_version = \"v3\"\nend\ntarget = Mailjet::Contactdata.find($contact_ID)\ntarget.update_attributes(\n  data: [\n    {\n      'name' => \"first_name\",\n      'value' => \"John\"\n    }\n  ]\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":"from 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), version='v3')\nid = '$contact_ID'\ndata = {\n  'Data': [\n    {\n      \"Name\": \"first_name\",\n      \"Value\": \"John\"\n    }\n  ]\n}\nresult = mailjet.contactdata.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.ClientOptions;\nimport com.mailjet.client.resource.Contactdata;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\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\"), new ClientOptions(\"v3\"));\n      request = new MailjetRequest(Contactdata.resource, ID)\n            .property(Contactdata.DATA, new JSONArray()\n                .put(new JSONObject()\n                    .put(\"Name\", \"first_name\")\n                    .put(\"Value\", \"John\")\n                )\n            )\n      );\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":"package 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: \"contactdata\",\n\t  ID: RESOURCE_ID,\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.Contactdata { \n      Data: []MailjetDat {\n          MailjetDat {\n            Name:\"first_name\",\n            Value:\"John\"\n          }\n        }\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      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         {\n            Version = ApiVersion.V3,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Contactdata.Resource,\n            ResourceId = ResourceId.Numeric(ID)\n         }\n             .Property(Contactdata.Data, new JArray {\n                 new JObject {\n                     {\"Name\", \"first_name\"},\n                     {\"Value\", \"John\"}\n                 }\n             });\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-2","__idx":8},"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\"Data\": [\n\t\t\t\t{}\n\t\t\t],\n\t\t\t\"ContactID\": 123456,\n\t\t\t\"ID\": 123456\n\t\t}\n\t],\n\t\"Total\": 1\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Contact data can also be added for multiple contacts at the same time by using the bulk contact management resources."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"create-a-contact-list","__idx":9},"children":["Create a contact list"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Contact lists are created with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]}," request on the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/contactslist"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-3","__idx":10},"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":"curl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/contactslist \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n      \"Name\":\"my_contactslist\"\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'),true,['version' => 'v3']);\n$body = [\n  'Name' => \"my_contactslist\"\n];\n$response = $mj->post(Resources::$Contactslist, ['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":"const mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"contactslist\", {'version': 'v3'})\n\t.request({\n      \"Name\":\"my_contactslist\"\n    })\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":"require 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.api_version = \"v3\"\nend\nvariable = Mailjet::Contactslist.create(\n  name: \"my_contactslist\"\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":"from 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), version='v3')\ndata = {\n  'Name': \"my_contactslist\"\n}\nresult = mailjet.contactslist.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.ClientOptions;\nimport com.mailjet.client.resource.Contactslist;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\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\"), new ClientOptions(\"v3\"));\n      request = new MailjetRequest(Contactslist.resource)\n            .property(Contactslist.NAME, \"my_contactslist\")\n      );\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":"package 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.Contactslist\n\tmr := &Request{\n\t  Resource: \"contactslist\",\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.Contactslist { \n\t  Name:\"my_contactslist\"\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      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         {\n            Version = ApiVersion.V3,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Contactslist.Resource,\n         }\n             .Property(Contactslist.Name, \"my_contactslist\");\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":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response-3","__idx":11},"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\"Name\": \"my_contactslist\",\n\t\t\t\"Address\": \"abcdef123\",\n\t\t\t\"CreatedAt\": \"2018-01-01T00:00:00\",\n\t\t\t\"ID\": 123456,\n\t\t\t\"SubscriberCount\": 111\n\t\t}\n\t],\n\t\"Total\": 1\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-a-contact-to-a-contact-list","__idx":12},"children":["Add a contact to a contact list"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To add a contact to a list, you need to create a new list recipient with a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]}," request on the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/listrecipient"]}," resource. You can specify the contact by either providing the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["contact ID"]}," (in ContactID) or email address (in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ContactAlt"]},"), as well as the list with either the list ID (in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ListID"]},") or the list name (in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ListAlt"]},")."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-4","__idx":13},"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":"curl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/listrecipient \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n      \"IsUnsubscribed\":\"true\",\n      \"ContactID\":\"987654321\",\n      \"ContactAlt\":\"passenger@mailjet.com\",\n      \"ListID\":\"123456\",\n      \"ListAlt\":\"abcdef123\"\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'),true,['version' => 'v3']);\n$body = [\n  'IsUnsubscribed' => \"true\",\n  'ContactID' => \"987654321\",\n  'ContactAlt' => \"passenger@mailjet.com\",\n  'ListID' => \"123456\",\n  'ListAlt' => \"abcdef123\"\n];\n$response = $mj->post(Resources::$Listrecipient, ['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":"const mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"listrecipient\", {'version': 'v3'})\n\t.request({\n      \"IsUnsubscribed\":\"true\",\n      \"ContactID\":\"987654321\",\n      \"ContactAlt\":\"passenger@mailjet.com\",\n      \"ListID\":\"123456\",\n      \"ListAlt\":\"abcdef123\"\n    })\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":"require 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.api_version = \"v3\"\nend\nvariable = Mailjet::Listrecipient.create(\n  is_unsubscribed: \"true\",\n  contact_id: \"987654321\",\n  contact_alt: \"passenger@mailjet.com\",\n  list_id: \"123456\",\n  list_alt: \"abcdef123\"\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":"from 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), version='v3')\ndata = {\n  'IsUnsubscribed': \"true\",\n  'ContactID': \"987654321\",\n  'ContactAlt': \"passenger@mailjet.com\",\n  'ListID': \"123456\",\n  'ListAlt': \"abcdef123\"\n}\nresult = mailjet.listrecipient.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.ClientOptions;\nimport com.mailjet.client.resource.Listrecipient;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\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\"), new ClientOptions(\"v3\"));\n      request = new MailjetRequest(Listrecipient.resource)\n            .property(Listrecipient.ISUNSUBSCRIBED, \"true\")\n            .property(Listrecipient.CONTACTID, \"987654321\")\n            .property(Listrecipient.CONTACTALT, \"passenger@mailjet.com\")\n            .property(Listrecipient.LISTID, \"123456\")\n            .property(Listrecipient.LISTALT, \"abcdef123\")\n      );\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":"package 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.Listrecipient\n\tmr := &Request{\n\t  Resource: \"listrecipient\",\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.Listrecipient { \n\t  IsUnsubscribed:\"true\",\n\t  ContactID:\"987654321\",\n\t  ContactAlt:\"passenger@mailjet.com\",\n\t  ListID:\"123456\",\n\t  ListAlt:\"abcdef123\"\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      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         {\n            Version = ApiVersion.V3,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Listrecipient.Resource,\n         }\n             .Property(Listrecipient.IsUnsubscribed, \"true\")\n             .Property(Listrecipient.ContactID, \"987654321\")\n             .Property(Listrecipient.ContactAlt, \"passenger@mailjet.com\")\n             .Property(Listrecipient.ListID, \"123456\")\n             .Property(Listrecipient.ListAlt, \"abcdef123\");\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":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response-4","__idx":14},"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\"IsUnsubscribed\": true,\n\t\t\t\"ContactID\": 987654321,\n\t\t\t\"ID\": 1234567890,\n\t\t\t\"IsActive\": true,\n\t\t\t\"ListID\": 123456,\n\t\t\t\"ListName\": \"abcdef123\",\n\t\t\t\"SubscribedAt\": \"2018-01-01T00:00:00\",\n\t\t\t\"UnsubscribedAt\": \"2018-01-01T00:00:00\"\n\t\t}\n\t],\n\t\"Total\": 1\n}\n"},"children":[]}]},"headings":[{"value":"Single Contact Management","id":"single-contact-management","depth":1},{"value":"Create a contact","id":"create-a-contact","depth":2},{"value":"Example","id":"example","depth":3},{"value":"API Response","id":"api-response","depth":3},{"value":"Manage Contact Properties","id":"manage-contact-properties","depth":2},{"value":"Example","id":"example-1","depth":3},{"value":"API Response","id":"api-response-1","depth":3},{"value":"Example","id":"example-2","depth":3},{"value":"API Response","id":"api-response-2","depth":3},{"value":"Create a contact list","id":"create-a-contact-list","depth":2},{"value":"Example","id":"example-3","depth":3},{"value":"API Response","id":"api-response-3","depth":3},{"value":"Add a contact to a contact list","id":"add-a-contact-to-a-contact-list","depth":2},{"value":"Example","id":"example-4","depth":3},{"value":"API Response","id":"api-response-4","depth":3}],"frontmatter":{"title":"Mailjet Send Contact Management","seo":{"description":"Create, retrieve, and update individual Mailjet contacts via the /contact REST resource, including setting email, display name, and campaign exclusion status.","title":"Single Contact Management"}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/contact-management/single-contact","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}