How to chain Phantoms 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 chain Phantoms via the PhantomBuster API, launch the first Phantom, wait for it to finish, retrieve its result file URL, then pass that URL as the spreadsheetUrl input when launching the next Phantom. Repeat for each step in the chain. The API does not support launching Workflows, so chaining is handled by your own API calls or automation tool.

Before you start

Before chaining Phantoms 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.
  • Each Phantom is already fully set up and works when launched manually.
  • You know the Agent ID of each Phantom you want to chain.
  • The first Phantom in the chain generates a result file (CSV or JSON).
  • The next Phantom accepts a file-based input (for example, spreadsheetUrl).

→ If needed, start with How to Get Started with the PhantomBuster API and How to launch a Phantom via API.

How chaining Phantoms via API works

The PhantomBuster API doesn’t support launching Workflows.

However, you can recreate a simple multi-step process by launching individual Phantoms one after another and reusing the output of each step as input for the next.

At a high level, this works as follows:

  1. Launch a Phantom via API.
  2. Wait for the Phantom to finish running.
  3. Retrieve the result file URL it generated (CSV or JSON).
  4. Pass that file URL as input when launching the next Phantom via API.
  5. Repeat the process for each step in your chain.

Each Phantom runs independently. The “chaining” logic is handled by your API calls or automation tool, not inside PhantomBuster.

What kind of data can be reused between Phantoms

API-based chaining relies on file-based input passed through the spreadsheetUrl field.

This field can point to:

  • A Google Sheet
  • A public CSV file, including a PhantomBuster result file (for example, result.csv)

In practice:

  • The first Phantom generates a result file (for example a CSV).
  • You reuse the full file URL of that result as the spreadsheetUrl input when launching the next Phantom.

Not all Phantoms accept file-based input, so always check the Phantom’s setup to confirm that spreadsheetUrl is supported.

Step 1: Launch the first Phantom via API

Start by launching the first Phantom using the standard launch endpoint:

  1. Open the PhantomBuster API reference to launch the first Phantom.
  2. In the left menu, go to:
    PhantomBuster API v2 → Agents → POST /api/v2/agents/launch
    PhantomBuster API reference showing the POST /agents/launch endpoint
  3. Add the API key in the Credentials section and the Phantom ID in the Body Params section. 
    Click Try it! to launch it. 
    PhantomBuster API reference launching the first Phantom with the API key and Agent ID set

This first Phantom must generate a result file (CSV or JSON).
Examples: LinkedIn Search Export or LinkedIn Profile Scraper

Step 2: Get the result file URL

After the Phantom finishes running:

  • Retrieve its results via the API using the POST /api/v2/agents/fetch endpoint.
    PhantomBuster API reference showing the POST /agents/fetch endpoint to retrieve results
  • Build the result file URL. 
    For example: https://phantombuster.s3.amazonaws.com/E5czzj975lU/BIcIPWVRhDy3pjF04LyTtw/result.csv
    PhantomBuster API response showing the first Phantom result file location
    This URL is what you’ll reuse as input for your next Phantom.

→ If needed, see How to retrieve a Phantom’s result files (CSV or JSON) via API.

Step 3: Identify where the next Phantom expects a file as input

At this point, you have everything needed to launch the next Phantom. Now you need to identify which input field in the second Phantom should receive the file URL.

Open the second Phantom in your PhantomBuster Dashboard and:

  1. Open its setup and switch to JSON view.
    PhantomBuster second Phantom setup JSON view showing its input fields
  2. Identify the input field that accepts a file and 
    → Most commonly, this is: spreadsheetUrl
    PhantomBuster second Phantom setup JSON view showing the spreadsheetUrl input field

→ This is the field you’ll populate with the result file URL from the first Phantom.

Step 4: Pass the first Phantom’s result file to the second Phantom

When launching the second Phantom via API:

  • Use the same POST /agents/launch endpoint.
  • Add your API key and set the Agent ID of the second Phantom.
  • In the arguments, replace the value of spreadsheetUrl with the full result file URL generated by the first Phantom.
PhantomBuster API reference launching the second Phantom with spreadsheetUrl set to the first Phantom result file URL

Example (conceptual):

  • First Phantom → Generates a result file. Result file URL example: https://cache1.phantombooster.com/WkmfRpzZZus/QJqnY7h3agbHJ2fs58uYBg/result.csv
  • Second Phantom → Expects spreadsheetUrl.
  • You paste the entire URL into spreadsheetUrl. Example:
    spreadsheetUrl = https://cache1.phantombooster.com/WkmfRpzZZus/QJqnY7h3agbHJ2fs58uYBg/result.csv

This allows the second Phantom to load and process the output produced by the first one.

Step 5: Launch the second Phantom

  • Send the API request: The second Phantom now processes the data produced by the first one.
    PhantomBuster API response showing the second Phantom processing the first Phantom output
  • You can repeat this pattern to chain additional Phantoms.

Important limitations to know

  • Each Phantom must run at least once and generate a result file before its output can be reused.
  • Not all Phantoms accept file-based input.
  • Some Phantoms only accept single URLs, not files.
  • You control the sequence manually (via API or your automation tool).

Frequently asked questions

Can I chain Phantoms directly inside PhantomBuster?

Not via the API. Workflows handle multi-step processes inside PhantomBuster, but they can't be triggered via API. To chain Phantoms programmatically, you launch each one separately and pass results between them.

What if a Phantom only accepts a single URL, not a file?

That Phantom can't be used in a file-based chain. You'd need to extract individual URLs from the first Phantom's results and launch the second Phantom once per URL.

How do I know when the first Phantom has finished?

Poll the API using the /agents/fetch endpoint to check the Phantom's status, or use webhooks/notifications to detect when a run completes.

Can I automate this with tools like Make, Zapier, or n8n?

Yes. These tools can orchestrate the API calls, handle waiting for completion, and pass result URLs between steps automatically.

Was this article helpful?

0 out of 0 found this helpful