Agents

Adopt a discovered agent, or merge it into an existing one

Makes the traces that arrive FROM NOW ON from this trace source count under an agent:

  • with no body (or {}), a new agent named after the source is created (the same cap and slug rules as POST /api/v1/agents);
  • with {"agent_id": "..."}, the source is merged into that existing agent of this project.

Traces already recorded stay with the monitor that owned them: backfilled is always false. Idempotent: adopting a source again returns the same agent and creates nothing; merging a source that was already adopted into a DIFFERENT agent is a 409.

post/api/v1/agents/discovered/{id}/adopt

Request

  • Base URL: https://app.lastping.dev
  • URL: https://app.lastping.dev/api/v1/agents/discovered/{id}/adopt
  • Auth: API key in header X-Api-Key

Request body

agent_idstring uuid

Example request

{
  "agent_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
}

Response

Adopted (now, or already into the same agent).

backfilledboolean required

Always false. Adopting attributes the traces that arrive from now on; dependency and usage totals already recorded stay with the monitor that owned them.

Example response

{
  "agent": {
    "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
    "slug": "nightly-etl-bot",
    "name": "Nightly ETL bot",
    "description": "Runs the nightly ETL pipeline and owns its monitors.",
    "status": "up",
    "monitor_count": 3,
    "last_seen": "2026-07-10T03:00:05Z",
    "spend_24h": {
      "cost_usd": "0.006600",
      "cost_source": "estimated",
      "tokens_in": 150,
      "tokens_out": 50,
      "runs": 1
    },
    "runs_7d": [
      {
        "day": "2026-09-14",
        "runs": 12
      }
    ],
    "usage_24h": {
      "day": "2026-09-20",
      "model": "claude-sonnet-4-5",
      "provider": "anthropic",
      "tokens_in": 182340,
      "tokens_out": 20411,
      "tokens_cache_read": 95012,
      "tokens_cache_write": 4100,
      "cost_usd": "0.853221",
      "cost_source": "estimated",
      "origin": "traces"
    },
    "top_dependencies": [
      {
        "kind": "database",
        "name": "postgresql",
        "direction": "out",
        "calls": 1480,
        "errors": 12,
        "error_rate": 0.0081,
        "p50_ms": 10,
        "p95_ms": 25,
        "series": [
          {
            "day": "2026-09-20",
            "calls": 210,
            "errors": 2
          }
        ]
      }
    ],
    "created_at": "2026-07-01T12:00:00Z"
  }
}

Changes

No recorded changes to this operation across all 2 revisions of this API.