Skip to main content
If you track a competitor’s launches and business news by hand, you repeat the same web searches. You also read links that you already reviewed. The Monitor API runs your Search query on the server at the scheduled times. It uses your goal to filter new candidate results. It saves the findings in the run history, so you can close your terminal and read the results later.

What you will build

The daily Search monitor checks for product launches, announcements about availability, partnerships, and business news about Samsung Electronics.
  • Create the monitor.
  • Poll the run history until the first run finishes.
  • Get the saved findings.
  • Start a manual run.
  • Pause or delete the monitor when you finish.
This example uses one Search target across the web without a webhook. Use webhooks to receive change notifications without polling for results. You get the result of the first run as monitor.created only if you subscribe.
See the Search guide for the query options, the filters, and how the monitor removes duplicates.

Prerequisites

Use a Perplexity API key. Install the Perplexity Python library (perplexityai>=0.47.0) or @perplexity-ai/perplexity_ai (>=0.42.0), or use curl and jq. Review Monitor API pricing before you start. API organizations that require zero data retention cannot create or resume monitors and cannot start manual runs.

Set up your API key

Set PERPLEXITY_API_KEY in your shell environment. The perplexityai and @perplexity-ai/perplexity_ai libraries read this variable automatically.

Create the monitor

When you create the monitor, the first run is due immediately. The Monitor API schedules daily checks until you pause or delete the monitor. The query sets the topic of the search. The monitor uses goal to keep substantive reports and exclude rumors, reviews, and duplicate reports. To track a different company, replace name, query, and goal. See Freshness for the freshness windows across runs. See Deduplication and results for how the monitor removes duplicate URLs across runs.
Export the id that the create request returns. The next steps use this ID for your monitor.

Check the monitor’s status

Get the saved monitor. Check its configuration, status, last_run, and next_run_at. If a monitor pauses unexpectedly, check pause_reason. See Automatic pausing for details.

Read the findings

The first run starts asynchronously after you create the monitor. Poll the run history with a retry limit until the newest run has a status other than queued or running. This read-only request returns saved runs and does not start another search. The Monitor API keeps the run history for 90 days. See Run status and history for the run statuses and the history rules. See Queries and goals for how the monitor evaluates Search results and gives them a score in confidence.
Each finding in changes has type: "search_result", a stable id, the source url, and a confidence score. The title, snippet, published_at, and last_updated_at fields are optional.

Run a check now

After the first run finishes, you can request a manual check before the next scheduled check. The same Monitor API pricing applies to manual and scheduled runs that succeed. Perplexity does not charge for runs that fail or that the Monitor API skips.
  • If the Monitor API returns 202, get the run with the id in the response.
  • If the Monitor API returns 409 run_in_progress, get the run with the ID in error.current_run_id instead.
  • If the Monitor API returns 409 invalid_state, resume the monitor before you try again.

Pause when finished

Pause the monitor to stop scheduled checks. The monitor keeps its state and saved history. See Pause and resume for details.

Optionally delete it

When you delete the monitor, the Monitor API removes it, its run history, and its saved state. Export any findings you want to keep before you delete the monitor.

Limits

Scheduled checks continue after your shell exits. Pause or delete the monitor when you finish.