REST Java Client

Sage provides a Java-based REST client for interacting with Bridge services (v0.16.25):

REST client API docs
JavaDocs for the REST client.
Source code.

Clients in other languages can be produced using the swagger specification of the services.

Installing the REST client (Maven)

Add the Sage Bionetworks repository and the REST client to your pom.xml:


Using the REST client

If you don't have an account to start, you can create one (if you do not have a study, you will have to contact Sage Bionetworks to create one):

SignUp signUp = new SignUp()

ClientManager manager = new ClientManager.Builder().build();
AuthenticationApi authApi = manager.getClient(AuthenticationApi.class);

// check your email and verify your email address

// Now you can sign in, although ClientManager will do this automatically
SignIn signIn = new SignIn()

UserSessionInfo session = null;
try {
    session = authApi.signIn(signIn).execute().body();
} catch(ConsentRequiredException e) {
    // user still has session, but must consent to continue.
    String sessionToken = e.getSession().getSessionToken();

The available Api clients are documented in the javadocs for the REST client. You can create them using the ClientManager (as shown above).

The ClientManager class provides the means to configure your clients using a file in your user home directory (~/bridge-sdk.properites on Mac OSX and Linux):

study.identifier = yourStudyIdentifier =
account.password = yourPassword
languages = en

This allows you to use credentials without embedding them in your program:

Config config = new Config();
ClientManager manager = new ClientManager.Builder().withConfig(config).build();

ForConsentedUsersApi usersApi = manager.getClient(ForConsentedUsersApi.class);
ScheduledActivityList scheduledActivities = usersApi
    .getScheduledActivities("+00:00", 4, 0).execute().body();

Filtering server content

The server can tailor behavior for your app based on criteria such as the app's version or the declared language of the user. For this to work, you must send a User-Agent header with your requests, in a specific format understood by Bridge. The rest client represents the user agent through the ClientInfo class, which can be provided to the ClientManager:

ClientInfo info = new ClientInfo();
info.setDeviceName("Google Plexus");
info.setOsName("Android"); // or "iPhone OS"

List<String> languages = new ArrayList<>();

ClientManager manager = new ClientManager.Builder()

See customizing content and the ClientInfo object for further details.

Finally you may wish to sign out when you are done:

AuthenticationApi authApi = manager.getClient(AuthenticationApi.class);