All examples read the API key from the DIDWW_API_KEY environment variable and run against the sandbox. WebhookExample sends no request and needs no API key.
- Java 11+
- Gradle wrapper (
./gradlew) - DIDWW API key for sandbox account
DIDWW_API_KEY(required): your DIDWW API keyFILE_PATH(optional forUploadFileExample): file to encrypt. Generates a sample PDF if not setXDG_CACHE_HOME(optional forPricesDownloadExample, Linux and other Unix systems): user cache directory,~/.cacheif not setDIDWW_README_PROXY_URL(optional forTestReadmeExample): HTTP proxy for the HTTP client check, such ashttp://proxy.example.com:3128; the check is skipped if not setDIDWW_README_REDIS_URL(optional forTestReadmeExample): Redis server for the token store check, such asredis://localhost:6379/0; the check is skipped if not setDIDWW_README_PRODUCTION_API_KEY(optional forTestReadmeExample): API key of a production account for the production client check, which only reads (balance, countries, one price lookup) with a read-only token; the check is skipped if not set
Use the runExample Gradle task with -PexampleClass:
DIDWW_API_KEY=your_api_key ./gradlew runExample -PexampleClass=com.didww.examples.BalanceExampleSome examples take an optional argument. Pass it with Gradle's --args; relative paths resolve against the project directory:
DIDWW_API_KEY=your_api_key ./gradlew runExample -PexampleClass=com.didww.examples.PricesLookupExample --args="18005550123"
DIDWW_API_KEY=your_api_key ./gradlew runExample -PexampleClass=com.didww.examples.PricesDownloadExample --args="/path/to/dir"All classes are in the package com.didww.examples.
| Class | Description |
|---|---|
BalanceExample |
Prints the account balance: total balance, balance and credit. |
CountriesExample |
Lists countries, filters them, and finds one country by ID. |
RegionsExample |
Lists the regions of a country with filters and the included country, and finds one region. |
DidGroupsExample |
Lists DID groups with their included SKUs, number type and demo flag, and shows group details. |
DidHistoryExample |
Lists DID history events (last 90 days) with action and date filters. |
DidsExample |
Lists DIDs and updates the last ordered one: trunk, capacity pool, capacity limit and description. |
DidTrunkAssignmentExample |
Assigns a DID to a trunk, then to a trunk group (the trunk is cleared: they are exclusive), and restores the DID's routing. |
DidSmsRoutingExample |
Routes a DID's inbound SMS to an SMS trunk, then to an SMS trunk group (exclusive), and restores the routing. |
DidReservationsExample |
Reserves an available DID, lists and finds reservations, and deletes the reservation. |
CapacityPoolsExample |
Lists capacity pools with their included shared capacity groups and qty-based pricings, and finds one pool. |
SharedCapacityGroupsExample |
Creates a shared capacity group in a capacity pool, lists the groups, renames it and deletes it. |
OrdersExample |
Lists the most recent orders, orders a DID by SKU and cancels (deletes) that order. |
OrdersSkuExample |
Orders DIDs by SKU and quantity (did_order_items with sku_id and qty). |
OrdersAvailableDidsExample |
Orders a specific available DID with an SKU of its included DID group. |
OrdersReservationDidsExample |
Reserves a DID and orders it from the reservation. |
OrdersNanpaExample |
Orders a NANPA DID by NPA/NXX prefix. |
OrdersCapacityExample |
Buys capacity channels in a capacity pool. |
OrdersAllItemTypesExample |
Places one order with the three DID item variants (by SKU, by available DID, by reservation) and lists its DIDs; capacity needs an order of its own. |
OrdersEmergencyExample |
Reads emergency orders, which DIDWW creates: recent orders with emergency order items, then the order of an emergency calling service. |
TrunksExample |
Lists Voice IN trunks, creates a SIP trunk (point of presence, codecs, ICE mode) and a PSTN trunk, finds, updates and deletes them. |
VoiceInTrunkGroupsExample |
Creates two trunks and a trunk group with them, lists groups, renames the group and deletes it with its trunks. |
VoiceInTrunkSipRegistrationExample |
SIP registration flow: create with enabledSipRegistration=true, rename, disable by setting host, re-enable by toggling the flag. The SDK keeps host, port and useDidInRuri aligned with the server's validation rules. |
VoiceOutTrunksExample |
Creates, updates and deletes a Voice OUT trunk with codecs and ICE mode (requires account configuration). |
SmsTrunksExample |
Lists SMS trunks, creates and updates an HTTP IN trunk, regenerates the credentials of an HTTP OUT trunk, deletes both. |
SmsTrunkGroupsExample |
Creates two inbound SMS trunks, groups them by priority, lists groups, deletes the group (and its trunks). |
SenderIdVerificationsExample |
Lists Sender ID verifications, renames an active one and routes it through a sending SMS trunk, then restores its name and trunk. |
IdentityAddressProofsExample |
Creates an identity and an address, uploads encrypted files, creates proofs for both, prints the verified flags, deletes them. |
AddressVerificationsExample |
Lists address verifications with status predicates and reject details. |
UploadFileExample |
Encrypts a file with the DIDWW public keys, uploads it and prints the encrypted file ID. |
ExportsExample |
Creates and lists CDR exports with from/to datetime range filters (UTC). |
ExportsSmsExample |
Creates sms_in and sms_out exports with their filters and reads the columns of a completed one. |
EmergencyRequirementsExample |
Lists emergency requirements per country and number type. |
EmergencyRequirementValidationsExample |
Validates an address and identity against an emergency requirement. |
EmergencyVerificationsExample |
Lists emergency verifications with status predicates. |
EmergencyCallingServicesExample |
Lists emergency calling services and filters them by status. |
EmergencyScenarioExample |
End to end: find a DID, check requirements, validate, create a verification, get the calling service. |
PricesLookupExample [number] |
Looks up Voice IN, Voice OUT, SMS OUT (A2P, P2P, OTP) and SMS IN prices for a number. |
PricesDownloadExample [dir] |
Downloads the Voice IN price file, fetches it again with If-Modified-Since (304), reads the first rows. Default directory: didww-prices in the user cache directory, created for the current user only. |
IncludesExample |
Reads regions with their country, DID groups with SKUs, available DIDs with a nested include and DIDs with their trunk; a relationship that is not included reads as null. |
WebhookExample |
Signs a sample callback the way DIDWW does and validates it with RequestValidator: valid: true, then valid: false for a tampered payload. |
TestReadmeExample |
Runs the code snippets of the SDK README against the sandbox, one check per snippet, cleans up, prints Results: N passed, M failed and exits with status 1 on a failure. The production client check only reads, with a read-only token, and runs when DIDWW_README_PRODUCTION_API_KEY is set. It creates an address verification and an emergency verification (ordering DIDs when needed) and prints each on a REVIEW line for DIDWW to approve or reject. |
SenderIdVerificationsExample, DidSmsRoutingExample, DidTrunkAssignmentExample and TestReadmeExample change existing account state and restore it at the end; DidReservationsExample, SharedCapacityGroupsExample, TrunksExample, VoiceInTrunkGroupsExample, SmsTrunksExample, SmsTrunkGroupsExample and TestReadmeExample delete what they create. Both happen also when a step fails. Orders, exports, address verifications and emergency verifications cannot be deleted; the DIDs, identity and address a verification uses stay with it.
DIDWW_API_KEY=your_api_key FILE_PATH=/absolute/path/to/file.jpeg \
./gradlew runExample -PexampleClass=com.didww.examples.UploadFileExampleIf DIDWW_API_KEY is missing, examples fail fast with:
DIDWW_API_KEY environment variable is required