Skip to main content
An Agent monitor runs a task with the Agent API on a schedule and saves relevant updates with their sources. Use an Agent monitor when you need a written answer, not a list of results. Use Search monitoring to find URLs for a query. Use Page monitoring to track later edits at known URLs.

Create an Agent monitor

Set PERPLEXITY_API_KEY to your API key. The Python and TypeScript examples use the Perplexity SDKs. The cURL examples use jq. When you create a monitor, its first run is due immediately. The service schedules later runs while the monitor is active. To stop the runs, pause or delete the monitor. See Cost. perplexityai 0.49.0 and @perplexity-ai/perplexity_ai 0.44.0 do not have types for the Agent target. The examples send each request with client.post, client.get, or client.patch.
The 200 response is a monitor, not a completed run. Set MONITOR_ID to its id for the requests below. Use an idempotency key if your application retries creation.
This example reads results through the API without a webhook. Use webhooks to receive change notifications without polling for results.

Read the results

A run is one execution of a monitor. Its changes array contains the updates that the run kept. Get the latest run with MONITOR_ID. The first run starts asynchronously after you create the monitor. Do not send another /run request for the first run. The two responses below show the same run. Use the IDs that your own requests return.
If the list is empty, read it again later. If the status is queued, running, or an unknown status, poll with a bounded retry policy. If the status is failed or skipped, check error. When the status is succeeded, set RUN_ID to the ID of the run in data[0].id. Then get that run. The service keeps run history for 90 days.
Each update in changes has type agent_update. A succeeded run can have an empty changes array.

Configure your agent

Put one target with type: "agent" in targets. Do not combine it with another target.

Task and goal

The task in input tells the agent what to do in each run. Set an optional top-level goal on the monitor to describe which updates to keep:
Judging runs automatically. An update must pass each check that applies to appear in changes:
  • Relevance: Checks if the update reports something that you asked for. The judge reads the task in input and, if you set one, the goal. This check runs with or without a goal.
  • Novelty: Checks if the update adds new information. This check does not apply to a first check.
A run with no saved state is a first check. A first check can save at most one update. This update describes the current state. Later runs use the saved state to find what is new. Each later run can save at most five updates. confidence is the product of the judging scores that apply.

Effort

Choose the effort level for the task. Use low or low@latest for the active version of low. To pin a version, use a value such as low@<version>. The service does not check that the version exists when you create the monitor. If the version does not exist, the run fails with error.code: "source_failed".

Profiles

Set profile to {"type": "custom", "id": "YOUR_PROFILE_ID"} to use a saved Agent API profile. Omit effort when you set profile. The service does not check that the profile exists when you create the monitor. If the Agent API cannot find or access the profile, the run fails with error.code: "source_failed". Do not use a profile that enables the sandbox tool. The service does not accept sandbox results as sources, and it drops an update that has no other source. If you also set a domain filter or only one freshness value, the run fails with error.code: "source_failed".

Filters

Set freshness to ["published"] or ["updated"] to filter the agent’s web search by publication date or last-updated date. The filter date is the UTC date of window.from in the run. See how the service sets the run window. If you select both values, the monitor applies no date filter. In include_domains and exclude_domains, use bare host names such as go.dev, without a scheme, path, or port. Each entry also covers its subdomains. Do not put the same domain in both lists. With a domain filter, sources contains only the sources that pass the filter. The service keeps an update only if it has at least one of these sources.

Saved state

The monitor keeps saved state between runs. Later runs use this saved state to find what is new. The next run is a first check when one of these values differs from the saved state:
  • The task in input
  • The top-level goal
  • The profile id or version
  • The freshness filter
  • The domains in either domain list
An equivalent value does not reset the saved state. For example, the order of the values in a list has no effect. A change to one of these fields keeps the saved state:
  • effort
  • name
  • schedule
  • webhook
  • metadata

Update your agent

Send a PATCH request with targets to replace the whole target. Repeat input and any nondefault settings that you want to keep. If you omit effort and profile, the service uses low. If you omit filters, the service resets freshness to ["published", "updated"] and clears both domain lists. If you omit one filter, the service resets that filter to its default. This example sets effort to medium and limits sources to go.dev. Because the domain list changes, the next run is a first check. The update does not start a run. The next run starts at next_run_at. To start a run before that time, request a manual run.

Cost

Perplexity bills an Agent run as Agent API usage. Perplexity does not charge a separate Monitor API fee for an Agent run. Each run reports its list cost in usage.cost.total_cost. A succeeded run with no updates can also have a cost. A failed run can have a cost. For an Agent run, usage.fetched_urls is always 0.

Run failures

A run fails with error.code: "source_failed" in conditions such as these:
  • The effort version does not exist.
  • The Agent API cannot find or access the profile.
  • The agent cannot retrieve information that is relevant to the task.
  • The service cannot read the answer from the agent.
Other failures can have a different error.code. Use error.code in your application logic. Read error.message for the reason. Do not parse error.message. After three source failures without a successful run between them, the service pauses the monitor automatically.

Next steps

Pause the monitor when you finish your test. You can also change its schedule, add webhooks, or check the API reference for the full contract.