For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/api/latest/reference-tables/create-reference-table.md. A documentation index is available at /llms.txt.
Language
Datadog site

Create reference table

POSThttps://api.datadoghq.com/api/v2/reference-tables/tableshttps://api.us3.datadoghq.com/api/v2/reference-tables/tableshttps://api.us5.datadoghq.com/api/v2/reference-tables/tableshttps://api.datadoghq.eu/api/v2/reference-tables/tableshttps://api.ap1.datadoghq.com/api/v2/reference-tables/tableshttps://api.ap2.datadoghq.com/api/v2/reference-tables/tableshttps://api.uk1.datadoghq.com/api/v2/reference-tables/tableshttps://api.ddog-gov.com/api/v2/reference-tables/tableshttps://api.us2.ddog-gov.com/api/v2/reference-tables/tables

Overview

Creates a reference table. You can provide data in two ways:

  1. Call POST /api/v2/reference-tables/upload to get an upload ID. Then, PUT the CSV data (not the file itself) in chunks to each URL in the request body. Finally, call this POST endpoint with upload_id in file_metadata.
  2. Provide access_details in file_metadata pointing to a CSV file in cloud storage.

Request

Body Data (required)

Field
Type
Description
data
object

The data object containing the table definition.

Response

Created

A reference table resource containing its full configuration and state.

Field
Type
Description
data
object

The data object containing the reference table configuration and state.

Code Example

Create reference table
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF
## Create table from cloud storage (S3)

# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## default

# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Customer reference data synced from S3",
      "file_metadata": {
        "access_details": {
          "aws_detail": {
            "aws_account_id": "924305315327",
            "aws_bucket_name": "my-data-bucket",
            "file_path": "customers.csv"
          }
        },
        "sync_enabled": true
      },
      "schema": {
        "fields": [
          {
            "name": "customer_id",
            "type": "STRING"
          },
          {
            "name": "customer_name",
            "type": "STRING"
          },
          {
            "name": "email",
            "type": "STRING"
          }
        ],
        "primary_keys": [
          "customer_id"
        ]
      },
      "source": "S3",
      "table_name": "customer_reference_data",
      "tags": [
        "team:data-platform"
      ]
    },
    "type": "reference_table"
  }
}
EOF

## Create table from local file upload

# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/reference-tables/tables" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "description": "Product catalog uploaded via local file",
      "file_metadata": {
        "upload_id": "00000000-0000-0000-0000-000000000000"
      },
      "schema": {
        "fields": [
          {
            "name": "product_id",
            "type": "STRING"
          },
          {
            "name": "product_name",
            "type": "STRING"
          },
          {
            "name": "price",
            "type": "DOUBLE"
          }
        ],
        "primary_keys": [
          "product_id"
        ]
      },
      "source": "LOCAL_FILE",
      "table_name": "product_catalog",
      "tags": [
        "team:ecommerce"
      ]
    },
    "type": "reference_table"
  }
}
EOF