# Create rule

> Creates a new authorization rule within an organization.

Creates a new authorization rule within an organization.

## Endpoint

`POST /api/Rule`

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | String | Yes | Name of the rule |
| `description` | String | No | Description of the rule's purpose |
| `enabled` | Boolean | Yes | Whether the rule is active |
| `definition` | String | No | The rule definition, expressed as a JSON-encoded string. |
| `partitionGlobalId` | GUID | Yes | The global identifier of the organization.  For steps on retrieving `partitionGlobalId`, refer to [Retrieving partitionGlobalId for API use](https://docs.uipath.com/test-cloud/automation-cloud/latest/api-guide/retrieving-partitionglobalid-for-api-use). |

## Request headers

```
--header 'Authorization: Bearer {access_token}'
--header 'Content-Type: application/json'
```

## Responses

:::note
1. The response returns the created rule as a `RuleDto`,
   including the generated `id`.
2. `partitionGlobalId` may be returned as the zero GUID,
   depending on the environment or rule provider behavior.
3. `definition` is persisted and returned as a JSON-encoded
   string.
4. `assignedGroups` is returned as an empty array
(`[]`) when no groups are resolved at creation time.
:::

```
{
  "id": 3684,
  "partitionGlobalId": "00000000-0000-0000-0000-000000000000",
  "name": "Test",
  "description": "Test",
  "enabled": true,
  "definition": "{\"GroupsToAssign\":[\"4d161738-7204-4794-b839-8f7fed28366c\"],\"Conditions\":[]}",
  "assignedGroups": []
}
```

## Example request

```
{
  "name": "Test",
  "description": "Test",
  "partitionGlobalId": "47a714db-cd27-4250-9668-2054e008c448",
  "enabled": true,
  "definition": "{\"GroupsToAssign\":[\"4d161738-7204-4794-b839-8f7fed28366c\"],\"Conditions\":[]}"
}
```

### Error responses

* `400 Bad Request`: Invalid request body or validation errors
* `401 Unauthorized`: Missing or invalid authentication token
* `403 Forbidden`: Insufficient permissions
* `404 Not Found`: Organization does not exist
