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

# Add delegated admin

> Grant an organization member Macroscope workspace Admin

Grants a member of the workspace's GitHub organization Macroscope workspace Admin, as **Add admin** does on the **Delegated admins** page. Available only for GitHub organization workspaces. The grant takes effect for access right away. Granting someone who is already a delegated admin succeeds and changes nothing. The grant stays in place until it is revoked, including after the API key that made it is revoked or expires. A delegated admin who leaves the GitHub organization loses this access, but stays listed until a workspace admin removes the grant. If a key is compromised, find the grants it made by `grantedByApiKeyId` in [List delegated admins](https://docs.macroscope.com/api-reference/endpoint/list-delegated-admins.md) or in the workspace audit log, and [remove](https://docs.macroscope.com/api-reference/endpoint/remove-delegated-admin.md) any you don't want. Each attempt, including a refused or invalid one, is recorded in the workspace audit log with its outcome and the API key, or the person and connected app, that made it. Requests rejected before they reach the operation, such as malformed requests, invalid credentials and rate-limited requests, may have no entry. The entry is a member management event that names the GitHub user granted.

> [!WARNING]
>
> A delegated admin has Macroscope workspace Admin: they can do anything a workspace admin can, including creating API keys, managing billing, and granting or revoking admin for others. A grant made with an API key gives the person more access than the key itself has.

## Authorization

Requires an **Admin** API key, or an [OAuth sign-in](https://docs.macroscope.com/api-reference/mcp.md#permissions) with **Admin** access by a person who is a workspace admin. Read and Write keys get `403`, and a sign-in with Read or Write access gets an `insufficient_scope` challenge for `macroscope:admin`.

**Authorization** `string` *required*

`Bearer <key>`. See [Authentication](https://docs.macroscope.com/api#authentication).

**X-Macroscope-Initiation** `string`

How your client identifies the source of the request in the workspace audit log. Use `human` or `agent`. Macroscope records the client's value without verifying it. Other values are treated as unspecified.

## Path parameters

**workspaceType** `string` *required*

`GITHUB_ORGANIZATION` or `GITHUB_USER`.

**workspaceId** `string` *required*

Numeric GitHub ID of the organization or user.

## Body

**githubUserId** `string` *required*

GitHub user ID of a member of the workspace's GitHub organization, as a decimal string.

## Response

**changed** `boolean`

Whether the grant is new. Omitted when `false`, meaning the person was already a delegated admin.

## Errors

<table>
  <colgroup>
    <col width="100" />

    <col width="698" />
  </colgroup>

  <thead>
    <tr>
      <th>HTTP</th>
      <th>Meaning</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`400`</td>
      <td>Invalid body, or the user is not a member of the workspace's GitHub organization</td>
    </tr>

    <tr>
      <td>`403`</td>
      <td>Your credential or your permissions do not allow managing delegated admins</td>
    </tr>
  </tbody>
</table>

See [Errors](https://docs.macroscope.com/api#errors) for the rest.

```bash cURL theme={null}
curl -X POST https://api.macroscope.com/api/v1/workspaces/GITHUB_ORGANIZATION/12345678/delegatedAdmins \
  -H "Authorization: Bearer $MACROSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"githubUserId": "10293847"}'
```

```json 200 theme={null}
{
  "changed": true
}
```

```json 401 theme={null}
{ "code": 16, "message": "unauthenticated" }
```


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