---
title: Crear carga de tabla de referencia
description: Crear una carga de tablas de referencia para la ingesta masiva de datos
breadcrumbs: Documentación > API > Crear carga de tabla de referencia
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/llms.txt).

# Crear carga de tabla de referencia

## v2 (latest)

| Datadog site      | API endpoint                                                       |
| ----------------- | ------------------------------------------------------------------ |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/reference-tables/uploads     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/reference-tables/uploads |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/reference-tables/uploads |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/reference-tables/uploads      |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/reference-tables/uploads |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/reference-tables/uploads |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/api/v2/reference-tables/uploads |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/reference-tables/uploads      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/reference-tables/uploads  |

### Overview

Crear una carga de tablas de referencia para la ingesta masiva de datos

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field | Field                   | Type     | Description                                                                                                                                 |
| ------------ | ----------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data                    | object   | Solicitud de creación de una carga de un archivo que se ingerirá en una tabla de referencia.                                                |
| data         | attributes              | object   | Upload configuration specifying how data is uploaded by the user, and properties of the table to associate the upload with.                 |
| attributes   | headers [*required*]    | [string] | The CSV file headers that define the schema fields, provided in the same order as the columns in the uploaded file. Maximum of 200 columns. |
| attributes   | part_count [*required*] | int32    | Number of parts to split the file into for multipart upload.                                                                                |
| attributes   | part_size [*required*]  | int64    | The size of each part in the upload in bytes. All parts except the last one must be at least 5,000,000 bytes.                               |
| attributes   | table_name [*required*] | string   | Name of the table to associate with this upload.                                                                                            |
| data         | type [*required*]       | enum     | Upload resource type. Allowed enum values: `upload`. Default: `upload`.                                                                     |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "headers": [
        "field_1",
        "field_2"
      ],
      "part_count": 3,
      "part_size": 10000000,
      "table_name": ""
    },
    "type": "upload"
  }
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="201" %}
Created

{% tabs %}
{% tab label="Model" %}
Information about the upload created containing the upload ID and pre-signed URLs to PUT chunks of the CSV file to.

