For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/fr/api/latest/reference-tables/create-reference-table.md. A documentation index is available at /llms.txt.
Language
Datadog site

Créer une table de référence

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

Présentation

Crée une table de référence. Vous pouvez fournir des données de deux façons :

  1. Appelez POST /api/v2/reference-tables/upload pour obtenir un ID d'importation. Ensuite, envoyez les données CSV   (pas le fichier lui-même) en blocs via PUT vers chaque URL dans le corps de la requête. Enfin, appelez cet   endpoint POST avec upload_id dans file_metadata.
  2. Fournissez access_details dans file_metadata pointant vers un fichier CSV dans un stockage cloud.

Requête

Body Data (required)

Champ
Type
Description
data
object

Corps de la requête pour la création d'une nouvelle table de référence à partir d'un fichier local ou d'un stockage cloud.

Réponse

Created

A reference table resource containing its full configuration and state.

Champ
Type
Description
data
object

The data object containing the reference table configuration and state.

Exemple de code

Créer une table de référence
## 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