# Delete agent graph

DELETE https://app.launchdarkly.com/api/v2/projects/{projectKey}/agent-graphs/{graphKey}

Delete an existing agent graph and all of its edges.

Reference: https://launchdarkly.com/docs/api/ai-configs/delete-agent-graph

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects/{projectKey}/agent-graphs/{graphKey}:
    delete:
      operationId: delete-agent-graph
      summary: Delete agent graph
      description: Delete an existing agent graph and all of its edges.
      tags:
        - subpackage_aiConfigs
      parameters:
        - name: projectKey
          in: path
          required: true
          schema:
            type: string
        - name: graphKey
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
        - name: LD-API-Version
          in: header
          description: Version of the endpoint.
          required: true
          schema:
            $ref: >-
              #/components/schemas/ApiV2ProjectsProjectKeyAgentGraphsGraphKeyDeleteParametersLdApiVersion
      responses:
        '204':
          description: No content
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AI Configs_deleteAgentGraph_Response_204'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    ApiV2ProjectsProjectKeyAgentGraphsGraphKeyDeleteParametersLdApiVersion:
      type: string
      enum:
        - beta
      title: ApiV2ProjectsProjectKeyAgentGraphsGraphKeyDeleteParametersLdApiVersion
    AI Configs_deleteAgentGraph_Response_204:
      type: object
      properties: {}
      description: Empty response body
      title: AI Configs_deleteAgentGraph_Response_204
    Error:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
      required:
        - message
        - code
      title: Error
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/projects/projectKey/agent-graphs/graphKey"

headers = {
    "LD-API-Version": "beta",
    "Authorization": "<apiKey>"
}

response = requests.delete(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/projects/projectKey/agent-graphs/graphKey';
const options = {
  method: 'DELETE',
  headers: {'LD-API-Version': 'beta', Authorization: '<apiKey>'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://app.launchdarkly.com/api/v2/projects/projectKey/agent-graphs/graphKey"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("LD-API-Version", "beta")
	req.Header.Add("Authorization", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/projects/projectKey/agent-graphs/graphKey")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["LD-API-Version"] = 'beta'
request["Authorization"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://app.launchdarkly.com/api/v2/projects/projectKey/agent-graphs/graphKey")
  .header("LD-API-Version", "beta")
  .header("Authorization", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://app.launchdarkly.com/api/v2/projects/projectKey/agent-graphs/graphKey', [
  'headers' => [
    'Authorization' => '<apiKey>',
    'LD-API-Version' => 'beta',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/projects/projectKey/agent-graphs/graphKey");
var request = new RestRequest(Method.DELETE);
request.AddHeader("LD-API-Version", "beta");
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "LD-API-Version": "beta",
  "Authorization": "<apiKey>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/projects/projectKey/agent-graphs/graphKey")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```