> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.lakera.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.lakera.ai/_mcp/server.

# Keep a Target's Profile Up to Date

A target's recon profile is set once at creation and reused by every scan. When the
underlying application changes — new capabilities, tightened restrictions, a reworked
system prompt — the stored profile drifts out of sync, and scans start attacking a
target that no longer matches reality. Refresh the profile so Red keeps testing what you
actually ship.

There are two ways to refresh it, depending on whether you already know what changed.

## Which method to use

1. **`updateTarget`** — use it when you know the new state. You supply the change
   directly: a new name, a replacement profile, or both. Predictable and immediate; no
   recon phase runs.
2. **`runRecon`** — use it when you want Red to re-discover the profile. It relays a
   fresh round of prompts through your agent and saves the newly discovered profile on
   the target, exactly as recon did at creation time.

A rule of thumb: reach for `updateTarget` when the change is known and you can describe
it; reach for `runRecon` when the agent has changed in ways you'd rather have Red probe
for than hand-write.

## Update a known profile

`updateTarget` takes the target id and at least one of `name` or `appContext`. When
provided, `appContext` replaces the stored profile wholesale — it is always a complete
profile, matching `createOrGetTarget`. It returns a fresh `Target` reflecting the
update.

#### TypeScript

```typescript
// Rename only.
const renamed = await client.updateTarget(target.targetId, { name: "support-bot-v2" })

// Replace the recon profile (optionally alongside a rename).
const updated = await client.updateTarget(target.targetId, {
  appContext: {
    appDescription: "A customer support chatbot that now also issues store credit",
    allowedActions: ["Look up orders", "Process refunds", "Issue store credit"],
    forbiddenActions: ["Reveal internal pricing rules"],
  },
})
```

#### Python

```python
from lakera_red_sdk import ReconContext

# Rename only.
renamed = await client.update_target(target.target_id, name="support-bot-v2")

# Replace the recon profile (optionally alongside a rename).
updated = await client.update_target(
    target.target_id,
    app_context=ReconContext(
        app_description="A customer support chatbot that now also issues store credit",
        allowed_actions=["Look up orders", "Process refunds", "Issue store credit"],
        forbidden_actions=["Reveal internal pricing rules"],
    ),
)
```

## Re-discover the profile with recon

`runRecon` refreshes the profile the same way it was first built: by relaying prompts
through your agent. Pass the target id and a handler; it returns the recon profile the
run produced (or `undefined`/`None` when it yielded nothing usable). Use it when the
agent has changed and you'd rather have Red re-probe it than describe the changes by
hand.

#### TypeScript

```typescript
const recon = await client.runRecon(target.targetId, async (session) => {
  for await (const { attack, respond } of session) {
    const reply = await myAgent.chat(attack)
    await respond(reply)
  }
})
```

#### Python

```python
async def handler(session):
    async for message in session:
        reply = await my_agent.chat(message.attack)
        await message.respond(reply)


recon = await client.run_recon(target.target_id, handler)
```

> **Note**
>
> Both methods persist the refreshed profile on the target, so later scans against the
> same `targetId` use it automatically. `updateTarget` returns the updated `Target`;
> `runRecon` returns the profile it discovered (or `undefined`/`None` when the run
> yielded nothing usable). Call `getTarget` if you need the target's persisted state.

See [Updating a Target](/docs/red/sdk-reference#updating-a-target) and
[Running Recon](/docs/red/sdk-reference#running-recon) in the SDK Reference for the full
parameter lists.