This repository contains a Go API client for the Datadog API. The code is generated using openapi-generator and apigentools.


  • Go 1.14+


This repository contains per-major-version API client packages. Right now, Datadog has two API versions, v1 and v2.

The API v1 Client

The client library for Datadog API v1 is located in the api/v1/datadog directory. Import it with

import ""

All the documentation for this package is available here.

The API v2 Client

The client library for Datadog API v2 is located in the api/v2/datadog directory. Import it with

import ""

All the documentation for this package is available here.

Getting Started

Here's an example creating a user:

package main

import (
    datadog ""

func main() {
    ctx := context.WithValue(
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),

    body := *datadog.NewUserCreateRequest(*datadog.NewUserCreateData(*datadog.NewUserCreateAttributes(""), datadog.UsersType("users")))

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.UsersApi.CreateUser(ctx, body)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error creating user: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    responseData := resp.GetData()
    fmt.Fprintf(os.Stdout, "User ID: %s", responseData.GetId())

Save it to example.go, then run go get Set the DD_CLIENT_API_KEY and DD_CLIENT_APP_KEY to your Datadog credentials, and then run go run example.go.

Unstable Endpoints

This client includes access to Datadog API endpoints while they are in an unstable state and may undergo breaking changes. An extra configuration step is required to enable these endpoints:

    configuration.SetUnstableOperationEnabled("<OperationName>", true)

where <OperationName> is the name of the method used to interact with that endpoint. For example: GetLogsIndex, or UpdateLogsIndex

Changing Server

When talking to a different server, like the eu instance, change the ContextServerVariables:

    ctx = context.WithValue(ctx,
            "site": "",


Documentation for API endpoints and models can be found under the docs subdirectories, in v1 and v2.

It's also available on


As most of the code in this repository is generated, we will only accept PRs for files that are not modified by our code-generation machinery (changes to the generated files would get overwritten). We happily accept contributions to files that are not autogenerated, such as tests and development tooling.