# Create a workspace assignment for a workspace

Launch stage: GA

`POST /api/2.0/identity/workspace-assignments`

Assigns a user, service principal, or group directly to this workspace with the given
 entitlements. Returns an error if the principal is already assigned directly.

 Entitlements are granted one at a time. If the request fails partway through, the principal
 stays assigned with only some of the entitlements. Get the assignment afterwards to check which
 were granted.

API scopes: identity

## Query parameters

- `parent` (string, optional)
  The resource name of the workspace, in the format
   `accounts/{account_id}/workspaces/{workspace_id}`. Defaults to this workspace. Any other
   workspace is rejected.

## Request body

The assignment to create. Set its `principal_id` and `entitlements`.
- `name` (string, optional, ID, Immutable)
  The resource name of the assignment, in one of these formats:
     - Account APIs:
       `accounts/{account_id}/workspaces/{workspace_id}/workspace-assignments/{principal_id}`
     - Workspace APIs: `workspace-assignments/{principal_id}`
- `principal_id` (int64, required, Immutable)
  The Databricks ID of the assigned user, service principal, or group. It can't be changed after
   the assignment is created.
- `entitlements` (array of string, optional, Unordered list)
  The entitlements granted directly by this assignment. Create and update set exactly this list,
   even if the principal also gets some of these entitlements through a group. List responses
   leave it empty.
  Possible values:
  - `WORKSPACE_ACCESS`
  - `WORKSPACE_CONSUME`
  - `DATABRICKS_SQL_ACCESS`
  - `WORKSPACE_ADMIN`
  - `ALLOW_CLUSTER_CREATE`
  - `ALLOW_INSTANCE_POOL_CREATE`

## Returns

Returns the WorkspaceAssignment object.

## Response

```json
{
  "name": "string",
  "parent": "string",
  "principal_type": "USER",
  "principal_id": 0,
  "workspace_id": 0,
  "account_id": "string",
  "entitlements": [
    "WORKSPACE_ACCESS"
  ],
  "effective_entitlements": [
    "WORKSPACE_ACCESS"
  ]
}
```

