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

# Create Assignment Tables

> Learn how to create assignment tables using the API.

export const HowToSchema = ({name, description, steps = []}) => {
  const schema = {
    "@context": "https://schema.org",
    "@type": "HowTo",
    name,
    description
  };
  if (steps.length > 0) {
    schema.step = steps.map((s, i) => ({
      "@type": "HowToStep",
      position: i + 1,
      name: typeof s === "string" ? s : s.name,
      text: typeof s === "string" ? s : s.text || s.name
    }));
  }
  return <script type="application/ld+json" dangerouslySetInnerHTML={{
    __html: JSON.stringify(schema)
  }} />;
};

<HowToSchema
  name="Create Assignment Tables"
  description="Learn how to create assignment tables using the API."
  steps={[
{
  name: "Before You Begin",
  text: "Before creating an assignment table, ensure you have: - An API access token with appropriate permissions - Created the entity you want to track assignments for",
},
{
  name: "Create an Assignment Table",
  text: "Create an assignment table with automatic data delivery:",
},
{
  name: "Column Mapping Fields",
  text: "- entityColumnMapping: Maps the column containing entity IDs to the entity resource - column.name: Name of the column in your query results - entity: Resource name of the entity (for example, entities/user)",
},
{
  name: "Data Delivery Strategy",
  text: "Configure how Confidence updates data from your warehouse: ```json",
},
]}
/>

Create assignment tables that store records of what entities have been assigned what configuration.

## Before You Begin

Before creating an assignment table, ensure you have:

* An API access token with appropriate permissions
* Created the entity you want to track assignments for
* Prepared a SQL query that selects assignment rows from your data warehouse
* Identified the columns for timestamp, entity ID, exposure key, and variant key

## Create an Assignment Table

Create an assignment table with automatic data delivery:

```bash theme={null}
curl -X POST "https://metrics.confidence.dev/v1/assignmentTables" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "displayName": "My Assignment Table",
    "dataDeliveredUntilUpdateStrategyConfig": {
      "strategy": "AUTOMATIC",
      "automaticUpdateConfig": {
        "incrementDuration": "P13H",
        "commitDelay": "P13H"
      }
    },
    "sql": "SELECT * FROM my_table",
    "entityColumnMapping": {
      "column": {
        "name": "user_id"
      },
      "entity": "entities/user"
    },
    "timestampColumn": {
      "name": "timestamp"
    },
    "exposureKeyColumn": {
      "name": "experiment_id"
    },
    "variantKeyColumn": {
      "name": "group"
    }
  }'
```

## Column Mapping Fields

* **entityColumnMapping**: Maps the column containing entity IDs to the entity resource
  * `column.name`: Name of the column in your query results
  * `entity`: Resource name of the entity (for example, `entities/user`)
* `timestampColumn`: Column containing the assignment timestamp
* `exposureKeyColumn`: Column identifying which experiment the assignment belongs to
* `variantKeyColumn`: Column identifying which variant was assigned

## Data Delivery Strategy

Configure how Confidence updates data from your warehouse:

<Tabs>
  <Tab title="Automatic Updates">
    ```json theme={null}
    "dataDeliveredUntilUpdateStrategyConfig": {
      "strategy": "AUTOMATIC",
      "automaticUpdateConfig": {
        "incrementDuration": "P13H",
        "commitDelay": "P13H"
      }
    }
    ```

    * **incrementDuration**: How frequently to check for new data
    * **commitDelay**: Buffer time before considering data complete
  </Tab>

  <Tab title="Daily Updates">
    ```json theme={null}
    "dataDeliveredUntilUpdateStrategyConfig": {
      "strategy": "DAILY",
      "dailyUpdateConfig": {}
    }
    ```

    Updates once per day at a scheduled time.
  </Tab>
</Tabs>

## Next Steps

After creating an assignment table:

* [Create fact tables](./create-fact-table) to measure outcomes
* [Create metrics](./create-metric) using your assignment and fact tables
* Configure experiments to use this assignment table
