> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Add users and groups

> Add users and groups to an Agent Vault delegation with the Node.js SDK.

`client.agentVault().delegations.addSubjects()` adds users and groups to a machine identity's delegation. The users and groups that are already in the delegation stay in it. Pass at least one ID. The client must log in as a user or machine identity with the **Admin** role in the [Agent Vault project](https://infisical.com/docs/documentation/platform/agent-vault/access-control#product-membership).

* If the machine identity has no delegation, `addSubjects` creates one with the `AgentVaultDelegationScope.Selected` scope
* If the delegation covers all members, you can't add users or groups to it

## Parameters

**machineIdentityId** `string` *required*

The ID of the machine identity.

**options** `object` *required*

**properties**

**projectId** `string` *required*

The ID of the [Agent Vault project](https://infisical.com/docs/documentation/platform/agent-vault/projects.md#find-the-project-id) that the delegation is in.

**userIds** `string[]`

The IDs of the users to add (up to 100).

**groupIds** `string[]`

The IDs of the groups to add (up to 100).

## Returns

**delegation** `AgentVaultDelegationDetail`

The delegation after the change, with `missingAccessBundles`.

```typescript Basic theme={"dark"}
const delegation = await client.agentVault().delegations.addSubjects("<machine-identity-id>", {
  projectId: "<project-id>",
  userIds: ["<user-id>"], // Optional
  groupIds: ["<group-id>"] // Optional
});
```

```json Response theme={"dark"}
{
  "machineIdentity": {
    "id": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
    "name": "deploy-bot"
  },
  "scope": "selected",
  "users": [
    {
      "id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
      "username": "jsmith@example.com",
      "email": "jsmith@example.com",
      "firstName": "Jo",
      "lastName": "Smith",
      "addedAt": "2026-12-02T13:10:00.000Z",
      "missingAccessBundles": []
    }
  ],
  "groups": [],
  "missingAccessBundles": [],
  "createdAt": "2026-11-20T10:00:00.000Z",
  "updatedAt": "2026-12-02T13:10:00.000Z"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.