---
agentTools:
  projectIndex: https://hub.phantombuster.com/llms.txt
---

# /agents/fetch-output

Gets the output of the most recent container of an agent. This API endpoint is specifically designed so that it's easy to get incremental data from an agent.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "servers": [
    {
      "description": "Phantombuster api",
      "url": "https://api.phantombuster.com/api/v2"
    },
    {
      "description": "SwaggerHub API Auto Mocking",
      "url": "https://virtserver.swaggerhub.com/Phantombuster/Phantombuster-v2/2.0.0"
    }
  ],
  "info": {
    "description": "Phantombuster API v2. Swagger api specification is located at https://github.com/phantombuster/public-gists/blob/master/swagger-api-v2.json",
    "version": "2.0.0",
    "title": "Phantombuster API v2",
    "contact": {
      "email": "contact@phantombuster.com"
    },
    "license": {
      "name": "ISC",
      "url": "https://opensource.org/licenses/ISC"
    }
  },
  "components": {
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Phantombuster-Key"
      }
    }
  },
  "security": [
    {
      "apiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "agents"
    }
  ],
  "paths": {
    "/agents/fetch-output": {
      "get": {
        "description": "Gets the output of the most recent container of an agent. This API endpoint is specifically designed so that it's easy to get incremental data from an agent.\n",
        "tags": [
          "agents"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "containerId": {
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "starting",
                            "running",
                            "finished",
                            "unknown",
                            "launch error"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "never launched"
                          ]
                        }
                      ]
                    },
                    "output": {
                      "type": "string"
                    },
                    "outputPos": {
                      "type": "number"
                    },
                    "mostRecentEndedAt": {
                      "type": "number"
                    },
                    "progress": {
                      "type": "number"
                    },
                    "progressLabel": {
                      "type": "string"
                    },
                    "isAgentRunning": {
                      "type": "boolean"
                    },
                    "canSoftAbort": {
                      "type": "boolean"
                    },
                    "runtimeEvents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "slug"
                        ],
                        "properties": {
                          "timestamp": {
                            "type": "number"
                          },
                          "slug": {
                            "type": "string",
                            "maxLength": 100,
                            "pattern": "^[a-zA-Z0-9-_]+$"
                          },
                          "icon": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "type": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "category": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "title": {
                            "type": "string",
                            "maxLength": 500
                          },
                          "text": {
                            "type": "string",
                            "maxLength": 500
                          },
                          "primaryValue": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string",
                                "maxLength": 100
                              },
                              {
                                "type": "boolean"
                              }
                            ]
                          },
                          "secondaryValue": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string",
                                "maxLength": 100
                              },
                              {
                                "type": "boolean"
                              }
                            ]
                          },
                          "props": {
                            "type": "object"
                          },
                          "setupLink": {
                            "type": "string",
                            "maxLength": 100,
                            "pattern": "^(phase|step|field|advancedSettings):([\\w-])+$"
                          },
                          "redirectPage": {
                            "type": "string",
                            "maxLength": 100,
                            "pattern": "^billing$"
                          }
                        }
                      }
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "status",
                    "isAgentRunning",
                    "canSoftAbort"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid output position provided."
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "X-Phantombuster-Org",
            "description": "ID of the org that is perfoming the operation (not necessary when using a third party key)",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "required": true,
            "name": "id",
            "description": "Id of the agent to fetch output from.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "fromOutputPos",
            "description": "If set, the returned output will start from the specified position.",
            "schema": {
              "type": "number"
            }
          },
          {
            "in": "query",
            "name": "prevContainerId",
            "description": "If set, the output will be retrieved from the container after the specified previous container id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "prevStatus",
            "description": "If set, allows to define which status was previously retrieved on user-side.",
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "starting",
                    "running",
                    "finished",
                    "unknown",
                    "launch error"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "never launched"
                  ]
                }
              ]
            }
          },
          {
            "in": "query",
            "name": "prevRuntimeEventIndex",
            "description": "If set, the container's runtime events will be returned in the response starting from the provided previous runtime event index.",
            "schema": {
              "type": "number"
            }
          }
        ]
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 100,
      "1": 255,
      "2": 11,
      "3": 121,
      "4": 188,
      "5": 102,
      "6": 19,
      "7": 16,
      "8": 145,
      "9": 137,
      "10": 142,
      "11": 64
    }
  }
}
```