> ## Documentation Index
> Fetch the complete documentation index at: https://docs.logic.inc/llms.txt
> Use this file to discover all available pages before exploring further.

# Past Agent Executions

> How to read and delete past agent executions

## Agent Executions

An agent execution represents a single run of an agent—including the time it ran, its status, and the input/output.

You can review agent executions to monitor how your agent has been used over time.

### Get Agent Executions

To get the agent executions for all your agents, you can use the `GET /agent_executions/` endpoint.

#### Example for All Agents

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.logic.inc/v1/agent_executions/
    -H "Authorization: Bearer $LOGIC_API_TOKEN"
  ```

  ```bash httpie theme={null}
  http GET https://api.logic.inc/v1/agent_executions/
    "Authorization:Bearer $LOGIC_API_TOKEN"
  ```

  ```python python theme={null}
  import requests

  LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

  headers = {
      "Authorization": f"Bearer {LOGIC_API_TOKEN}"
  }

  response = requests.get("https://api.logic.inc/v1/agent_executions/", headers=headers)
  print(response.status_code, response.text)
  ```

  ```ruby ruby theme={null}
  require 'net/http'
  require 'uri'

  uri = URI('https://api.logic.inc/v1/agent_executions/')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  LOGIC_API_TOKEN = 'ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  request = Net::HTTP::Get.new(uri)
  request["Authorization"] = "Bearer #{LOGIC_API_TOKEN}"

  response = http.request(request)
  puts response.code
  puts response.body
  ```

  ```javascript javascript theme={null}
  const LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

  fetch("https://api.logic.inc/v1/agent_executions/", {
    headers: {
      Authorization: `Bearer ${LOGIC_API_TOKEN}`,
    },
  })
    .then((res) => res.text())
    .then(console.log)
    .catch(console.error);
  ```

  ```go go theme={null}
  package main

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

  const LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

  func main() {
      url := "https://api.logic.inc/v1/agent_executions/"

      req, err := http.NewRequest("GET", url, nil)
      if err != nil {
          panic(err)
      }

      req.Header.Set("Authorization", "Bearer " + LOGIC_API_TOKEN)

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          panic(err)
      }

      fmt.Println(string(body))
  }
  ```

  ```java java theme={null}
  // Java requires the OkHttp library. You can add it to your project using Maven or Gradle. Learn more in the Java Quick Start section of the API reference.

  import okhttp3.*;
  import java.io.IOException;

  public class Main {
      public static void main(String[] args) throws IOException {
          OkHttpClient client = new OkHttpClient();

          Request request = new Request.Builder()
              .url("https://api.logic.inc/v1/agent_executions/")
              .addHeader("Authorization", "Bearer ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
              .build();

          try (Response response = client.newCall(request).execute()) {
              if (!response.isSuccessful()) {
                  System.err.println("Request failed: " + response.code());
                  return;
              }

              System.out.println(response.body().string());
          }
      }
  }
  ```
</CodeGroup>

<Info>
  This will return a list of all the executions for the agents in your
  organization.
</Info>

### List All Agent Executions for a Specific Agent

To get the agent executions for a specific agent, you can use the `GET /agents/{agent_id}/executions` endpoint. This will return a list of all the executions for the specified agent.

You can learn more about how to get the agent ID in the [Agent IDs](/api-reference/agents/agent-id) section.

#### Example for a Specific Agent

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.logic.inc/v1/agents/{agent_id}/executions/
    -H "Authorization: Bearer $LOGIC_API_TOKEN"
  ```

  ```bash httpie theme={null}
  http GET https://api.logic.inc/v1/agents/{agent_id}/executions/
    "Authorization:Bearer $LOGIC_API_TOKEN"
  ```

  ```python python theme={null}
  import requests

  LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

  headers = {
      "Authorization": f"Bearer {LOGIC_API_TOKEN}"
  }

  response = requests.get("https://api.logic.inc/v1/agents/{agent_id}/executions/", headers=headers)
  print(response.status_code, response.text)
  ```

  ```ruby ruby theme={null}
  require 'net/http'
  require 'uri'

  uri = URI('https://api.logic.inc/v1/agents/{agent_id}/executions/')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  LOGIC_API_TOKEN = 'ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  request = Net::HTTP::Get.new(uri)
  request["Authorization"] = "Bearer #{LOGIC_API_TOKEN}"

  response = http.request(request)
  puts response.code
  puts response.body
  ```

  ```javascript javascript theme={null}
  const LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

  fetch("https://api.logic.inc/v1/agents/{agent_id}/executions/", {
    headers: {
      Authorization: `Bearer ${LOGIC_API_TOKEN}`,
    },
  })
    .then((res) => res.text())
    .then(console.log)
    .catch(console.error);
  ```

  ```go go theme={null}
  package main

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

  const LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

  func main() {
      url := "https://api.logic.inc/v1/agents/{agent_id}/executions/"

      req, err := http.NewRequest("GET", url, nil)
      if err != nil {
          panic(err)
      }

      req.Header.Set("Authorization", "Bearer " + LOGIC_API_TOKEN)

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          panic(err)
      }

      fmt.Println(string(body))
  }
  ```

  ```java java theme={null}
  // Java requires the OkHttp library. You can add it to your project using Maven or Gradle. Learn more in the Java Quick Start section of the API reference.

  import okhttp3.*;
  import java.io.IOException;

  public class Main {
      public static void main(String[] args) throws IOException {
          OkHttpClient client = new OkHttpClient();

          Request request = new Request.Builder()
              .url("https://api.logic.inc/v1/agents/{agent_id}/executions/")
              .addHeader("Authorization", "Bearer ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
              .build();

          try (Response response = client.newCall(request).execute()) {
              if (!response.isSuccessful()) {
                  System.err.println("Request failed: " + response.code());
                  return;
              }

              System.out.println(response.body().string());
          }
      }
  }
  ```
</CodeGroup>

<Info>
  This will return a list of all the executions for a specified agent in your
  organization.
</Info>

<Note>
  Replace any **\{id}** in the example code, such as **\{agent\_id}** with the ID you need for your specific API call.
</Note>
