---
title: "Attach policy to target"
url: https://hexelstudio.com/docs/api/ciam-iam/policies/attach-policy-to-target
---

# Attach policy to target

**POST** `/policies/{policy_id}/attachments`

Attach a policy to a user, group, or role

## Path parameters

- `policy_id: string`

  Policy ID

## Headers

- `Authorization: string`

  `Bearer <token>`.

## Body parameters

- `attached_at: optional string`

- `attached_by_user_id: optional string`

- `id: optional string`

- `organization_id: optional string`

- `policy_id: optional string`

- `target_id: optional string`

- `target_type: optional string`

## Returns

`201` Created (`PolicyAttachment`)

- `attached_at: optional string`

- `attached_by_user_id: optional string`

- `id: optional string`

- `organization_id: optional string`

- `policy_id: optional string`

- `target_id: optional string`

- `target_type: optional string`

## Errors

- `400` Bad Request
- `500` Internal Server Error

## Example

```bash
curl --request POST \
  --url 'https://api.hexelstudio.com/v1/policies/{policy_id}/attachments' \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
  "attached_at": "2026-01-01T00:00:00Z",
  "attached_by_user_id": "string",
  "id": "string",
  "organization_id": "string",
  "policy_id": "string",
  "target_id": "string",
  "target_type": "string"
}'
```

### Response (201)

```json
{
  "attached_at": "2026-01-01T00:00:00Z",
  "attached_by_user_id": "string",
  "id": "string",
  "organization_id": "string",
  "policy_id": "string",
  "target_id": "string",
  "target_type": "string"
}
```

### Response (400)

```json
{
  "key": "string"
}
```

### Response (500)

```json
{
  "key": "string"
}
```
