For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/api/latest/static-analysis/create-an-ai-memory-violation-result.md. A documentation index is available at /llms.txt.

Create an AI memory violation result

Note: This endpoint is in preview and is subject to change. If you have any feedback, contact Datadog support.

POST https://api.ap1.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.ap2.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.datadoghq.eu/api/v2/static-analysis/ai/memoryhttps://api.ddog-gov.com/api/v2/static-analysis/ai/memoryhttps://api.us2.ddog-gov.com/api/v2/static-analysis/ai/memoryhttps://api.uk1.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.us3.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.us5.datadoghq.com/api/v2/static-analysis/ai/memory

Overview

Add a new AI memory violation result for the authenticated organization.

Request

Body Data (required)

Expand All

Field

Type

Description

data

object

Request data for creating an AI memory violation result.

attributes

object

Attributes for creating an AI memory violation result.

line [required]

int64

The line number where the violation was found.

message [required]

string

A message explaining the violation result.

name [required]

string

The file path where the violation was found.

repository_id [required]

string

The repository identifier.

rule [required]

string

The rule identifier in the format ruleset/rule.

sha [required]

string

The git commit SHA where the violation was found.

type [required]

enum

The type of AI memory violation result indicating whether it is a true positive or false positive. Allowed enum values: TP,FP

id

string

The violation result identifier.

type

enum

AI memory violation result resource type. Allowed enum values: ai_memory_violation_result

{
  "data": {
    "attributes": {
      "line": 10,
      "message": "This is a false positive because the input is sanitized.",
      "name": "src/main.py",
      "repository_id": "my-repo",
      "rule": "my-ai-ruleset/my-ai-rule",
      "sha": "abc123def456789012345678901234567890abcd",
      "type": "FP"
    },
    "id": "violation-abc",
    "type": "ai_memory_violation_result"
  }
}

Response

Successfully created

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Unauthorized

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Not Found

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Internal Server Error

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Code Example

                  ## default
# 

# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

