{"id":15285583,"url":"https://github.com/zenvia/zenvia-sdk-java","last_synced_at":"2025-10-27T04:07:41.046Z","repository":{"id":51638851,"uuid":"209392510","full_name":"zenvia/zenvia-sdk-java","owner":"zenvia","description":"Zenvia CPaaS SDK for Java","archived":false,"fork":false,"pushed_at":"2021-05-10T23:58:32.000Z","size":292,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-26T20:02:18.145Z","etag":null,"topics":["api","facebook","java","sdk","sms","whatsapp"],"latest_commit_sha":null,"homepage":"https://devs.zenvia.com/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenvia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-18T19:54:42.000Z","updated_at":"2025-03-24T11:39:45.000Z","dependencies_parsed_at":"2022-08-22T01:20:34.124Z","dependency_job_id":null,"html_url":"https://github.com/zenvia/zenvia-sdk-java","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenvia%2Fzenvia-sdk-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenvia%2Fzenvia-sdk-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenvia%2Fzenvia-sdk-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenvia%2Fzenvia-sdk-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenvia","download_url":"https://codeload.github.com/zenvia/zenvia-sdk-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657796,"owners_count":21140841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","facebook","java","sdk","sms","whatsapp"],"created_at":"2024-09-30T15:06:27.054Z","updated_at":"2025-10-27T04:07:40.972Z","avatar_url":"https://github.com/zenvia.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zenvia CPaaS SDK for Java\n\nThis SDK for [Java](https://www.java.com/) was created based on the [Zenvia](https://www.zenvia.com/) [API](https://zenvia.github.io/zenvia-openapi-spec/) and\n[Zenvia CPaaS SDK for Node.js](https://github.com/zenvia/zenvia-sdk-node).\n\n[![License](https://img.shields.io/github/license/zenvia/zenvia-sdk-java.svg)](LICENSE.md)\n[![Build Status](https://travis-ci.com/zenvia/zenvia-sdk-java.svg?branch=master)](https://travis-ci.com/zenvia/zenvia-sdk-java)\n[![Coverage Status](https://coveralls.io/repos/github/zenvia/zenvia-sdk-java/badge.svg?branch=master)](https://coveralls.io/github/zenvia/zenvia-sdk-java?branch=master)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.zenvia/zenvia-api-sdk/badge.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/com.zenvia/zenvia-api-sdk/)\n\n[![Twitter Follow](https://img.shields.io/twitter/follow/ZENVIA_.svg?style=social)](https://twitter.com/intent/follow?screen_name=ZENVIA_)\n\n## Table of Contents\n\n- [Features](#features)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Basic Usage](#basic-usage)\n- [Getting Started](#getting-started)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- [x] Text message content\n- [x] File message content\n- [x] Template message content\n- [x] Subscription handling\n- [x] Logging support\n\n## Prerequisites\n\n- [Sign up](https://www.zenvia.com/) for a Zenvia Account\n- [Java](https://www.java.com/)\n\n#### Obtain an API Token\n\nYou need to create an API token in the Zenvia [API console](https://app.zenvia.com/home/api).\n\n## Installation\n\n### Client\n\nIf using maven, add to your pom [this SDK](https://search.maven.org/search?q=g:com.zenvia+AND+a:zenvia-api-sdk-client-apache):\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.zenvia\u003c/groupId\u003e\n\t\u003cartifactId\u003ezenvia-api-sdk-client-apache\u003c/artifactId\u003e\n\t\u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIf you are using Gradle instead, add to your `build.gradle` [this SDK](https://search.maven.org/search?q=g:com.zenvia+AND+a:zenvia-api-sdk-client-apache):\n\n```groovy\ndependencies {\n    implementation group: 'com.zenvia', name: 'zenvia-api-sdk-client-apache', version: '1.1.0'\n}\n```\n\nYou can also use [the one](https://search.maven.org/search?q=g:com.zenvia+AND+a:zenvia-api-sdk-client-spring) that includes [Spring Boot](https://spring.io/projects/spring-boot):\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.zenvia\u003c/groupId\u003e\n\t\u003cartifactId\u003ezenvia-api-sdk-client-spring\u003c/artifactId\u003e\n\t\u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nor in `build.gradle`:\n\n```groovy\ndependencies {\n    implementation group: 'com.zenvia', name: 'zenvia-api-sdk-client-spring', version: '1.1.0'\n}\n```\n\n### Webhook Controller\n\nAdd to your pom [this SDK](https://search.maven.org/search?q=g:com.zenvia+AND+a:zenvia-api-sdk-webhook-jersey) for the WebhookController over `Jersey` framework:\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.zenvia\u003c/groupId\u003e\n\t\u003cartifactId\u003ezenvia-api-sdk-webhook-jersey\u003c/artifactId\u003e\n\t\u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nor in `build.gradle`:\n\n```groovy\ndependencies {\n    implementation group: 'com.zenvia', name: 'zenvia-api-sdk-webhook-jersey', version: '1.1.0'\n}\n```\n\nor [the one](https://search.maven.org/search?q=g:com.zenvia+AND+a:zenvia-api-sdk-webhook-webmvc) for the WebhookController over `Spring Web MVC` framework:\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.zenvia\u003c/groupId\u003e\n\t\u003cartifactId\u003ezenvia-api-sdk-webhook-webmvc\u003c/artifactId\u003e\n\t\u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nor in `build.gradle`\n\n```groovy\ndependencies {\n    implementation group: 'com.zenvia', name: 'zenvia-api-sdk-webhook-webmvc', version: '1.1.0'\n}\n```\n\n### Starters\n\nFor those using Spring Boot, consider ours [Starters](./zenvia-sdk-starters/README.md) to easily configure the Zenvia SDK in your project.\n\n## Basic Usage\n\n```Java\nimport com.zenvia.api.sdk.contents.*;\nimport com.zenvia.api.sdk.messages.Message;\nimport com.zenvia.api.sdk.client.Channel;\nimport com.zenvia.api.sdk.client.errors.ErrorResponse;\nimport com.zenvia.api.sdk.client.exceptions.ApiException;\nimport com.zenvia.api.sdk.client.exceptions.UnsuccessfulRequestException;\n\n// When using zenvia-api-sdk-client-apache\nimport com.zenvia.api.sdk.client.apache.Client;\n// When using zenvia-api-sdk-client-spring\nimport com.zenvia.api.sdk.client.spring.Client;\n\n\n// Initialization with your API token (x-api-token)\nClient client = new Client(\"YOUR_API_TOKEN\");\n\n// Choosing the channel\nChannel whatsapp = client.getChannel(\"whatsapp\");\n\n// Creating a text content\nContent content = new TextContent(\"some text message here\");\n\ntry {\n  Message response = whatsapp.sendMessage(\"sender-identifier\", \"recipient-identifier\", content);\n  // do something here\n} catch(UnsuccessfulRequestException exception) {\n  ErrorResponse response = exception.body;\n  // handle error here\n} catch(ApiException exception) {\n  // handle error here\n}\n```\n\n## Getting Started\n\n### Sending your first message\n\nUse the `sendMessage` method to send text (`TextContent`), file (`FileContent`) or template (`TemplateContent`) messages to your contacts.\n\n```java\nClient client = new Client(\"YOUR_API_TOKEN\");\nChannel sms = client.getChannel(\"sms\");\nTextContent content = new TextContent(\"some text message\");\ntry {\n  Message response = sms.sendMessage(\"sender-identifier\", \"recipient-identifier\", content);\n} catch(UnsuccessfulRequestException exception) {\n  ErrorResponse response = exception.body;\n}\n```\n\nThe response will be an `Message` object when successful, or an `ErrorResponse` object will be\navailable on the exception.\n\nThe content types can be:\n\n| Name            | Description                                      |\n| --------------- | ------------------------------------------------ |\n| TextContent     | Used to send text messages to your customer.     |\n| FileContent     | Used to send file messages to your customer.     |\n| TemplateContent | Used to send template messages to your customer. |\n\nThe content support by channel is described below.\n\n| Channel  | TextContent | FileContent | TemplateContent |\n| -------- | :---------: | :---------: | :-------------: |\n| SMS      |      X      |             |                 |\n| WhatsApp |      X      |      X      |        X        |\n| Facebook |      X      |      X      |                 |\n\n### Receiving message and message status events\n\nUse the `WebhookController` class to create your webhook to receive message and message status events. The default port is `8080`.\n\nIf you inform the `client`, `url`, and `channel` fields, a subscription will be created if it does not exist for these configurations.\n\nIn the `messageEventHandler` field you will receive the message events and in the `messageStatusEventHandler` field you will receive the message status events.\n\n```java\nClient client = new Client(\"YOUR_API_TOKEN\");\nWebhookController webhook = new WebhookController(\n  new ResourceConfig(), //or an instance of RequestMappingHandlerMapping when using Spring Wev MVC version\n  (MessageEvent messageEvent) -\u003e {\n    System.out.println(\"Message event:\" + messageEvent);\n  },\n  (MessageStatusEvent messageStatusEvent) -\u003e {\n    System.out.println(\"Message status event:\" + messageStatusEvent);\n  },\n  client,\n  \"https://my-webhook.company.com\",\n  ChannelType.whatsapp\n);\nwebhook.init();\n```\n\n## Contributing\n\nPull requests are always welcome!\n\nPlease see the [Contributors' Guide](CONTRIBUTING.md) for more information on contributing.\n\n## License\n\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenvia%2Fzenvia-sdk-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenvia%2Fzenvia-sdk-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenvia%2Fzenvia-sdk-java/lists"}