# Update Agency Team Member Beta

> Change a team member's role or the client workspaces they can open.

> Documentation index: https://www.foxreach.io/docs/llms.txt lists every page of these docs. Each page is also served as Markdown: add `.md` to its URL.

`PATCH` https://api.foxreach.io/api/v1/agency/team/{member_id}

> **Note:** **Beta.** Agency team endpoints are new and may change.

Requires an API key with the `write` and `admin` scopes, created by the agency workspace owner. The `admin` scope is opt-in: no default key carries it. Only keys of an Agency workspace can call it (`403 agency_required` otherwise).

Only API keys of an Agency workspace can call this endpoint (`403 agency_required` otherwise). The call always runs in the key's own workspace; `X-Workspace-Id` is ignored. Writes also need a key created by the agency workspace owner (`403 agency_owner_required` otherwise).

Send `role`, `workspaceIds` or both. A role change applies in the client workspaces the agency gave them; access a client gave them in its own Settings, Team keeps its role. `workspaceIds` is the exact set they keep: workspaces left out lose their access, and the API keys they created there are revoked.

## Path Parameters

- `member_id` string path required: The team member id from [List Agency Team](https://www.foxreach.io/docs/api-reference/agency/list-team).

## Body Parameters

- `role` string body: `manager` or `member`. Leave out to keep the role.
- `workspaceIds` string[] body: The exact set of client workspaces, at most 50. Leave out to keep the current set.

## Response

- `data` object

  - `id` string: Team member id.
  - `role` string: `manager` or `member`.
  - `workspaceIds` string[]: The client workspaces they can open now.

**Request example**

```bash cURL
curl -X PATCH "https://api.foxreach.io/api/v1/agency/team/am_abc123" \
  -H "X-API-Key: otr_your_key" \
  -H "Content-Type: application/json" \
  -d '{"role": "member", "workspaceIds": ["ws_abc123", "ws_ghi789"]}'
```

```python Python SDK (beta)
from foxreach import FoxReach

client = FoxReach(api_key="otr_your_key")
client.agency.update_team_member("am_abc123", role="member", workspace_ids=["ws_abc123", "ws_ghi789"])
```

```typescript TypeScript SDK (beta)
import { FoxReach } from "foxreach";

const client = new FoxReach({ apiKey: "otr_your_key" });
await client.agency.updateTeamMember("am_abc123", { role: "member", workspaceIds: ["ws_abc123", "ws_ghi789"] });
```

**Response example**

```json
{
  "data": {"id": "am_abc123", "role": "member", "workspaceIds": ["ws_abc123", "ws_ghi789"]}
}
```

Each change is recorded as `audit.agency_member.*` events (`agency_role_changed`, `role_changed`, `access_granted`, `access_revoked`) with the key as the actor.

## Errors

| Status | Description |
|--------|-------------|
| `401` | Missing, invalid, revoked or expired API key |
| `403` | API key does not have the required scope: `write` |
| `403` | `agency_required` or `agency_owner_required` |
| `400` | `role` is not `manager` or `member`, or a workspace is not the agency owner's |
| `404` | No team member with this id on the agency's team |
| `409` | Another change to this team was saved at the same time; try again |

## Rate Limit

- **120 requests per minute, shared by every `write` call in your workspace.** Fixed 60-second window.
- Every response includes `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset` (unix epoch seconds) and `X-RateLimit-Bucket` (`write`).
- A `429` response includes a `Retry-After` header (seconds until the bucket resets).

For client-side patterns, see [Rate Limiting](https://www.foxreach.io/docs/rate-limiting).
