# Remote configuration

Fetch the current published release, understand schema compatibility, and keep your app usable when delivery fails.

## Fetch a published configuration

### Swift

```
let configuration = try await client.configuration(flowID: "YOUR_FLOW_ID")
// AplynaConfiguration; current Swift client requests schema 2.
```

### Kotlin

```
// Background thread. Returns org.json.JSONObject.
val configuration = client.configuration(flowId = "YOUR_FLOW_ID")
// Current Kotlin client requests schema 1.
```

The flow must be published and belong to the app that issued your SDK key. An unpublished or foreign flow is not available through this endpoint.

## Schema compatibility

| Consumer | Compatibility |
| --- | --- |
| Swift source SDK | Requests schema_version=2; accepts schema 1 and 2 with nonempty steps. |
| Kotlin source SDK | Requests schema_version=1; accepts schema 1. A layout requiring schema 2 is rejected and needs a compatible native fallback. |
| Direct HTTP client | Declare the maximum schema you can safely render using schema_version. Unsupported requests or newer layouts return 422. |

Schema 1 covers supported ordered screen fields. Schema 2 is used when saved layout nodes require the newer structure. Upgrade and verify the renderer in the app before publishing layouts it cannot interpret.

## Caching and ETags

The server returns ETag for the immutable release and Cache-Control: private, max-age=30. A matching If-None-Match returns 304 without a JSON body. Both clients keep compatible configuration caches on disk and reuse them on delivery failure. A saved draft does not change the published release or ETag.

## Plan the offline experience

- Keep bundled native onboarding available even for a first offline launch.
- Try configuration delivery; use a previously cached compatible release when available.
- If delivery and cache both fail, render the bundled fallback instead of a blank screen.
- Assignments use cached results when a request fails; without cache, the clients return A with no experiment ID.
- Do not treat a cached assignment or local trial event as verified payment state.

## What remote configuration can change

> **Supported content only**
> Remote configuration changes supported declarative content or selects branches already shipped in the app. It does not download and execute arbitrary native code. New code or unsupported components require an application release.

- [HTTP configuration reference](https://aplyna.com/docs/api#configuration): Parameters, status codes and caching headers.
- [Troubleshooting](https://aplyna.com/docs/troubleshooting): Resolve unpublished flows and schema errors.
