{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Mailjet Java SDK","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Install and use the official Mailjet Java wrapper: Maven setup, authentication, sending with Send API v3.1, REST requests, OkHttp options and SMS.","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":"java-sdk","__idx":0},"children":["Java SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The official Java wrapper for the Mailjet API is published to Maven Central as ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["com.mailjet:mailjet-client"]}]}," and developed at ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-java"},"children":["mailjet/mailjet-apiv3-java"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Current release: ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["6.0.0"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"compatibility","__idx":1},"children":["Compatibility"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The 6.x line runs on ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Java 11 or higher"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"installation","__idx":2},"children":["Installation"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"xml","header":{"controls":{"copy":{}}},"source":"<dependencies>\n    <dependency>\n        <groupId>com.mailjet</groupId>\n        <artifactId>mailjet-client</artifactId>\n        <version>6.0.0</version>\n    </dependency>\n</dependencies>\n","lang":"xml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"authentication","__idx":3},"children":["Authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Email API authenticates with your API key and secret:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"export MJ_APIKEY_PUBLIC='your API key'\nexport MJ_APIKEY_PRIVATE='your API secret'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"ClientOptions options = ClientOptions.builder()\n        .apiKey(System.getenv(\"MJ_APIKEY_PUBLIC\"))\n        .apiSecretKey(System.getenv(\"MJ_APIKEY_PRIVATE\"))\n        .build();\n\nMailjetClient client = new MailjetClient(options);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tip:"]}," register ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MailjetClient"]}," as a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["singleton"]}," and reuse it across sends. Creating a client per message wastes connections and threads."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SMS API authenticates with a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["bearer token"]}," instead — see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#sms-api"},"children":["SMS API"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"send-your-first-email","__idx":4},"children":["Send your first email"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The transactional email builder is the recommended path — it produces a typed message and handles serialisation for you."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"TransactionalEmail message = TransactionalEmail\n        .builder()\n        .to(new SendContact(\"passenger@example.com\", \"Passenger 1\"))\n        .from(new SendContact(\"pilot@example.com\", \"Mailjet Pilot\"))\n        .subject(\"Your email flight plan!\")\n        .htmlPart(\"<h1>This is the HTML content of the mail</h1>\")\n        .trackOpens(TrackOpens.ENABLED)\n        .attachment(Attachment.fromFile(attachmentPath))\n        .header(\"test-header-key\", \"test-value\")\n        .customID(\"custom-id-value\")\n        .build();\n\nSendEmailsRequest request = SendEmailsRequest\n        .builder()\n        .message(message) // up to 50 messages per request\n        .build();\n\nSendEmailsResponse response = request.sendWith(client);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Attachments can also be created from an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["InputStream"]},", which is useful when the file never touches disk."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"using-the-json-object-syntax","__idx":5},"children":["Using the JSON object syntax"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The older, untyped style is still supported and maps one-to-one onto the Send API v3.1 payload:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\n\nimport com.mailjet.client.ClientOptions;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.resource.Emailv31;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n\npublic class MyClass {\n    public static void main(String[] args) throws MailjetException {\n        ClientOptions options = ClientOptions.builder()\n                .apiKey(System.getenv(\"MJ_APIKEY_PUBLIC\"))\n                .apiSecretKey(System.getenv(\"MJ_APIKEY_PRIVATE\"))\n                .build();\n\n        MailjetClient client = new MailjetClient(options);\n\n        MailjetRequest request = new MailjetRequest(Emailv31.resource)\n                .property(Emailv31.MESSAGES, new JSONArray()\n                        .put(new JSONObject()\n                                .put(Emailv31.Message.FROM, new JSONObject()\n                                        .put(\"Email\", \"pilot@example.com\")\n                                        .put(\"Name\", \"Mailjet Pilot\"))\n                                .put(Emailv31.Message.TO, new JSONArray()\n                                        .put(new JSONObject()\n                                                .put(\"Email\", \"passenger@example.com\")\n                                                .put(\"Name\", \"Passenger 1\")))\n                                .put(Emailv31.Message.SUBJECT, \"My first Mailjet Email!\")\n                                .put(Emailv31.Message.TEXTPART, \"Greetings from Mailjet!\")\n                                .put(Emailv31.Message.HTMLPART, \"<h3>Dear passenger 1, welcome to Mailjet!</h3>\")));\n\n        MailjetResponse response = client.post(request);\n\n        System.out.println(response.getStatus());\n        System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"client-and-call-configuration","__idx":6},"children":["Client and call configuration"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"timeouts-and-request-logging","__idx":7},"children":["Timeouts and request logging"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The client is built on OkHttp. Pass a pre-configured ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OkHttpClient"]}," to control timeouts, logging, interceptors and connection pooling:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"HttpLoggingInterceptor logging = new HttpLoggingInterceptor();\nlogging.setLevel(Level.BASIC);\n\nOkHttpClient customHttpClient = new OkHttpClient.Builder()\n        .connectTimeout(60, TimeUnit.SECONDS)\n        .readTimeout(60, TimeUnit.SECONDS)\n        .writeTimeout(60, TimeUnit.SECONDS)\n        .addInterceptor(logging)\n        .build();\n\nClientOptions options = ClientOptions.builder()\n        .apiKey(System.getenv(\"MJ_APIKEY_PUBLIC\"))\n        .apiSecretKey(System.getenv(\"MJ_APIKEY_PRIVATE\"))\n        .okHttpClient(customHttpClient)\n        .build();\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://square.github.io/okhttp/"},"children":["OkHttp documentation"]}," for the full set of options."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-versioning","__idx":8},"children":["API versioning"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Version"},"children":["Version"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Scope"},"children":["Scope"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Email API"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3.1"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Send API v3.1 (latest send version)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v4"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SMS API"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You do not need to configure this. Since 5.0.0 the client derives the required version from the resource itself."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"base-url","__idx":9},"children":["Base URL"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The default base domain is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["api.mailjet.com"]},". Override it in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ClientOptions"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"ClientOptions options = ClientOptions.builder()\n        .baseUrl(\"https://api.us.mailjet.com\")\n        .apiKey(System.getenv(\"MJ_APIKEY_PUBLIC\"))\n        .apiSecretKey(System.getenv(\"MJ_APIKEY_PRIVATE\"))\n        .build();\n\nMailjetClient client = new MailjetClient(options);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Accounts on Mailjet's ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["US architecture"]}," must set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.us.mailjet.com"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"http-proxy","__idx":10},"children":["HTTP proxy"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The proxy is configured through the standard JVM system properties:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"-Dhttp.proxyHost=\n-Dhttp.proxyPort=\n\n-Dhttps.proxyHost=\n-Dhttps.proxyPort=\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you call other endpoints through ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["java.net.HttpURLConnection"]}," that should bypass the proxy:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"-Dhttp.nonProxyHosts=<hosts to exclude>\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"request-examples","__idx":11},"children":["Request examples"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Requests are ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MailjetRequest"]}," objects built from a resource constant, an optional ID, properties and filters. The full list of resources is in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-java/blob/master/src/main/java/com/mailjet/client/resource"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["src/main/java/com/mailjet/client/resource"]}]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"post--create-an-object","__idx":12},"children":["POST — create an object"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"MailjetRequest request = new MailjetRequest(Contact.resource)\n        .property(Contact.EMAIL, \"passenger@example.com\");\n\nMailjetResponse response = client.post(request);\n\nSystem.out.println(response.getStatus());\nSystem.out.println(response.getData());\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"post--endpoints-with-an-action","__idx":13},"children":["POST — endpoints with an action"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Action endpoints have their own resource object. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/contact/{id}/managecontactslists"]}," maps to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ContactManagecontactslists"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"MailjetRequest request = new MailjetRequest(ContactManagecontactslists.resource, contactId)\n        .property(ContactManagecontactslists.CONTACTSLISTS, new JSONArray()\n                .put(new JSONObject()\n                        .put(\"ListID\", listId1)\n                        .put(\"Action\", \"addnoforce\"))\n                .put(new JSONObject()\n                        .put(\"ListID\", listId2)\n                        .put(\"Action\", \"addforce\")));\n\nMailjetResponse response = client.post(request);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--all-objects","__idx":14},"children":["GET — all objects"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"MailjetRequest request = new MailjetRequest(Contact.resource);\nMailjetResponse response = client.get(request);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--with-filtering-and-sorting","__idx":15},"children":["GET — with filtering and sorting"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add filters with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".filter()"]},". Sorting takes a property name and an order (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ASC"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DESC"]},") separated by a space. Neither ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Sort"]}," nor descending order is available for every property."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"MailjetRequest request = new MailjetRequest(Contact.resource)\n        .filter(Contact.ISEXCLUDEDFROMCAMPAIGNS, \"false\")\n        .filter(\"Sort\", \"CreatedAt DESC\");\n\nMailjetResponse response = client.get(request);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--a-single-object","__idx":16},"children":["GET — a single object"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"MailjetRequest request = new MailjetRequest(Contact.resource, contactId);\nMailjetResponse response = client.get(request);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"put--update-an-object","__idx":17},"children":["PUT — update an object"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," in the Mailjet API behaves like a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PATCH"]},": only the properties you send are updated, everything else is left untouched, and non-mandatory properties can be omitted."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"MailjetRequest request = new MailjetRequest(Contactdata.resource, contactId)\n        .property(Contactdata.DATA, new JSONArray()\n                .put(new JSONObject()\n                        .put(\"Name\", \"Age\")\n                        .put(\"Value\", \"30\"))\n                .put(new JSONObject()\n                        .put(\"Name\", \"Country\")\n                        .put(\"Value\", \"US\")));\n\nMailjetResponse response = client.put(request);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"delete--remove-an-object","__idx":18},"children":["DELETE — remove an object"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A successful ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DELETE"]}," returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["204 No Content"]}," with no response body."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"MailjetRequest request = new MailjetRequest(Template.resource, templateId);\nMailjetResponse response = client.delete(request);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"sms-api","__idx":19},"children":["SMS API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SMS endpoints authenticate with a bearer token generated in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://app.mailjet.com/sms"},"children":["SMS section"]}," of your account:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"MailjetClient client = new MailjetClient(ClientOptions\n        .builder()\n        .bearerAccessToken(System.getenv(\"MJ_APITOKEN\"))\n        .build());\n\nMailjetRequest request = new MailjetRequest(SmsSend.resource)\n        .property(SmsSend.FROM, \"MJPilot\")\n        .property(SmsSend.TO, \"+4915200000000\")\n        .property(SmsSend.TEXT, \"Have a nice SMS flight with Mailjet!\");\n\nMailjetResponse response = client.post(request);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["More usage patterns are covered by the repository's ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-java/blob/master/src/test/java/com/mailjet/client/SendSmsIT.java"},"children":["integration tests"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"release-notes","__idx":20},"children":["Release notes"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Version"},"children":["Version"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Changes"},"children":["Changes"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["6.0.0"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Moves to Java 11; adds and updates unit tests"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5.2.6"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Fixes vulnerabilities; moves to Java 11"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5.2.4"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Adds file attachments to requests; fixes CSV upload through the Data API"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5.2.0"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Adds async methods, an automatic module name, and attachments from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["InputStream"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5.1.1"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Fixes extra quotes when serialising string variables and headers in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TransactionalEmailBuilder"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5.1.0"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Adds the transactional email builder; downgrades OkHttp to 3.12 for Spring Boot compatibility"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5.0.0"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Migrates to OkHttp; removes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ApiVersion"]}," from client config (resolved per resource); adds the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ClientOptions"]}," builder"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"other-examples","__idx":21},"children":["Other examples"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/fouad-j/aws-lambda-java-jetmail"},"children":["AWS Lambda integration"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"contribute","__idx":22},"children":["Contribute"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The wrapper is open source. Fork the repository, branch, implement your fix or feature, add documentation and specs, and open a pull request at ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-java"},"children":["mailjet/mailjet-apiv3-java"]},". Documentation improvements belong in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/api-documentation"},"children":["API documentation repo"]},"."]}]},"headings":[{"value":"Java SDK","id":"java-sdk","depth":1},{"value":"Compatibility","id":"compatibility","depth":2},{"value":"Installation","id":"installation","depth":2},{"value":"Authentication","id":"authentication","depth":2},{"value":"Send your first email","id":"send-your-first-email","depth":2},{"value":"Using the JSON object syntax","id":"using-the-json-object-syntax","depth":3},{"value":"Client and call configuration","id":"client-and-call-configuration","depth":2},{"value":"Timeouts and request logging","id":"timeouts-and-request-logging","depth":3},{"value":"API versioning","id":"api-versioning","depth":3},{"value":"Base URL","id":"base-url","depth":3},{"value":"HTTP proxy","id":"http-proxy","depth":3},{"value":"Request examples","id":"request-examples","depth":2},{"value":"POST — create an object","id":"post--create-an-object","depth":3},{"value":"POST — endpoints with an action","id":"post--endpoints-with-an-action","depth":3},{"value":"GET — all objects","id":"get--all-objects","depth":3},{"value":"GET — with filtering and sorting","id":"get--with-filtering-and-sorting","depth":3},{"value":"GET — a single object","id":"get--a-single-object","depth":3},{"value":"PUT — update an object","id":"put--update-an-object","depth":3},{"value":"DELETE — remove an object","id":"delete--remove-an-object","depth":3},{"value":"SMS API","id":"sms-api","depth":2},{"value":"Release notes","id":"release-notes","depth":2},{"value":"Other examples","id":"other-examples","depth":2},{"value":"Contribute","id":"contribute","depth":2}],"frontmatter":{"title":"Mailjet Java SDK","seo":{"title":"Mailjet Java SDK","description":"Install and use the official Mailjet Java wrapper: Maven setup, authentication, sending with Send API v3.1, REST requests, OkHttp options and SMS."}},"lastModified":"2026-08-26T16:26:02.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/developer-tools/java","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}