---
title: Create Assignment Source
description: Create Assignment Source
product: general
token_estimate: 2311
---
# Create Assignment Source

> 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`.

## Create Assignment Source

**POST** `/console/v1/experiments/assignment_sources`

Full URL: `https://statsigapi.net/console/v1/experiments/assignment_sources`

Create Assignment Source

## Authorizations

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| STATSIG-API-KEY | string | Yes | — | apiKey (header) |

## Body (application/json)

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| name | string | Yes | — | Unique identifier for the assignment source. |
| description | string | No | — | Optional detailed context for the assignment source. |
| isVerified | boolean | No | — | Marks the assignment source as verified for internal trustworthiness. |
| tags | string[] | No | — | Optional tags for categorization. |
| sql | string | Yes | — | SQL query defining the data source for assignments. |
| timestampColumn | string | Yes | — | Column name representing the timestamp of assignments. |
| experimentIDColumn | string | Yes | — | Column name for the experiment ID associated with the assignments. |
| groupIDColumn | string | Yes | — | Column name for the group ID linked to the assignments. |
| groupNameColumn | string | No | — | Optional column name for the group name linked to the assignments. |
| idTypeMapping | object[] | Yes | — | Mappings of Statsig units to their respective columns. |
| idTypeMapping.statsigUnitID | string | Yes | — | ID for the Statsig unit. |
| idTypeMapping.column | string | Yes | — | Column name associated with the ID type mapping. |
| isReadOnly | boolean | No | — | Specifies if the source can only be edited via the Console API. |
| owner | object | No | {"ownerID":"user123","ownerType":"USER","ownerName":"John Doe","ownerEmail":"owner123@test.com"} | Schema for owner data including ID, type, name. Constraints: nullable |
| owner.ownerID | string | No | abc123 | ID of the owner |
| owner.ownerType | string | No | USER | Type of the owner (e.g., SDK_KEY or USER) |
| owner.ownerName | string | No | John Doe | The name of the owner. This field is optional. |
| owner.ownerEmail | string | No | — | The email of the owner. This field is optional. |
| team | string | No | — | Optional field indicating the team name responsible for the assignment source, aiding in accountability and management. Constraints: nullable |
| teamID | string | No | — | Optional field indicating the team ID responsible for the assignment source, aiding in accountability and management. Constraints: nullable |
| scheduledReloadHour | integer | No | — | Optional field indicating what UTC hour to run a scheduled scan for the assignment source. Constraints: format: int64, nullable, min: 0, max: 23 |
| dryRun | boolean | No | — | Skips persisting the assignment source (used to validate that inputs are correct) |

## Response (application/json)

**201** — Create Assignment Source response

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| message | string | Yes | — | A simple string explaining the result of the operation. |
| data | object | Yes | — | — |
| data.name | string | Yes | — | Unique identifier for the assignment source. |
| data.description | string | Yes | — | Detailed context and purpose of the assignment source. |
| data.isVerified | boolean | No | — | Marks the assignment source as verified for internal trustworthiness. |
| data.tags | string[] | Yes | — | Tags for categorization and search. |
| data.sql | string | Yes | — | SQL query defining the data source for assignments. |
| data.timestampColumn | string | Yes | — | Column name representing the timestamp of assignments. |
| data.experimentIDColumn | string | Yes | — | Column name for the experiment ID associated with the assignments. |
| data.groupIDColumn | string | Yes | — | Column name for the group ID linked to the assignments. |
| data.groupNameColumn | string | No | — | Optional column name for the group name linked to the assignments. |
| data.idTypeMapping | object[] | Yes | — | Mappings of Statsig units to their respective columns. |
| data.idTypeMapping.statsigUnitID | string | Yes | — | ID for the Statsig unit. |
| data.idTypeMapping.column | string | Yes | — | Column name associated with the ID type mapping. |
| data.isReadOnly | boolean | No | — | Specifies if the source can only be edited via the Console API. |
| data.owner | object | No | {"ownerID":"user123","ownerType":"USER","ownerName":"John Doe","ownerEmail":"owner123@test.com"} | Schema for owner data including ID, type, name. Constraints: nullable |
| data.owner.ownerID | string | No | abc123 | ID of the owner |
| data.owner.ownerType | string | No | USER | Type of the owner (e.g., SDK_KEY or USER) |
| data.owner.ownerName | string | No | John Doe | The name of the owner. This field is optional. |
| data.owner.ownerEmail | string | No | — | The email of the owner. This field is optional. |
| data.team | string | No | — | Optional field indicating the team name responsible for the assignment source, aiding in accountability and management. Constraints: nullable |
| data.teamID | string | No | — | Optional field indicating the team ID responsible for the assignment source, aiding in accountability and management. Constraints: nullable |
| data.scheduledReloadHour | integer | No | — | Optional field indicating what UTC hour to run a scheduled scan for the assignment source. Constraints: format: int64, nullable, min: 0, max: 23 |

```json
{
  "message": "Assignment Source created successfully",
  "data": {
    "name": "exposures4",
    "description": "",
    "tags": [],
    "sql": "SELECT * FROM shoppy-sales.experiment_data.exposures",
    "timestampColumn": "ts",
    "groupIDColumn": "group_id",
    "experimentIDColumn": "experiment_name",
    "idTypeMapping": [
      {
        "statsigUnitID": "stableID",
        "column": "user_id"
      }
    ]
  }
}
```

**400** — Invalid request. Please check the request input and try again.

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| status | integer | Yes | — | Allowed values: 400 |
| message | string | Yes | — | — |

```json
{
  "status": 400,
  "message": "Invalid request. Please check the request input and try again."
}
```

**401** — This endpoint only accepts an active CONSOLE key, but an invalid key was sent. Key: console-xxxXXXxxxXXXxxx

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| status | integer | Yes | — | Allowed values: 401 |
| message | string | Yes | — | — |

```json
{
  "status": 401,
  "message": "This endpoint only accepts an active CONSOLE key, but an invalid key was sent. Key: console-xxxXXXxxxXXXxxx"
}
```

## Code samples

### cURL

```bash
curl -X POST "https://statsigapi.net/console/v1/experiments/assignment_sources" \
  -H "Content-Type: application/json" \
  -H "STATSIG-API-KEY: YOUR_API_KEY"
```

### Python

```python
import requests

response = requests.post(
    "https://statsigapi.net/console/v1/experiments/assignment_sources",
    headers={
        "Content-Type": "application/json",
        "STATSIG-API-KEY": "YOUR_API_KEY"
    }
)
data = response.json()
```

### JavaScript

```javascript
const response = await fetch("https://statsigapi.net/console/v1/experiments/assignment_sources", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "STATSIG-API-KEY": "YOUR_API_KEY"
  }
});
const data = await response.json();
```

### PHP

```php
<?php
$ch = curl_init("https://statsigapi.net/console/v1/experiments/assignment_sources");
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);
$response = curl_exec($ch);
curl_close($ch);
```

### Go

```go
package main

import (
  "bytes"
  "net/http"
)

func main() {
req, _ := http.NewRequest("POST", "https://statsigapi.net/console/v1/experiments/assignment_sources", nil)
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://statsigapi.net/console/v1/experiments/assignment_sources"))
      .method("POST", HttpRequest.BodyPublishers.noBody())
.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://statsigapi.net/console/v1/experiments/assignment_sources")
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["STATSIG-API-KEY"] = "YOUR_API_KEY"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end
```

