> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Kotlin SDK - Installation

> Gradle and Maven setup for the Westyx Nexus Kotlin SDK.

## Requirements

| Requirement | Minimum version              |
| ----------- | ---------------------------- |
| Kotlin      | 2.1.0                        |
| JVM         | 17                           |
| Gradle      | 8.x (Kotlin DSL recommended) |

## GitLab package registry

<CodeGroup>
  ```kotlin title="settings.gradle.kts" theme={null}
  dependencyResolutionManagement {
      repositories {
          mavenCentral()
          maven {
              url = uri("https://gitlab.com/api/v4/projects/82635144/packages/maven")
              credentials(HttpHeaderCredentials::class) {
                  name  = "Deploy-Token"
                  value = System.getenv("NEXUS_DEPLOY_TOKEN") ?: ""
              }
              authentication {
                  create<HttpHeaderAuthentication>("header")
              }
          }
      }
  }
  ```

  ```kotlin title="build.gradle.kts" theme={null}
  dependencies {
      implementation("dev.westyx.nexus:nexus-kotlin-sdk:0.10.0")
  }
  ```
</CodeGroup>

### Gradle (Groovy DSL)

```groovy theme={null}
// build.gradle
repositories {
    maven {
        url "https://gitlab.com/api/v4/projects/82635144/packages/maven"
        credentials(HttpHeaderCredentials) {
            name  = "Deploy-Token"
            value = System.getenv("NEXUS_DEPLOY_TOKEN") ?: ""
        }
        authentication {
            header(HttpHeaderAuthentication)
        }
    }
}

dependencies {
    implementation "dev.westyx.nexus:nexus-kotlin-sdk:0.10.0"
}
```

### Maven

```xml theme={null}
<!-- pom.xml -->
<repositories>
  <repository>
    <id>westyx-nexus-sdk</id>
    <url>https://gitlab.com/api/v4/projects/82635144/packages/maven</url>
  </repository>
</repositories>

<!-- ~/.m2/settings.xml - add server credentials -->
<servers>
  <server>
    <id>westyx-nexus-sdk</id>
    <configuration>
      <httpHeaders>
        <property>
          <name>Deploy-Token</name>
          <value>${env.NEXUS_DEPLOY_TOKEN}</value>
        </property>
      </httpHeaders>
    </configuration>
  </server>
</servers>

<!-- pom.xml dependency -->
<dependency>
  <groupId>dev.westyx.nexus</groupId>
  <artifactId>nexus-kotlin-sdk</artifactId>
  <version>0.10.0</version>
</dependency>
```

## Transitive dependencies

The SDK pulls in the following at runtime. You do not need to declare them manually.

| Artifact                                           | Version |
| -------------------------------------------------- | ------- |
| `io.ktor:ktor-client-core`                         | 3.0.3   |
| `io.ktor:ktor-client-cio`                          | 3.0.3   |
| `io.ktor:ktor-client-content-negotiation`          | 3.0.3   |
| `io.ktor:ktor-serialization-kotlinx-json`          | 3.0.3   |
| `org.jetbrains.kotlinx:kotlinx-coroutines-core`    | 1.9.0   |
| `org.jetbrains.kotlinx:kotlinx-serialization-json` | 1.7.3   |
| `org.slf4j:slf4j-api`                              | 2.0.9   |

## Deploy token

Generate a deploy token in your GitLab project under **Settings > Repository > Deploy tokens**. Grant the `read_package_registry` scope. Store the token in CI/CD as a masked variable (`NEXUS_DEPLOY_TOKEN`).

## Verifying connectivity

Before writing any code, confirm your endpoint and API key work with a plain `curl`:

```sh theme={null}
curl -s \
  -H "X-Nexus-API-Key: wxs_..." \
  https://your-service.westyx.dev/v1/sync
```

A valid response returns a JSON snapshot with your `configs`, `secrets`, and `flags`. An `HTTP 401` means the key is wrong; `HTTP 404` means the slug is wrong.

To watch the live SSE stream:

```sh theme={null}
curl -N \
  -H "X-Nexus-API-Key: wxs_..." \
  -H "Accept: text/event-stream" \
  https://your-service.westyx.dev/v1/stream
```

You should see `event:resync` arrive within a second. Press `Ctrl+C` to stop.
