Create connection

Note: This endpoint may be subject to changes.

POST https://api.ap1.datadoghq.com/api/v2/product-analytics/{entity}/mapping/connectionhttps://api.ap2.datadoghq.com/api/v2/product-analytics/{entity}/mapping/connectionhttps://api.datadoghq.eu/api/v2/product-analytics/{entity}/mapping/connectionhttps://api.ddog-gov.com/api/v2/product-analytics/{entity}/mapping/connectionhttps://api.us2.ddog-gov.com/api/v2/product-analytics/{entity}/mapping/connectionhttps://api.datadoghq.com/api/v2/product-analytics/{entity}/mapping/connectionhttps://api.us3.datadoghq.com/api/v2/product-analytics/{entity}/mapping/connectionhttps://api.us5.datadoghq.com/api/v2/product-analytics/{entity}/mapping/connection

Overview

Create a new data connection and its fields for an entity

Arguments

Path Parameters

Name

Type

Description

entity [required]

string

The entity for which to create the connection

Request

Body Data (required)

Expand All

Field

Type

Description

data

object

The data object containing the resource type and attributes for creating a new connection.

attributes

object

Attributes defining the data source connection, including join configuration and custom fields.

fields

[object]

List of custom attribute fields to import from the data source.

description

string

Human-readable explanation of what the field represents.

display_name

string

The human-readable label for the field shown in the UI.

groups

[string]

List of group labels used to categorize the field.

id [required]

string

The unique identifier for the field within the connection.

source_name [required]

string

The name of the column or attribute in the source data system that maps to this field.

type [required]

string

The data type of the field (for example, string or number).

join_attribute [required]

string

The attribute in the data source used to join records with the entity.

join_type [required]

string

The type of join key used to link the data source to the entity (for example, email or user_id).

metadata

object

Additional key-value metadata associated with the connection.

<any-key>

string

type [required]

string

The type of data source connection (for example, ref_table).

id

string

Unique identifier for the new connection resource.

type [required]

enum

Connection id resource type. Allowed enum values: connection_id

default: connection_id

{
  "data": {
    "attributes": {
      "fields": [
        {
          "description": "string",
          "display_name": "string",
          "groups": [],
          "id": "",
          "source_name": "",
          "type": ""
        }
      ],
      "join_attribute": "",
      "join_type": "",
      "metadata": {
        "<any-key>": "string"
      },
      "type": ""
    },
    "id": "string",
    "type": "connection_id"
  }
}

Response

Connection created successfully

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example

                  ## default
# 

