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

# Delete Role

> Delete a role

## Path Parameters

<ParamField path="organizationId" type="string" required>
  Organization ID
</ParamField>

<ParamField path="roleId" type="string" required>
  Role ID
</ParamField>

## Response

```json theme={null}
{
  "message": "Role successfully deleted",
  "id": "role123"
}
```

<Warning>
  Deleting a role will remove it from all users who have it assigned. Consider the impact on user permissions before deleting.
</Warning>

## Error Responses

### Role Not Found

```json theme={null}
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Role not found"
  }
}
```

### Role In Use

```json theme={null}
{
  "error": {
    "code": "ROLE_IN_USE_BY_USERS",
    "message": "Cannot delete a role that is used in users user123, user456"
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.metabind.ai/app/v1/organizations/org123/roles/role123" \
    -H "Authorization: Bearer YOUR_JWT"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/roles/role123',
    {
      method: 'DELETE',
      headers: {
        'Authorization': 'Bearer YOUR_JWT'
      }
    }
  );

  const result = await response.json();
  console.log(result.message);
  ```

  ```swift Swift theme={null}
  var request = URLRequest(url: URL(string: "https://api.metabind.ai/app/v1/organizations/org123/roles/role123")!)
  request.httpMethod = "DELETE"
  request.setValue("Bearer YOUR_JWT", forHTTPHeaderField: "Authorization")

  let (data, _) = try await URLSession.shared.data(for: request)
  ```

  ```kotlin Kotlin theme={null}
  val response = client.delete("https://api.metabind.ai/app/v1/organizations/org123/roles/role123") {
      header("Authorization", "Bearer YOUR_JWT")
  }

  println("Deleted role")
  ```
</CodeGroup>
