---
title: Create reference table upload
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Reference Tables
---

# Create reference table upload{% #create-reference-table-upload %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                       |
| ----------------- | ------------------------------------------------------------------ |
| 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 |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/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  |
| 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 |

### Overview

Create a reference table upload for bulk data ingestion

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                        | Type     | Description                                                                                                                 |
| ------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
|              | data                         | object   | Request data for creating an upload for a file to be ingested into a reference table.                                       |
| 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.         |
| 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`                                                                         |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "headers": [
        "field_1",
        "field_2"
      ],
      "part_count": 3,
      "part_size": 10000000,
      "table_name": ""
    },
    "type": "upload"
  }
}
```

{% /tab %}

### Response

{% tab title="201" %}
Created
{% tab title="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`                               |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "part_urls": []
    },
    "id": "string",
    "type": "upload"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/reference-tables/uploads" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "headers": [
        "product_id",
        "product_name",
        "price"
      ],
      "part_count": 3,
      "part_size": 10000000,
      "table_name": "my_products_table"
    },
    "type": "upload"
  }
}
EOF 
                
##### 

```python
"""
Create reference table upload returns "Created" response
"""

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()
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://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Create reference table upload returns "Created" response

require "datadog_api_client"
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://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```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())
	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://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```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();
    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://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```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://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Create reference table upload returns "Created" response
 */

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

const configuration = client.createConfiguration();
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://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
