# Get started

Canonical page: https://docs.ovok.com/java-sdk/getting-started

The Java SDK requires Java 17 or later.

## Install [#install]

Add the SDK from Maven Central to your Gradle project:

```kotlin
repositories {
    mavenCentral()
}

dependencies {
    implementation("com.ovok:ovok-sdk:0.1.0")
}
```

Or to your Maven project:

```xml
<dependency>
    <groupId>com.ovok</groupId>
    <artifactId>ovok-sdk</artifactId>
    <version>0.1.0</version>
</dependency>
```

Release candidates are on Maven Central as `0.1.0-rc.<n>`. Development builds are `0.1.0-SNAPSHOT` in the Central Portal snapshot repository:

```kotlin
repositories {
    mavenCentral()
    maven("https://central.sonatype.com/repository/maven-snapshots/")
}

dependencies {
    implementation("com.ovok:ovok-sdk:0.1.0-SNAPSHOT")
}
```

The SDK brings in `tools.jackson.core:jackson-databind` (Jackson 3) as an API dependency.

## Configure a client [#configure-a-client]

```java
import com.ovok.sdk.Ovok;
import com.ovok.sdk.OvokConfig;

Ovok ovok = new Ovok(OvokConfig.builder()
        .baseUrl("https://api.sandbox.ovok.com")
        .tenantCode("your-tenant")
        .build());
```

`baseUrl` and `tenantCode` are required. See [client configuration](/java-sdk/client-configuration) for the other options.

## Sign in [#sign-in]

```java
import com.ovok.sdk.LoginCredentials;
import com.ovok.sdk.LoginResult;
import com.ovok.sdk.ProfileType;

LoginResult result = ovok.auth().login(new LoginCredentials(
        ProfileType.PRACTITIONER, "person@example.com", password));

if (result.status().equals("mfa-required")) {
    result = ovok.auth().verifyMfa(result.challenge(), mfaCode);
}
```

The client keeps the session and refreshes its access token before it expires. A backend service can use client credentials instead; see [machine clients](/java-sdk/client-configuration#machine-clients).

## Read a FHIR resource [#read-a-fhir-resource]

```java
import tools.jackson.databind.JsonNode;

JsonNode patient = ovok.fhir().read("Patient", "patient-id");
```

SDK methods declare `IOException` and `InterruptedException`. A response that is not a success throws an `OvokApiException` subtype; see [errors](/java-sdk/errors-and-retries).