# 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.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/static-analysis/ai/memory" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${DD_BEARER_TOKEN}" \ -d @- << EOF { "data": { "attributes": { "line": 10, "message": "This is a false positive.", "name": "src/main.py", "repository_id": "my-repo", "rule": "my-ai-ruleset/my-ai-rule", "sha": "abc123def456789012345678901234567890abcd", "type": "FP" }, "id": "violation-abc", "type": "ai_memory_violation_result" } } EOF
"""
Create an AI memory violation result returns "Successfully created" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.static_analysis_api import StaticAnalysisApi
from datadog_api_client.v2.model.ai_memory_violation_result_data_type import AiMemoryViolationResultDataType
from datadog_api_client.v2.model.ai_memory_violation_result_request import AiMemoryViolationResultRequest
from datadog_api_client.v2.model.ai_memory_violation_result_request_attributes import (
    AiMemoryViolationResultRequestAttributes,
)
from datadog_api_client.v2.model.ai_memory_violation_result_request_data import AiMemoryViolationResultRequestData
from datadog_api_client.v2.model.ai_memory_violation_type import AiMemoryViolationType

body = AiMemoryViolationResultRequest(
    data=AiMemoryViolationResultRequestData(
        attributes=AiMemoryViolationResultRequestAttributes(
            line=10,
            message="This is a false positive because the input is sanitized.",
            name="src/main.py",
            repository_id="my-repo",
            rule="my-ai-ruleset/my-ai-rule",
            sha="abc123def456789012345678901234567890abcd",
            type=AiMemoryViolationType.FP,
        ),
        id="violation-abc",
        type=AiMemoryViolationResultDataType.AI_MEMORY_VIOLATION_RESULT,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_ai_memory_violation_result"] = True
with ApiClient(configuration) as api_client:
    api_instance = StaticAnalysisApi(api_client)
    api_instance.create_ai_memory_violation_result(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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
# Create an AI memory violation result returns "Successfully created" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
  config.unstable_operations["v2.create_ai_memory_violation_result".to_sym] = true
end
api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new

body = DatadogAPIClient::V2::AiMemoryViolationResultRequest.new({
  data: DatadogAPIClient::V2::AiMemoryViolationResultRequestData.new({
    attributes: DatadogAPIClient::V2::AiMemoryViolationResultRequestAttributes.new({
      line: 10,
      message: "This is a false positive because the input is sanitized.",
      name: "src/main.py",
      repository_id: "my-repo",
      rule: "my-ai-ruleset/my-ai-rule",
      sha: "abc123def456789012345678901234567890abcd",
      type: DatadogAPIClient::V2::AiMemoryViolationType::FP,
    }),
    id: "violation-abc",
    type: DatadogAPIClient::V2::AiMemoryViolationResultDataType::AI_MEMORY_VIOLATION_RESULT,
  }),
})
p api_instance.create_ai_memory_violation_result(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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
// Create an AI memory violation result returns "Successfully created" 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.AiMemoryViolationResultRequest{
		Data: &datadogV2.AiMemoryViolationResultRequestData{
			Attributes: &datadogV2.AiMemoryViolationResultRequestAttributes{
				Line:         10,
				Message:      "This is a false positive because the input is sanitized.",
				Name:         "src/main.py",
				RepositoryId: "my-repo",
				Rule:         "my-ai-ruleset/my-ai-rule",
				Sha:          "abc123def456789012345678901234567890abcd",
				Type:         datadogV2.AIMEMORYVIOLATIONTYPE_FP,
			},
			Id:   datadog.PtrString("violation-abc"),
			Type: datadogV2.AIMEMORYVIOLATIONRESULTDATATYPE_AI_MEMORY_VIOLATION_RESULT.Ptr(),
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateAiMemoryViolationResult", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewStaticAnalysisApi(apiClient)
	r, err := api.CreateAiMemoryViolationResult(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `StaticAnalysisApi.CreateAiMemoryViolationResult`: %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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
// Create an AI memory violation result returns "Successfully created" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.StaticAnalysisApi;
import com.datadog.api.client.v2.model.AiMemoryViolationResultDataType;
import com.datadog.api.client.v2.model.AiMemoryViolationResultRequest;
import com.datadog.api.client.v2.model.AiMemoryViolationResultRequestAttributes;
import com.datadog.api.client.v2.model.AiMemoryViolationResultRequestData;
import com.datadog.api.client.v2.model.AiMemoryViolationType;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    defaultClient.setUnstableOperationEnabled("v2.createAiMemoryViolationResult", true);
    StaticAnalysisApi apiInstance = new StaticAnalysisApi(defaultClient);

    AiMemoryViolationResultRequest body =
        new AiMemoryViolationResultRequest()
            .data(
                new AiMemoryViolationResultRequestData()
                    .attributes(
                        new AiMemoryViolationResultRequestAttributes()
                            .line(10L)
                            .message("This is a false positive because the input is sanitized.")
                            .name("src/main.py")
                            .repositoryId("my-repo")
                            .rule("my-ai-ruleset/my-ai-rule")
                            .sha("abc123def456789012345678901234567890abcd")
                            .type(AiMemoryViolationType.FP))
                    .id("violation-abc")
                    .type(AiMemoryViolationResultDataType.AI_MEMORY_VIOLATION_RESULT));

    try {
      apiInstance.createAiMemoryViolationResult(body);
    } catch (ApiException e) {
      System.err.println("Exception when calling StaticAnalysisApi#createAiMemoryViolationResult");
      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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
// Create an AI memory violation result returns "Successfully created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI;
use datadog_api_client::datadogV2::model::AiMemoryViolationResultDataType;
use datadog_api_client::datadogV2::model::AiMemoryViolationResultRequest;
use datadog_api_client::datadogV2::model::AiMemoryViolationResultRequestAttributes;
use datadog_api_client::datadogV2::model::AiMemoryViolationResultRequestData;
use datadog_api_client::datadogV2::model::AiMemoryViolationType;

#[tokio::main]
async fn main() {
    let body = AiMemoryViolationResultRequest::new().data(
        AiMemoryViolationResultRequestData::new()
            .attributes(AiMemoryViolationResultRequestAttributes::new(
                10,
                "This is a false positive because the input is sanitized.".to_string(),
                "src/main.py".to_string(),
                "my-repo".to_string(),
                "my-ai-ruleset/my-ai-rule".to_string(),
                "abc123def456789012345678901234567890abcd".to_string(),
                AiMemoryViolationType::FP,
            ))
            .id("violation-abc".to_string())
            .type_(AiMemoryViolationResultDataType::AI_MEMORY_VIOLATION_RESULT),
    );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateAiMemoryViolationResult", true);
    let api = StaticAnalysisAPI::with_config(configuration);
    let resp = api.create_ai_memory_violation_result(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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
/**
 * Create an AI memory violation result returns "Successfully created" response
 */

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

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
configuration.unstableOperations["v2.createAiMemoryViolationResult"] = true;
const apiInstance = new v2.StaticAnalysisApi(configuration);

const params: v2.StaticAnalysisApiCreateAiMemoryViolationResultRequest = {
  body: {
    data: {
      attributes: {
        line: 10,
        message: "This is a false positive because the input is sanitized.",
        name: "src/main.py",
        repositoryId: "my-repo",
        rule: "my-ai-ruleset/my-ai-rule",
        sha: "abc123def456789012345678901234567890abcd",
        type: "FP",
      },
      id: "violation-abc",
      type: "ai_memory_violation_result",
    },
  },
};

apiInstance
  .createAiMemoryViolationResult(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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"