---
title: Get Dynamic Config or Experiment
description: "Fetches configuration values for a dynamic config or experiment. Works for both types - the system automatically determines which type based on the name. Aut…"
product: general
token_estimate: 1675
---
# Get Dynamic Config or Experiment

> For AI agents: a documentation index is available at [/llms.txt](/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

## Get Dynamic Config or Experiment

**POST** `/v1/get_config`

Full URL: `https://api.statsig.com/v1/get_config`

**Servers:**
- SDK API Server: `https://api.statsig.com/v1/get_config`
- Events API Server: `https://events.statsigapi.net/v1/get_config`

Get Dynamic Config or Experiment

Fetches configuration values for a dynamic config or experiment. Works for both types - the system automatically determines which type based on the name. Automatically logs exposure events.

## Authorizations

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| statsig-api-key | string | Yes | — | SDK API key (Server Secret or Client SDK Key) |

## Body (application/json)

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| configName | string | Yes | — | Name of the dynamic config or experiment Constraints: min length: 2, max length: 100, pattern: ^[a-zA-Z0-9_\-. ]+$ |
| user | object | No | — | User object containing identification and attributes for evaluation. At minimum, provide at least one identifier. |
| user.userID | string | No | user-123 | Primary user identifier |
| user.email | string | No | user@example.com | User email address Constraints: format: email |
| user.ip | string | No | 192.168.1.1 | User IP address for geo-targeting |
| user.userAgent | string | No | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 | User agent string for device/browser targeting |
| user.country | string | No | US | 2-letter country code (ISO 3166-1 alpha-2) |
| user.locale | string | No | en_US | Locale/language code |
| user.appVersion | string | No | 1.2.3 | Application version |
| user.custom | object | No | {"subscription_plan":"premium","account_age_days":45,"is_beta_tester":true} | Custom user attributes for targeting (string, number, boolean, or array of strings) |
| user.privateAttributes | object | No | {"internal_user_id":"12345"} | Private attributes used for evaluation but not logged to analytics |
| user.customIDs | object | No | {"companyID":"company-456","deviceID":"device-789"} | Additional custom identifier mappings |
| user.statsigEnvironment | object | No | — | Environment tier for targeting |
| user.statsigEnvironment.tier | string | No | — | Environment tier Allowed values: production, staging, development |
| statsigMetadata | object | No | {"sdkType":"js-client","sdkVersion":"4.20.0","exposureLoggingDisabled":false} | SDK metadata for tracking SDK type, version, and other diagnostic information |
| statsigMetadata.sdkType | string | No | — | SDK type sending the request (e.g., js-client) |
| statsigMetadata.sdkVersion | string | No | — | SDK version |
| statsigMetadata.exposureLoggingDisabled | boolean | No | — | When true, prevents the HTTP API from automatically logging exposures. Use this only if you will handle exposure logging yourself. |

## Response (application/json)

**200** — Configuration values

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| name | string | Yes | — | Config name |
| value | object | Yes | — | Configuration parameter values as key-value pairs |
| group | string | No | — | Rule ID (deprecated, use rule_id instead) |
| rule_id | string | Yes | — | ID of the rule that matched Constraints: nullable |
| group_name | string | Yes | — | Name of the matching group Constraints: nullable |

```json
{
  "name": "homepage_config",
  "value": {
    "header_text": "Welcome!",
    "show_banner": true,
    "button_color": "#FF5733"
  },
  "group": "2RamGsERWbWMIMnSfOlQuX",
  "rule_id": "2RamGsERWbWMIMnSfOlQuX",
  "group_name": "Power Users"
}
```

## Code samples

### cURL

```bash
curl -X POST "https://api.statsig.com/v1/get_config" \
  -H "Content-Type: application/json" \
  -H "statsig-api-key: YOUR_API_KEY" \
  -d '{
  "configName": "homepage_config",
  "user": {
    "userID": "user-123"
  }
}'
```

### Python

```python
import requests

response = requests.post(
    "https://api.statsig.com/v1/get_config",
    headers={
        "Content-Type": "application/json",
        "statsig-api-key": "YOUR_API_KEY"
    },
    json={
  "configName": "homepage_config",
  "user": {
    "userID": "user-123"
  }
}
)
data = response.json()
```

### JavaScript

```javascript
const response = await fetch("https://api.statsig.com/v1/get_config", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "statsig-api-key": "YOUR_API_KEY"
  },
  body: JSON.stringify({
  "configName": "homepage_config",
  "user": {
    "userID": "user-123"
  }
})
});
const data = await response.json();
```

### PHP

```php
<?php
$ch = curl_init("https://api.statsig.com/v1/get_config");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "statsig-api-key: YOUR_API_KEY"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$body = json_encode({
  "configName": "homepage_config",
  "user": {
    "userID": "user-123"
  }
});
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($ch);
curl_close($ch);
```

### Go

```go
package main

import (
  "bytes"
  "net/http"
)

func main() {
body := []byte("{\"configName\":\"homepage_config\",\"user\":{\"userID\":\"user-123\"}}")
req, _ := http.NewRequest("POST", "https://api.statsig.com/v1/get_config", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("statsig-api-key", "YOUR_API_KEY")
  client := &http.Client{}
  resp, _ := client.Do(req)
  defer resp.Body.Close()
}
```

### Java

```java
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.statsig.com/v1/get_config"))
      .method("POST", HttpRequest.BodyPublishers.ofString("{\"configName\":\"homepage_config\",\"user\":{\"userID\":\"user-123\"}}"))
.header("Content-Type", "application/json")
      .header("statsig-api-key", "YOUR_API_KEY")
      .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
```

### Ruby

```ruby
require "net/http"
require "json"

uri = URI("https://api.statsig.com/v1/get_config")
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["statsig-api-key"] = "YOUR_API_KEY"
request.body = "{\"configName\":\"homepage_config\",\"user\":{\"userID\":\"user-123\"}}"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end
```

