{"id":13511852,"url":"https://github.com/twilio/twilio-java","last_synced_at":"2025-08-07T01:53:23.979Z","repository":{"id":664414,"uuid":"307476","full_name":"twilio/twilio-java","owner":"twilio","description":"A Java library for communicating with the Twilio REST API and generating TwiML.","archived":false,"fork":false,"pushed_at":"2025-07-31T16:03:33.000Z","size":44356,"stargazers_count":507,"open_issues_count":37,"forks_count":446,"subscribers_count":76,"default_branch":"main","last_synced_at":"2025-07-31T23:06:29.062Z","etag":null,"topics":["api","mms","phone","sms","telephony","twilio","twiml","video","voice","wireless"],"latest_commit_sha":null,"homepage":"","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/twilio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2009-09-15T06:04:28.000Z","updated_at":"2025-07-25T14:15:03.000Z","dependencies_parsed_at":"2024-03-26T14:25:46.658Z","dependency_job_id":"eec0ca4b-2a23-4e01-aa43-1b9b064a4e93","html_url":"https://github.com/twilio/twilio-java","commit_stats":{"total_commits":1950,"total_committers":146,"mean_commits":"13.356164383561644","dds":0.8512820512820513,"last_synced_commit":"b5076e1a53fe934851a1a2325aec3e848b3e2bd9"},"previous_names":[],"tags_count":415,"template":false,"template_full_name":null,"purl":"pkg:github/twilio/twilio-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twilio","download_url":"https://codeload.github.com/twilio/twilio-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-java/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268805484,"owners_count":24309971,"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","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","mms","phone","sms","telephony","twilio","twiml","video","voice","wireless"],"created_at":"2024-08-01T03:01:13.929Z","updated_at":"2025-08-07T01:53:23.971Z","avatar_url":"https://github.com/twilio.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# twilio-java\n\n[![Tests](https://github.com/twilio/twilio-java/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/twilio/twilio-java/actions/workflows/test-and-deploy.yml)\n[![Maven Central](https://img.shields.io/maven-central/v/com.twilio.sdk/twilio.svg)](https://mvnrepository.com/artifact/com.twilio.sdk/twilio)\n[![Learn with TwilioQuest](https://img.shields.io/static/v1?label=TwilioQuest\u0026message=Learn%20to%20contribute%21\u0026color=F22F46\u0026labelColor=1f243c\u0026style=flat-square\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5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Jggg==)](https://twil.io/learn-open-source)\n[![libs.tech recommends](https://libs.tech/project/307476/badge.svg)](https://libs.tech/project/307476/twilio-java)\n\n## Documentation\n\nThe documentation for the Twilio API can be found [here][apidocs].\n\nThe Java library documentation can be found [here][libdocs].\n\n## Versions\n\n`twilio-java` uses a modified version of [Semantic Versioning](https://semver.org) for all changes. [See this document](VERSIONS.md) for details.\n\n### TLS 1.2 Requirements\n\nNew accounts and subaccounts are now required to use TLS 1.2 when accessing the REST API. [\"Upgrade Required\" errors](https://www.twilio.com/docs/api/errors/20426) indicate that TLS 1.0/1.1 is being used.\n\n### Supported Java Versions\n\nThis library supports the following Java implementations:\n\n- OpenJDK 8\n- OpenJDK 11\n- OpenJDK 17\n- OracleJDK 8\n- OracleJDK 11\n- OracleJDK 17\n\nFor Java 7 support, use `twilio-java` major version `7.X.X`.\n\n### Beta Annotation\n\nTo indicate that a class or method is in beta and subject to change, we use the `@Beta` annotation. For example:\n\n```java\n\n@Beta\npublic class ClassName {\n  // Class implementation\n}\n\n\npublic class ClassName {\n  @Beta\n  public void init() {\n    // Implementation\n  }\n}\n```\n\n## Installation\n\n`twilio-java` uses Maven. At present the jars _are_ available from a public [maven](https://mvnrepository.com/artifact/com.twilio.sdk/twilio) repository.\n\nUse the following dependency in your project to grab via Maven:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.twilio.sdk\u003c/groupId\u003e\n  \u003cartifactId\u003etwilio\u003c/artifactId\u003e\n  \u003cversion\u003e11.X.X-rc.x\u003c/version\u003e\n  \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\nor Gradle:\n\n```groovy\nimplementation \"com.twilio.sdk:twilio:11.X.X-rc.x\"\n```\n\nIf you want to compile it yourself, here's how:\n\n```shell\ngit clone git@github.com:twilio/twilio-java\ncd twilio-java\nmvn install       # Requires maven, download from https://maven.apache.org/download.html\n```\n\nIf you want to build your own .jar, execute the following from within the cloned directory:\n\n```shell\nmvn package\n```\n\nIf you run into trouble with local tests, use:\n\n```shell\nmvn package -Dmaven.test.skip=true\n```\n\n### Test your installation\n\nTry sending yourself an SMS message, like this:\n\n```java\nimport com.twilio.Twilio;\nimport com.twilio.rest.api.v2010.account.Message;\nimport com.twilio.type.PhoneNumber;\n\npublic class Example {\n\n  // Find your Account Sid and Token at console.twilio.com\n  public static final String ACCOUNT_SID = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\";\n  public static final String AUTH_TOKEN = \"your_auth_token\";\n\n  public static void main(String[] args) {\n    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);\n\n    Message message = Message\n      .creator(\n        new PhoneNumber(\"+15558675309\"),\n        new PhoneNumber(\"+15017250604\"),\n        \"This is the ship that made the Kessel Run in fourteen parsecs?\"\n      )\n      .create();\n\n    System.out.println(message.getSid());\n  }\n}\n```\n\n\u003e **Warning**\n\u003e It's okay to hardcode your credentials when testing locally, but you should use environment variables to keep them secret before committing any code or deploying to production. Check out [How to Set Environment Variables](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html) for more information.\n\n## Usage\n\n### Initialize the Client\n\n```java\nimport com.twilio.Twilio;\nimport com.twilio.exception.AuthenticationException;\n\npublic class Example {\n\n  private static final String ACCOUNT_SID =\n    \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\";\n  private static final String AUTH_TOKEN = \"your_auth_token\";\n\n  public static void main(String[] args) throws AuthenticationException {\n    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);\n  }\n}\n```\n### Initialize the client when endpoints does not use basic authentication\nThe above example shows how to initialize the client in case the endpoints use basic authentication. When the endpoint does not require any authentication, use TwilioNoAuth client instead.\nThere are endpoints like Organization domain which uses bearer token authentication. Custom Clients needs to be used in such cases and initialize them with the values required for access token generation.\n\nTo bypass the initialization step you can also use a custom token manager implementation. Token manager class should implement the Token interface and call a token generation endpoint of your choice.\nDetailed examples [here](https://github.com/twilio/twilio-java/tree/main/examples)\n\n### Environment Variables\n\n`twilio-java` supports the credentials, region, and edge values stored in the following environment variables:\n\n- `TWILIO_ACCOUNT_SID`\n- `TWILIO_AUTH_TOKEN`\n- `TWILIO_REGION`\n- `TWILIO_EDGE`\n\nIf using these variables, the above client initialization can be skipped.\n\n### Make a Call\n\n```java\nimport com.twilio.Twilio;\nimport com.twilio.rest.api.v2010.account.Call;\nimport com.twilio.type.PhoneNumber;\nimport java.net.URI;\nimport java.net.URISyntaxException;\n\npublic class Example {\n\n  public static final String ACCOUNT_SID = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\";\n  public static final String AUTH_TOKEN = \"your_auth_token\";\n\n  public static void main(String[] args) throws URISyntaxException {\n    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);\n\n    Call call = Call\n      .creator(\n        new PhoneNumber(\"+14155551212\"),\n        new PhoneNumber(\"+15017250604\"),\n        new URI(\"http://demo.twilio.com/docs/voice.xml\")\n      )\n      .create();\n\n    System.out.println(call.getSid());\n  }\n}\n```\n\n### Get an existing Call\n\n```java\nimport com.twilio.Twilio;\nimport com.twilio.rest.api.v2010.account.Call;\n\npublic class Example {\n\n  public static final String ACCOUNT_SID = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\";\n  public static final String AUTH_TOKEN = \"your_auth_token\";\n\n  public static void main(String[] args) {\n    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);\n\n    Call call = Call.fetcher(\"CA42ed11f93dc08b952027ffbc406d0868\").fetch();\n\n    System.out.println(call.getTo());\n  }\n}\n```\n\n\n\n### OAuth Feature for Twilio APIs\nWe are introducing Client Credentials Flow-based OAuth 2.0 authentication. \nThis feature is currently in `beta` and its implementation is subject to change.\n\n- API examples [here](https://github.com/twilio/twilio-java/blob/main/examples/FetchMessageUsingOAuth.md)\n- Organisation API examples [here](https://github.com/twilio/twilio-java/blob/main/examples/BearerTokenAuthentication.md)\n\n### Iterate through records\n\nThe library automatically handles paging for you. With the `read` method, you can specify the number of records you want to receive (`limit`) and the maximum size you want each page fetch to be (`pageSize`). The library will then handle the task for you, fetching new pages under the hood as you iterate over the records.\n\nFor more information, view the [auto-generated library docs](https://www.twilio.com/docs/libraries/reference/twilio-java/).\n\n#### Use the `read` method\n\n```java\nimport com.twilio.Twilio;\nimport com.twilio.base.ResourceSet;\nimport com.twilio.rest.api.v2010.account.Call;\n\npublic class Example {\n\n  public static final String ACCOUNT_SID = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\";\n  public static final String AUTH_TOKEN = \"your_auth_token\";\n\n  public static void main(String[] args) {\n    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);\n\n    ResourceSet\u003cCall\u003e calls = Call.reader().read();\n\n    for (Call call : calls) {\n      System.out.println(call.getDirection());\n    }\n  }\n}\n```\n\n### Specify Region and/or Edge\n\nTo take advantage of Twilio's [Global Infrastructure](https://www.twilio.com/docs/global-infrastructure), specify the target Region and/or Edge for the client:\n\n```java\nTwilio.init(accountSid, authToken);\nTwilio.setRegion(\"au1\");\nTwilio.setEdge(\"sydney\");\n```\n\nThis will result in the `hostname` transforming from `api.twilio.com` to `api.sydney.au1.twilio.com`.\n\nTo use multiple region within same application, refer [MultiRegionClient.md](https://github.com/twilio/twilio-java/blob/main/examples/MultiRegionClient.md)\n\n### Enable Debug Logging\n\nThis library uses SLF4J for logging. Consult the [SFL4J documentation](http://slf4j.org/docs.html) for information about logging configuration.\n\nFor example, if you are using `log4j`:\n\n- Make sure you have `log4j-slf4j-impl`, `log4j-core` and `log4j-api` in your `pom.xml` file\n- Define the logging level for the Twilio HTTP client in your configuration. For example, in `src/main/resources/log4j2.xml`:\n\n  ```xml\n  \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n  \u003cConfiguration status=\"WARN\"\u003e\n      \u003cAppenders\u003e\n          \u003cConsole name=\"Console\" target=\"SYSTEM_OUT\"\u003e\n              \u003cPatternLayout pattern=\"%d{HH:mm:ss.SSS} %-5level - %msg%n\"/\u003e\n          \u003c/Console\u003e\n      \u003c/Appenders\u003e\n      \u003cLoggers\u003e\n          \u003c!--Your Twilio logging configuration goes here--\u003e\n          \u003cLogger name=\"com.twilio.http\" level=\"debug\" additivity=\"false\"\u003e\n              \u003cAppenderRef ref=\"Console\"/\u003e\n          \u003c/Logger\u003e\n          \u003cRoot level=\"info\"\u003e\n              \u003cAppenderRef ref=\"Console\"/\u003e\n          \u003c/Root\u003e\n      \u003c/Loggers\u003e\n  \u003c/Configuration\u003e\n  ```\n\n### Handle Exceptions\n\n```java\nimport com.twilio.exception.ApiException;\n\ntry {\n    Message message = Message.creator(\n        new PhoneNumber(\"+15558881234\"),  // To number\n        new PhoneNumber(\"+15559994321\"),  // From number\n        \"Hello world!\"                    // SMS body\n    ).create();\n\n    System.out.println(message.getSid());\n} catch (final ApiException e) {\n    System.err.println(e);\n}\n```\n\n### Use a Client With PKCV Authentication\n\nAdditional documentation here: https://twilio.com/docs/iam/pkcv/quickstart\n\n```java\nValidationClient httpClient = new ValidationClient(ACCOUNT_SID, key.getSid(), signingKey.getSid(), pair.getPrivate());\nTwilioRestClient client = new TwilioRestClient.Builder(signingKey.getSid(), signingKey.getSecret())\n    .accountSid(ACCOUNT_SID)\n    .httpClient(httpClient)\n    .build();\n```\n\n### Generate TwiML\n\nTo control phone calls, your application needs to output [TwiML][twiml].\n\nTwiML in twilio-java now use the builder pattern!\n\n```java\nTwiML twiml = new VoiceResponse.Builder()\n    .say(new Say.Builder(\"Hello World!\").build())\n    .play(new Play.Builder(\"https://api.twilio.com/cowbell.mp3\").loop(5).build())\n    .build();\n```\n\nThat will output XML that looks like this:\n\n```xml\n\u003cResponse\u003e\n    \u003cSay\u003eHello World!\u003c/Say\u003e\n    \u003cPlay loop=\"5\"\u003ehttps://api.twilio.com/cowbell.mp3\u003c/Play\u003e\n\u003c/Response\u003e\n```\n\n### Use a custom HTTP Client\n\nTo use a custom HTTP client with this helper library, please see the [advanced example of how to do so](./advanced-examples/custom-http-client.md).\n\n## Docker image\n\nThe `Dockerfile` present in this repository and its respective `twilio/twilio-java` Docker image are currently used by Twilio for testing purposes only.\n\n## Getting Help\n\nIf you need help installing or using the library, please check the [Twilio Support Help Center](https://support.twilio.com) first, and [file a support ticket](https://twilio.com/help/contact) if you don't find an answer to your question.\n\nIf you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!\n\n[apidocs]: https://www.twilio.com/docs/api\n[twiml]: https://www.twilio.com/docs/api/twiml\n[libdocs]: https://twilio.github.io/twilio-java\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilio%2Ftwilio-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwilio%2Ftwilio-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilio%2Ftwilio-java/lists"}