# Path parameters
export entity="users"
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/product-analytics/${entity}/mapping/connection" \ -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": { "fields": [ { "description": "Customer subscription tier from `CRM`", "display_name": "Customer Tier", "id": "customer_tier", "source_name": "subscription_tier", "type": "string" }, { "description": "Customer lifetime value in `USD`", "display_name": "Lifetime Value", "id": "lifetime_value", "source_name": "ltv", "type": "number" } ], "join_attribute": "user_email", "join_type": "email", "type": "ref_table" }, "id": "crm-integration", "type": "connection_id" } } EOF
"""
Create connection returns "Connection created successfully" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.rum_audience_management_api import RumAudienceManagementApi
from datadog_api_client.v2.model.create_connection_request import CreateConnectionRequest
from datadog_api_client.v2.model.create_connection_request_data import CreateConnectionRequestData
from datadog_api_client.v2.model.create_connection_request_data_attributes import CreateConnectionRequestDataAttributes
from datadog_api_client.v2.model.create_connection_request_data_attributes_fields_items import (
    CreateConnectionRequestDataAttributesFieldsItems,
)
from datadog_api_client.v2.model.update_connection_request_data_type import UpdateConnectionRequestDataType

body = CreateConnectionRequest(
    data=CreateConnectionRequestData(
        attributes=CreateConnectionRequestDataAttributes(
            fields=[
                CreateConnectionRequestDataAttributesFieldsItems(
                    description="Customer subscription tier from `CRM`",
                    display_name="Customer Tier",
                    id="customer_tier",
                    source_name="subscription_tier",
                    type="string",
                ),
                CreateConnectionRequestDataAttributesFieldsItems(
                    description="Customer lifetime value in `USD`",
                    display_name="Lifetime Value",
                    id="lifetime_value",
                    source_name="ltv",
                    type="number",
                ),
            ],
            join_attribute="user_email",
            join_type="email",
            type="ref_table",
        ),
        id="crm-integration",
        type=UpdateConnectionRequestDataType.CONNECTION_ID,
    ),
)

configuration = Configuration()
configuration.unstable_operations["create_connection"] = True
with ApiClient(configuration) as api_client:
    api_instance = RumAudienceManagementApi(api_client)
    api_instance.create_connection(entity="users", body=body)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Create connection returns "Connection created successfully" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.create_connection".to_sym] = true
end
api_instance = DatadogAPIClient::V2::RumAudienceManagementAPI.new

body = DatadogAPIClient::V2::CreateConnectionRequest.new({
  data: DatadogAPIClient::V2::CreateConnectionRequestData.new({
    attributes: DatadogAPIClient::V2::CreateConnectionRequestDataAttributes.new({
      fields: [
        DatadogAPIClient::V2::CreateConnectionRequestDataAttributesFieldsItems.new({
          description: "Customer subscription tier from `CRM`",
          display_name: "Customer Tier",
          id: "customer_tier",
          source_name: "subscription_tier",
          type: "string",
        }),
        DatadogAPIClient::V2::CreateConnectionRequestDataAttributesFieldsItems.new({
          description: "Customer lifetime value in `USD`",
          display_name: "Lifetime Value",
          id: "lifetime_value",
          source_name: "ltv",
          type: "number",
        }),
      ],
      join_attribute: "user_email",
      join_type: "email",
      type: "ref_table",
    }),
    id: "crm-integration",
    type: DatadogAPIClient::V2::UpdateConnectionRequestDataType::CONNECTION_ID,
  }),
})
p api_instance.create_connection("users", body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Create connection returns "Connection created successfully" response

package main

import (
	"context"
	"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.CreateConnectionRequest{
		Data: &datadogV2.CreateConnectionRequestData{
			Attributes: &datadogV2.CreateConnectionRequestDataAttributes{
				Fields: []datadogV2.CreateConnectionRequestDataAttributesFieldsItems{
					{
						Description: datadog.PtrString(`Customer subscription tier from ` + "`" + `CRM` + "`"),
						DisplayName: datadog.PtrString("Customer Tier"),
						Id:          "customer_tier",
						SourceName:  "subscription_tier",
						Type:        "string",
					},
					{
						Description: datadog.PtrString(`Customer lifetime value in ` + "`" + `USD` + "`"),
						DisplayName: datadog.PtrString("Lifetime Value"),
						Id:          "lifetime_value",
						SourceName:  "ltv",
						Type:        "number",
					},
				},
				JoinAttribute: "user_email",
				JoinType:      "email",
				Type:          "ref_table",
			},
			Id:   datadog.PtrString("crm-integration"),
			Type: datadogV2.UPDATECONNECTIONREQUESTDATATYPE_CONNECTION_ID,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateConnection", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewRumAudienceManagementApi(apiClient)
	r, err := api.CreateConnection(ctx, "users", body)

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

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create connection returns "Connection created successfully" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RumAudienceManagementApi;
import com.datadog.api.client.v2.model.CreateConnectionRequest;
import com.datadog.api.client.v2.model.CreateConnectionRequestData;
import com.datadog.api.client.v2.model.CreateConnectionRequestDataAttributes;
import com.datadog.api.client.v2.model.CreateConnectionRequestDataAttributesFieldsItems;
import com.datadog.api.client.v2.model.UpdateConnectionRequestDataType;
import java.util.Arrays;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.createConnection", true);
    RumAudienceManagementApi apiInstance = new RumAudienceManagementApi(defaultClient);

    CreateConnectionRequest body =
        new CreateConnectionRequest()
            .data(
                new CreateConnectionRequestData()
                    .attributes(
                        new CreateConnectionRequestDataAttributes()
                            .fields(
                                Arrays.asList(
                                    new CreateConnectionRequestDataAttributesFieldsItems()
                                        .description("Customer subscription tier from `CRM`")
                                        .displayName("Customer Tier")
                                        .id("customer_tier")
                                        .sourceName("subscription_tier")
                                        .type("string"),
                                    new CreateConnectionRequestDataAttributesFieldsItems()
                                        .description("Customer lifetime value in `USD`")
                                        .displayName("Lifetime Value")
                                        .id("lifetime_value")
                                        .sourceName("ltv")
                                        .type("number")))
                            .joinAttribute("user_email")
                            .joinType("email")
                            .type("ref_table"))
                    .id("crm-integration")
                    .type(UpdateConnectionRequestDataType.CONNECTION_ID));

    try {
      apiInstance.createConnection("users", body);
    } catch (ApiException e) {
      System.err.println("Exception when calling RumAudienceManagementApi#createConnection");
      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 and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Create connection returns "Connection created successfully" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_rum_audience_management::RumAudienceManagementAPI;
use datadog_api_client::datadogV2::model::CreateConnectionRequest;
use datadog_api_client::datadogV2::model::CreateConnectionRequestData;
use datadog_api_client::datadogV2::model::CreateConnectionRequestDataAttributes;
use datadog_api_client::datadogV2::model::CreateConnectionRequestDataAttributesFieldsItems;
use datadog_api_client::datadogV2::model::UpdateConnectionRequestDataType;

#[tokio::main]
async fn main() {
    let body = CreateConnectionRequest::new().data(
        CreateConnectionRequestData::new(UpdateConnectionRequestDataType::CONNECTION_ID)
            .attributes(
                CreateConnectionRequestDataAttributes::new(
                    "user_email".to_string(),
                    "email".to_string(),
                    "ref_table".to_string(),
                )
                .fields(vec![
                    CreateConnectionRequestDataAttributesFieldsItems::new(
                        "customer_tier".to_string(),
                        "subscription_tier".to_string(),
                        "string".to_string(),
                    )
                    .description(r#"Customer subscription tier from `CRM`"#.to_string())
                    .display_name("Customer Tier".to_string()),
                    CreateConnectionRequestDataAttributesFieldsItems::new(
                        "lifetime_value".to_string(),
                        "ltv".to_string(),
                        "number".to_string(),
                    )
                    .description(r#"Customer lifetime value in `USD`"#.to_string())
                    .display_name("Lifetime Value".to_string()),
                ]),
            )
            .id("crm-integration".to_string()),
    );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateConnection", true);
    let api = RumAudienceManagementAPI::with_config(configuration);
    let resp = api.create_connection("users".to_string(), body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Create connection returns "Connection created successfully" response
 */

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

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.createConnection"] = true;
const apiInstance = new v2.RumAudienceManagementApi(configuration);

const params: v2.RumAudienceManagementApiCreateConnectionRequest = {
  body: {
    data: {
      attributes: {
        fields: [
          {
            description: `Customer subscription tier from ` + "`" + `CRM` + "`",
            displayName: "Customer Tier",
            id: "customer_tier",
            sourceName: "subscription_tier",
            type: "string",
          },
          {
            description: `Customer lifetime value in ` + "`" + `USD` + "`",
            displayName: "Lifetime Value",
            id: "lifetime_value",
            sourceName: "ltv",
            type: "number",
          },
        ],
        joinAttribute: "user_email",
        joinType: "email",
        type: "ref_table",
      },
      id: "crm-integration",
      type: "connection_id",
    },
  },
  entity: "users",
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"