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

# Delete Users

> Remove Users from an Organization or a Document.

Use this API to remove Users from:

1. **Organization:** This will remove their access from all the documents and data in the organization. It will also remove these users from the contact list of the organization.
2. **Document:** This will remove their access from the specified document. It will also remove these users from the contact list of the document. If you pass the `documentId`, then the users will be removed from the document.
3. **All documents:** Pass `allDocuments: true` to remove the users from every document in the organization in one call, including any documents that have since been deleted. Their organization and folder access is not changed.

# Endpoint

`POST https://api.velt.dev/v2/users/delete`

# Headers

**x-velt-api-key** `string` *required*

Your API key.

**x-velt-auth-token** `string` *required*

Your [Auth Token](https://velt.dev/docs/security/auth-tokens.md).

# Body

#### Params

**data** `object` *required*

**properties**

**organizationId** `string` *required*

Organization ID

**documentId** `string`

Document IDs. Provide this if you want to delete users from a specific document.

**folderId** `string`

Folder ID. Either provide `documentId` or `folderId`.

**allDocuments** `boolean`

Set to `true` to remove the users from every document in the organization. Cannot be combined with `documentId`, `folderId` or `context`.

**userIds** `string[]` *required*

Array of user Ids.

## **Example Requests**

#### 1. Delete users in a specific organization

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "userIds": [
      "yourUserId1"
    ]
  }
}
```

#### 2. Delete users in a specific document within an organization

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "userIds": [
      "yourUserId1"
    ]
  }
}
```

#### 3. Delete users in a specific folder within an organization

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "folderId": "yourFolderId",
    "userIds": [
      "yourUserId1"
    ]
  }
}
```

#### 4. Delete users from all documents within an organization

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "allDocuments": true,
    "userIds": [
      "yourUserId1"
    ]
  }
}
```

# Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "User(s) deleted successfully.",
    "data": {
      "yourUserId1": {
        "success": true,
        "message": "User removed."
      }
    }
  }
}
```

#### User(s) Not Found

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "User(s) deleted successfully.",
    "data": {
      "yourUserId1": {
        "success": true,
        "message": "User removed."
      },
      {
      "yourUserId2": {
        "success": false,
        "message": "User does not exist."
      }
    }
  }
}
```

#### Success Response (`allDocuments: true`)

Each user's entry also lists the documents they were removed from (`removedDocumentIds`) and how many stored document IDs pointed to documents that no longer exist (`removedStaleDocumentIdsCount`).

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "User(s) deleted successfully.",
    "data": {
      "yourUserId1": {
        "success": true,
        "id": "yourUserId1",
        "message": "User(s) deleted successfully.",
        "removedDocumentIds": [
          "yourDocumentId1",
          "yourDocumentId2"
        ],
        "removedStaleDocumentIdsCount": 1
      }
    }
  }
}
```

With `allDocuments: true`, a user who has no document access in the organization returns `"success": false` with the message `"User does not exist."`. The request then fails with `"Error deleting user(s)."`.

#### Failure Response

```JSON theme={null}
{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
```

```js theme={null}
{
  "result": {
    "status": "success",
    "message": "User(s) deleted successfully.",
    "data": {
      "yourUserId1": {
        "success": true,
        "message": "User removed."
      }
    }
  }
}
```


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