---
title: "Write relation tuple"
url: https://hexelstudio.com/docs/api/ciam-iam/relations/create
---

# Write relation tuple

**POST** `/relations`

Writes a tuple in the caller's organization, which must have the named namespace.

## Headers

- `Authorization: string`

  `Bearer <token>`.

## Body parameters

- `created_at: optional string`

- `id: optional string`

- `namespace: optional string`

  resource type: "document"

- `object_id: optional string`

  resource id

- `organization_id: optional string`

- `relation: optional string`

  "owner", "editor", "viewer"

- `subject_id: optional string`

  user/group id

- `subject_relation: optional string`

  for userset rewrite: namespace:object#relation

- `subject_type: optional string`

  "user", "group", "namespace"

## Returns

`201` Created (`RelationTuple`)

- `created_at: optional string`

- `id: optional string`

- `namespace: optional string`

  resource type: "document"

- `object_id: optional string`

  resource id

- `organization_id: optional string`

- `relation: optional string`

  "owner", "editor", "viewer"

- `subject_id: optional string`

  user/group id

- `subject_relation: optional string`

  for userset rewrite: namespace:object#relation

- `subject_type: optional string`

  "user", "group", "namespace"

## Errors

- `400` Bad Request
- `404` Not Found

## Example

```bash
curl --request POST \
  --url 'https://api.hexelstudio.com/v1/relations' \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
  "created_at": "2026-01-01T00:00:00Z",
  "id": "string",
  "namespace": "string",
  "object_id": "string",
  "organization_id": "string",
  "relation": "string",
  "subject_id": "string",
  "subject_relation": "string",
  "subject_type": "string"
}'
```

### Response (201)

```json
{
  "created_at": "2026-01-01T00:00:00Z",
  "id": "string",
  "namespace": "string",
  "object_id": "string",
  "organization_id": "string",
  "relation": "string",
  "subject_id": "string",
  "subject_relation": "string",
  "subject_type": "string"
}
```

### Response (400)

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

### Response (404)

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