This page is not yet available in Spanish. We are working on its translation. If you have any questions or feedback about our current translation project, feel free to reach out to us!
API Management
Configure your API endpoints through the Datadog API.
Create a new API from the OpenAPI specification given.
See the API Catalog documentation for additional
information about the possible metadata.
It returns the created API ID.
This endpoint requires the apm_api_catalog_write permission.
OAuth apps require the apm_api_catalog_write authorization scope to access this endpoint.
"""
Create a new API returns "API created successfully" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.api_management_apiimportAPIManagementApiconfiguration=Configuration()configuration.unstable_operations["create_open_api"]=TruewithApiClient(configuration)asapi_client:api_instance=APIManagementApi(api_client)response=api_instance.create_open_api(openapi_spec_file=open("openapi-spec.yaml","rb"),)print(response)
# Create a new API returns "API created successfully" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.unstable_operations["v2.create_open_api".to_sym]=trueendapi_instance=DatadogAPIClient::V2::APIManagementAPI.newopts={openapi_spec_file:File.open("openapi-spec.yaml","r"),}papi_instance.create_open_api(opts)
// Create a new API returns "API created successfully" response
packagemainimport("context""encoding/json""fmt""io""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.CreateOpenAPI",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewAPIManagementApi(apiClient)resp,r,err:=api.CreateOpenAPI(ctx,*datadogV2.NewCreateOpenAPIOptionalParameters().WithOpenapiSpecFile(func()io.Reader{fp,_:=os.Open("openapi-spec.yaml");returnfp}()))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `APIManagementApi.CreateOpenAPI`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `APIManagementApi.CreateOpenAPI`:\n%s\n",responseContent)}
// Create a new API returns "API created successfully" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ApiManagementApi;importcom.datadog.api.client.v2.api.ApiManagementApi.CreateOpenAPIOptionalParameters;importcom.datadog.api.client.v2.model.CreateOpenAPIResponse;importjava.io.File;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("v2.createOpenAPI",true);ApiManagementApiapiInstance=newApiManagementApi(defaultClient);try{CreateOpenAPIResponseresult=apiInstance.createOpenAPI(newCreateOpenAPIOptionalParameters().openapiSpecFile(newFile("openapi-spec.yaml")));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ApiManagementApi#createOpenAPI");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Create a new API returns "API created successfully" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_api_management::APIManagementAPI;usedatadog_api_client::datadogV2::api_api_management::CreateOpenAPIOptionalParams;usestd::fs;#[tokio::main]asyncfnmain(){letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.CreateOpenAPI",true);letapi=APIManagementAPI::with_config(configuration);letresp=api.create_open_api(CreateOpenAPIOptionalParams::default().openapi_spec_file(fs::read("openapi-spec.yaml").unwrap()),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Create a new API returns "API created successfully" response
*/import*asfsfrom"fs";import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.createOpenAPI"]=true;constapiInstance=newv2.APIManagementApi(configuration);constparams: v2.APIManagementApiCreateOpenAPIRequest={openapiSpecFile:{data: Buffer.from(fs.readFileSync("openapi-spec.yaml","utf8")),name:"openapi-spec.yaml",},};apiInstance.createOpenAPI(params).then((data: v2.CreateOpenAPIResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Update information about a specific API. The given content will replace all API content of the given ID.
The ID is returned by the create API, or can be found in the URL in the API catalog UI.
This endpoint requires the apm_api_catalog_write permission.
OAuth apps require the apm_api_catalog_write authorization scope to access this endpoint.
"""
Update an API returns "API updated successfully" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.api_management_apiimportAPIManagementApi# there is a valid "managed_api" in the systemMANAGED_API_DATA_ID=environ["MANAGED_API_DATA_ID"]configuration=Configuration()configuration.unstable_operations["update_open_api"]=TruewithApiClient(configuration)asapi_client:api_instance=APIManagementApi(api_client)response=api_instance.update_open_api(id=MANAGED_API_DATA_ID,openapi_spec_file=open("openapi-spec.yaml","rb"),)print(response)
# Update an API returns "API updated successfully" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.unstable_operations["v2.update_open_api".to_sym]=trueendapi_instance=DatadogAPIClient::V2::APIManagementAPI.new# there is a valid "managed_api" in the systemMANAGED_API_DATA_ID=ENV["MANAGED_API_DATA_ID"]opts={openapi_spec_file:File.open("openapi-spec.yaml","r"),}papi_instance.update_open_api(MANAGED_API_DATA_ID,opts)
// Update an API returns "API updated successfully" response
packagemainimport("context""encoding/json""fmt""io""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2""github.com/google/uuid")funcmain(){// there is a valid "managed_api" in the system
ManagedAPIDataID:=uuid.MustParse(os.Getenv("MANAGED_API_DATA_ID"))ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.UpdateOpenAPI",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewAPIManagementApi(apiClient)resp,r,err:=api.UpdateOpenAPI(ctx,ManagedAPIDataID,*datadogV2.NewUpdateOpenAPIOptionalParameters().WithOpenapiSpecFile(func()io.Reader{fp,_:=os.Open("openapi-spec.yaml");returnfp}()))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `APIManagementApi.UpdateOpenAPI`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `APIManagementApi.UpdateOpenAPI`:\n%s\n",responseContent)}
// Update an API returns "API updated successfully" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ApiManagementApi;importcom.datadog.api.client.v2.api.ApiManagementApi.UpdateOpenAPIOptionalParameters;importcom.datadog.api.client.v2.model.UpdateOpenAPIResponse;importjava.io.File;importjava.util.UUID;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("v2.updateOpenAPI",true);ApiManagementApiapiInstance=newApiManagementApi(defaultClient);// there is a valid "managed_api" in the systemUUIDMANAGED_API_DATA_ID=null;try{MANAGED_API_DATA_ID=UUID.fromString(System.getenv("MANAGED_API_DATA_ID"));}catch(IllegalArgumentExceptione){System.err.println("Error parsing UUID: "+e.getMessage());}try{UpdateOpenAPIResponseresult=apiInstance.updateOpenAPI(MANAGED_API_DATA_ID,newUpdateOpenAPIOptionalParameters().openapiSpecFile(newFile("openapi-spec.yaml")));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ApiManagementApi#updateOpenAPI");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Update an API returns "API updated successfully" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_api_management::APIManagementAPI;usedatadog_api_client::datadogV2::api_api_management::UpdateOpenAPIOptionalParams;usestd::fs;#[tokio::main]asyncfnmain(){// there is a valid "managed_api" in the system
letmanaged_api_data_id=uuid::Uuid::parse_str(&std::env::var("MANAGED_API_DATA_ID").unwrap()).expect("Invalid UUID");letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.UpdateOpenAPI",true);letapi=APIManagementAPI::with_config(configuration);letresp=api.update_open_api(managed_api_data_id.clone(),UpdateOpenAPIOptionalParams::default().openapi_spec_file(fs::read("openapi-spec.yaml").unwrap()),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Update an API returns "API updated successfully" response
*/import*asfsfrom"fs";import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.updateOpenAPI"]=true;constapiInstance=newv2.APIManagementApi(configuration);// there is a valid "managed_api" in the system
constMANAGED_API_DATA_ID=process.env.MANAGED_API_DATA_IDasstring;constparams: v2.APIManagementApiUpdateOpenAPIRequest={id: MANAGED_API_DATA_ID,openapiSpecFile:{data: Buffer.from(fs.readFileSync("openapi-spec.yaml","utf8")),name:"openapi-spec.yaml",},};apiInstance.updateOpenAPI(params).then((data: v2.UpdateOpenAPIResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get an API returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.api_management_apiimportAPIManagementApi# there is a valid "managed_api" in the systemMANAGED_API_DATA_ID=environ["MANAGED_API_DATA_ID"]configuration=Configuration()configuration.unstable_operations["get_open_api"]=TruewithApiClient(configuration)asapi_client:api_instance=APIManagementApi(api_client)response=api_instance.get_open_api(id=MANAGED_API_DATA_ID,)print(response.read())
# Get an API returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.unstable_operations["v2.get_open_api".to_sym]=trueendapi_instance=DatadogAPIClient::V2::APIManagementAPI.new# there is a valid "managed_api" in the systemMANAGED_API_DATA_ID=ENV["MANAGED_API_DATA_ID"]papi_instance.get_open_api(MANAGED_API_DATA_ID)
// Get an API returns "OK" response
packagemainimport("context""fmt""io/ioutil""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2""github.com/google/uuid")funcmain(){// there is a valid "managed_api" in the system
ManagedAPIDataID:=uuid.MustParse(os.Getenv("MANAGED_API_DATA_ID"))ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.GetOpenAPI",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewAPIManagementApi(apiClient)resp,r,err:=api.GetOpenAPI(ctx,ManagedAPIDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `APIManagementApi.GetOpenAPI`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=ioutil.ReadAll(resp)fmt.Fprintf(os.Stdout,"Response from `APIManagementApi.GetOpenAPI`:\n%s\n",responseContent)}
// Get an API returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ApiManagementApi;importjava.io.File;importjava.util.UUID;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("v2.getOpenAPI",true);ApiManagementApiapiInstance=newApiManagementApi(defaultClient);// there is a valid "managed_api" in the systemUUIDMANAGED_API_DATA_ID=null;try{MANAGED_API_DATA_ID=UUID.fromString(System.getenv("MANAGED_API_DATA_ID"));}catch(IllegalArgumentExceptione){System.err.println("Error parsing UUID: "+e.getMessage());}try{Fileresult=apiInstance.getOpenAPI(MANAGED_API_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ApiManagementApi#getOpenAPI");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get an API returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_api_management::APIManagementAPI;#[tokio::main]asyncfnmain(){// there is a valid "managed_api" in the system
letmanaged_api_data_id=uuid::Uuid::parse_str(&std::env::var("MANAGED_API_DATA_ID").unwrap()).expect("Invalid UUID");letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.GetOpenAPI",true);letapi=APIManagementAPI::with_config(configuration);letresp=api.get_open_api(managed_api_data_id.clone()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Get an API returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.getOpenAPI"]=true;constapiInstance=newv2.APIManagementApi(configuration);// there is a valid "managed_api" in the system
constMANAGED_API_DATA_ID=process.env.MANAGED_API_DATA_IDasstring;constparams: v2.APIManagementApiGetOpenAPIRequest={id: MANAGED_API_DATA_ID,};apiInstance.getOpenAPI(params).then((data: client.HttpFile)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* List APIs returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.listAPIs"]=true;constapiInstance=newv2.APIManagementApi(configuration);apiInstance.listAPIs().then((data: v2.ListAPIsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Delete an API returns "API deleted successfully" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.api_management_apiimportAPIManagementApi# there is a valid "managed_api" in the systemMANAGED_API_DATA_ID=environ["MANAGED_API_DATA_ID"]configuration=Configuration()configuration.unstable_operations["delete_open_api"]=TruewithApiClient(configuration)asapi_client:api_instance=APIManagementApi(api_client)api_instance.delete_open_api(id=MANAGED_API_DATA_ID,)
# Delete an API returns "API deleted successfully" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.unstable_operations["v2.delete_open_api".to_sym]=trueendapi_instance=DatadogAPIClient::V2::APIManagementAPI.new# there is a valid "managed_api" in the systemMANAGED_API_DATA_ID=ENV["MANAGED_API_DATA_ID"]api_instance.delete_open_api(MANAGED_API_DATA_ID)
// Delete an API returns "API deleted successfully" response
packagemainimport("context""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2""github.com/google/uuid")funcmain(){// there is a valid "managed_api" in the system
ManagedAPIDataID:=uuid.MustParse(os.Getenv("MANAGED_API_DATA_ID"))ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.DeleteOpenAPI",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewAPIManagementApi(apiClient)r,err:=api.DeleteOpenAPI(ctx,ManagedAPIDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `APIManagementApi.DeleteOpenAPI`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}}
// Delete an API returns "API deleted successfully" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ApiManagementApi;importjava.util.UUID;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("v2.deleteOpenAPI",true);ApiManagementApiapiInstance=newApiManagementApi(defaultClient);// there is a valid "managed_api" in the systemUUIDMANAGED_API_DATA_ID=null;try{MANAGED_API_DATA_ID=UUID.fromString(System.getenv("MANAGED_API_DATA_ID"));}catch(IllegalArgumentExceptione){System.err.println("Error parsing UUID: "+e.getMessage());}try{apiInstance.deleteOpenAPI(MANAGED_API_DATA_ID);}catch(ApiExceptione){System.err.println("Exception when calling ApiManagementApi#deleteOpenAPI");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Delete an API returns "API deleted successfully" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_api_management::APIManagementAPI;#[tokio::main]asyncfnmain(){// there is a valid "managed_api" in the system
letmanaged_api_data_id=uuid::Uuid::parse_str(&std::env::var("MANAGED_API_DATA_ID").unwrap()).expect("Invalid UUID");letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.DeleteOpenAPI",true);letapi=APIManagementAPI::with_config(configuration);letresp=api.delete_open_api(managed_api_data_id.clone()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Delete an API returns "API deleted successfully" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.deleteOpenAPI"]=true;constapiInstance=newv2.APIManagementApi(configuration);// there is a valid "managed_api" in the system
constMANAGED_API_DATA_ID=process.env.MANAGED_API_DATA_IDasstring;constparams: v2.APIManagementApiDeleteOpenAPIRequest={id: MANAGED_API_DATA_ID,};apiInstance.deleteOpenAPI(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));