How to list your Phantoms and get their Agent IDs via API

Sophie
Sophie This badge shows you’re hearing straight from the source! Team members are here to share insider tips, answer questions, and guide you through PhantomBuster with expert knowledge. They’re dedicated to helping you succeed and making sure your automation journey feels easy and exciting. PhantomBuster Official
  • Updated

To list all your Phantoms and their Agent IDs via the PhantomBuster API, call GET /agents/fetch-all with your API key. This returns every Phantom in your workspace with its ID, name, and configuration. To get Agent IDs only for Phantoms that ran during a specific period, use GET /orgs/export-agent-usage with a time range (up to 6 months).

If you only need the Agent ID of one specific Phantom, you can find it in the Phantom’s URL after opening it from your Dashboard.
→ Learn how in How to find your Agent ID for API calls.

Before you start

Before retrieving Phantom Agent IDs via API, make sure:

  • You have a valid PhantomBuster API key
    → If you don't have one, see Create an API key. API keys can only be created by Workspace admins, if you don't see the Add API key button, check with your admin.
  • You know what you want to retrieve:
    • A full list of all your Phantoms and their Agent IDs.
    • Agent IDs only for Phantoms that ran during a specific time range (up to 6 months).

The sections below explain both options.

How retrieving Agent IDs via API works

Phantom Agent IDs can be retrieved in two ways:

  • By listing all Phantoms in your Workspace.
  • By exporting usage data for a specific time range.

Both methods return Agent IDs that can be reused in other API calls, such as launching a Phantom, updating its configuration, or retrieving results.

Option 1: Get all Phantoms using the API reference

This method returns every Phantom in your Workspace along with its configuration details.

Step 1: Open the endpoint

  1. Open the PhantomBuster API reference.
  2. In the left menu, go to:

    PhantomBuster API v2 → Agents → GET /agents/fetch-all

→ This endpoint returns all Phantoms in your Workspace.

PhantomBuster API reference showing the GET /agents/fetch-all endpoint

Step 2: Add your API key

  1. In the top-right corner, locate the Credentials section.
  2. In the Header, paste your API key into X-Phantombuster-Key.
PhantomBuster API reference Credentials section showing the X-Phantombuster-Key field for /agents/fetch-all

Step 3: Send the request

  • In the Request box on the right-hand side, click Try it to send the request.

    PhantomBuster API reference showing the Try it button for /agents/fetch-all
  • If the request is successful, the response returns:

    • A 200 status.
    • An array of Phantom objects in JSON format. 
      Each object includes:
      • id → The Phantom’s Agent ID.
      • name → The Phantom’s name in your Workspace.
      • Additional configuration fields such as script, branch, environment, and settings.
    PhantomBuster API reference response showing the array of Phantom objects with id and name

Option 2: Get Agent IDs from recent Phantom usage using the API reference

This method returns usage data for Phantoms that ran during a specific time range.

You can define how many days to look back. The maximum time range is 6 months.

Step 1: Open the endpoint

  1. Open the PhantomBuster API reference.
  2. In the left menu, go to:

    PhantomBuster API v2 → Orgs → GET /orgs/export-agent-usage

→ This endpoint exports usage data for Phantoms that ran during the selected time range.

PhantomBuster API reference showing the GET /orgs/export-agent-usage endpoint

Step 2: Add your API key

  1. In the top-right corner, locate the Credentials section.
  2. In the Header, paste your API key into X-Phantombuster-Key.
PhantomBuster API reference Credentials section showing the X-Phantombuster-Key field for /orgs/export-agent-usage

Step 3: Define the time range

  • In the Query Params section, locate the days field (required), and enter the number of days you want to export. Make sure it does not exceed 6 months.
PhantomBuster API reference /orgs/export-agent-usage Query params section showing the days field

Step 4: Send the request

  • In the Request box on the right-hand side, click Try it to send the request.

    PhantomBuster API reference showing the Try it button for /orgs/export-agent-usage
  • If the request is successful, the response returns:

    • A 200 status.
    • The response contains usage data in CSV format. The file is returned as a downloadable CSV export.
    • The exported file includes columns such as:
      • Id → The Phantom’s Agent ID
      • Name → The Phantom’s name
      • Total launches
      • Total Execution Time In Seconds
      • Script Slug
      • Created At
      • Updated At
      • Deleted status
    PhantomBuster API reference response showing the agent usage CSV export

Frequently asked questions

What's the difference between /agents/fetch-all and /orgs/export-agent-usage?

/agents/fetch-all returns all Phantoms in your Workspace with full configuration details. /orgs/export-agent-usage returns a CSV with usage data (launches, execution time) only for Phantoms that ran during the specified time range.

Is there a limit to how many Phantoms are returned?

/agents/fetch-all returns all Phantoms in your Workspace. /orgs/export-agent-usage covers up to 6 months of usage data.

Can I use the Agent IDs from these endpoints in other API calls?

Yes. The Agent IDs returned can be reused in any endpoint that requires one, such as launching, updating, or retrieving results from a Phantom.

Was this article helpful?

0 out of 0 found this helpful