| Parent field | Field             | Type     | Description                                                                       |
| ------------ | ----------------- | -------- | --------------------------------------------------------------------------------- |
|              | data              | object   | Upload ID and attributes of the created upload.                                   |
| data         | attributes        | object   | Pre-signed URLs for uploading parts of the file.                                  |
| attributes   | part_urls         | [string] | The pre-signed URLs for uploading parts. These URLs expire after 5 minutes.       |
| data         | id                | string   | Unique identifier for this upload. Use this ID when creating the reference table. |
| data         | type [*required*] | enum     | Upload resource type. Allowed enum values: `upload`. Default: `upload`.           |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "part_urls": []
    },
    "id": "string",
    "type": "upload"
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="403" %}
Forbidden

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, 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/uploads" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "headers": [
        "product_id",
        "product_name",
        "price"
      ],
      "part_count": 3,
      "part_size": 10000000,
      "table_name": "my_products_table"
    },
    "type": "upload"
  }
}
EOF
```
{% /tab %}

{% tab label="Go" %}
```go
// Create reference table upload returns "Created" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.CreateUploadRequest{
		Data: &datadogV2.CreateUploadRequestData{
			Attributes: &datadogV2.CreateUploadRequestDataAttributes{
				Headers: []string{
					"id",
					"name",
					"value",
				},
				TableName: "test_upload_table_Example-Reference-Table",
				PartCount: 1,
				PartSize:  1024,
			},
			Type: datadogV2.CREATEUPLOADREQUESTDATATYPE_UPLOAD,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewReferenceTablesApi(apiClient)
	resp, r, err := api.CreateReferenceTableUpload(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ReferenceTablesApi.CreateReferenceTableUpload`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ReferenceTablesApi.CreateReferenceTableUpload`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
```
{% /tab %}

{% tab label="Java" %}
```java
// Create reference table upload returns "Created" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ReferenceTablesApi;
import com.datadog.api.client.v2.model.CreateUploadRequest;
import com.datadog.api.client.v2.model.CreateUploadRequestData;
import com.datadog.api.client.v2.model.CreateUploadRequestDataAttributes;
import com.datadog.api.client.v2.model.CreateUploadRequestDataType;
import com.datadog.api.client.v2.model.CreateUploadResponse;
import java.util.Arrays;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    ReferenceTablesApi apiInstance = new ReferenceTablesApi(defaultClient);

    CreateUploadRequest body =
        new CreateUploadRequest()
            .data(
                new CreateUploadRequestData()
                    .attributes(
                        new CreateUploadRequestDataAttributes()
                            .headers(Arrays.asList("id", "name", "value"))
                            .tableName("test_upload_table_Example-Reference-Table")
                            .partCount(1)
                            .partSize(1024L))
                    .type(CreateUploadRequestDataType.UPLOAD));

    try {
      CreateUploadResponse result = apiInstance.createReferenceTableUpload(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ReferenceTablesApi#createReferenceTableUpload");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
```
{% /tab %}

{% tab label="Python" %}
```python
"""
Create reference table upload returns "Created" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.reference_tables_api import ReferenceTablesApi
from datadog_api_client.v2.model.create_upload_request import CreateUploadRequest
from datadog_api_client.v2.model.create_upload_request_data import CreateUploadRequestData
from datadog_api_client.v2.model.create_upload_request_data_attributes import CreateUploadRequestDataAttributes
from datadog_api_client.v2.model.create_upload_request_data_type import CreateUploadRequestDataType

body = CreateUploadRequest(
    data=CreateUploadRequestData(
        attributes=CreateUploadRequestDataAttributes(
            headers=[
                "id",
                "name",
                "value",
            ],
            table_name="test_upload_table_Example-Reference-Table",
            part_count=1,
            part_size=1024,
        ),
        type=CreateUploadRequestDataType.UPLOAD,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = ReferenceTablesApi(api_client)
    response = api_instance.create_reference_table_upload(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
```
{% /tab %}

{% tab label="Ruby" %}
```ruby
# Create reference table upload returns "Created" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::ReferenceTablesAPI.new

body = DatadogAPIClient::V2::CreateUploadRequest.new({
  data: DatadogAPIClient::V2::CreateUploadRequestData.new({
    attributes: DatadogAPIClient::V2::CreateUploadRequestDataAttributes.new({
      headers: [
        "id",
        "name",
        "value",
      ],
      table_name: "test_upload_table_Example-Reference-Table",
      part_count: 1,
      part_size: 1024,
    }),
    type: DatadogAPIClient::V2::CreateUploadRequestDataType::UPLOAD,
  }),
})
p api_instance.create_reference_table_upload(body)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
```
{% /tab %}

{% tab label="Rust" %}
```rust
// Create reference table upload returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_reference_tables::ReferenceTablesAPI;
use datadog_api_client::datadogV2::model::CreateUploadRequest;
use datadog_api_client::datadogV2::model::CreateUploadRequestData;
use datadog_api_client::datadogV2::model::CreateUploadRequestDataAttributes;
use datadog_api_client::datadogV2::model::CreateUploadRequestDataType;

#[tokio::main]
async fn main() {
    let body = CreateUploadRequest::new().data(
        CreateUploadRequestData::new(CreateUploadRequestDataType::UPLOAD).attributes(
            CreateUploadRequestDataAttributes::new(
                vec!["id".to_string(), "name".to_string(), "value".to_string()],
                1,
                1024,
                "test_upload_table_Example-Reference-Table".to_string(),
            ),
        ),
    );
    let configuration = datadog::Configuration::new();
    let api = ReferenceTablesAPI::with_config(configuration);
    let resp = api.create_reference_table_upload(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
```
{% /tab %}

{% tab label="TypeScript" %}
```typescript
/**
 * Create reference table upload returns "Created" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
const apiInstance = new v2.ReferenceTablesApi(configuration);

const params: v2.ReferenceTablesApiCreateReferenceTableUploadRequest = {
  body: {
    data: {
      attributes: {
        headers: ["id", "name", "value"],
        tableName: "test_upload_table_Example-Reference-Table",
        partCount: 1,
        partSize: 1024,
      },
      type: "upload",
    },
  },
};

apiInstance
  .createReferenceTableUpload(params)
  .then((data: v2.CreateUploadResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"
```
{% /tab %}
{% /tabs %}
