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

# Policies

> Create and manage access policies

## Create

```go theme={null}
pol, err := client.Policies.Create(ctx, grantex.CreatePolicyParams{
    Name:           "Block after hours",
    Effect:         "deny",
    TimeOfDayStart: "18:00",
    TimeOfDayEnd:   "08:00",
    Scopes:         []string{"write:data"},
})
```

## List

```go theme={null}
result, err := client.Policies.List(ctx)
```

## Get

```go theme={null}
pol, err := client.Policies.Get(ctx, "policy-id")
```

## Update

```go theme={null}
name := "Updated Policy"
effect := "allow"
pol, err := client.Policies.Update(ctx, "policy-id", grantex.UpdatePolicyParams{
    Name:   &name,
    Effect: &effect,
})
```

## Delete

```go theme={null}
err := client.Policies.Delete(ctx, "policy-id")
```

## Types

### `Policy`

| Field            | Type       | Description             |
| ---------------- | ---------- | ----------------------- |
| `ID`             | `string`   | Policy ID               |
| `Name`           | `string`   | Policy name             |
| `Effect`         | `string`   | `"allow"` or `"deny"`   |
| `Priority`       | `int`      | Evaluation priority     |
| `AgentID`        | `*string`  | Scope to specific agent |
| `PrincipalID`    | `*string`  | Scope to specific user  |
| `Scopes`         | `[]string` | Affected scopes         |
| `TimeOfDayStart` | `*string`  | Start time (HH:MM)      |
| `TimeOfDayEnd`   | `*string`  | End time (HH:MM)        |
| `CreatedAt`      | `string`   | ISO 8601 timestamp      |
| `UpdatedAt`      | `string`   | ISO 8601 timestamp      |
