# Add a relationship type

`POST /api/v1/relationship-types`

Add a kind of link the product did not supply, when the ten it ships with fall short.

Say whether both people read the same word or a different one on each side. A symmetric type, Friend for instance, takes one role and reads with it from both sides, so role_b may be left out. A directed type, Godparent / Godchild for instance, takes a role for each side, and the first person always carries role_a.

The type goes at the end of the category you file it under, and is offered straight away unless you say otherwise. It never acquires a system_behavior: the family tree and romantic history read the types the product supplied, whatever you call yours.

A name another type of your account already carries is refused, so the picker never offers the same word twice.

## Body parameters

- `relationship_category_id` (uuid, required): The category to file the type under. A category belonging to somebody else is refused.
- `name` (string, required): What the link is called. Up to 255 characters. Markup and surrounding blank space are stripped, and a name left with nothing in it is refused.
- `role_a` (string, required): How the first person relates to the second. Up to 255 characters.
- `role_b` (string, optional): How the second person relates to the first. Required when is_symmetric is false; ignored and set to role_a when it is true.
- `is_symmetric` (boolean, optional): Whether both people read the same word. Defaults to true.
- `is_active` (boolean, optional): Whether the type is offered for a new relationship. Defaults to true.

## Returns

The relationship type object that was added.

- `data` (object): The type.
- `data.type` (string): Always relationship_type. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.
- `data.id` (string): The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.
- `data.attributes` (object): Everything the record holds.
- `data.attributes.relationship_category_id` (uuid): The category the type is filed under. It groups the list and the picker and has no other effect: moving a type between categories never changes what the product does with it.
- `data.attributes.name` (string): What the link is called: Parent / Child, Sibling, Colleague. A type the product supplied reads in the language you ask for, until somebody rewrites it, after which their words stand in every language. Up to 255 characters, reduced to plain text.
- `data.attributes.role_a` (string): How the first person relates to the second. In a Parent / Child link the first person is the Parent. It is read in the same way the name is.
- `data.attributes.role_b` (string): How the second person relates to the first. A symmetric type carries the same word here as in role_a, and rewording the two never swaps the people over: the first role stays on the first person of every relationship already written.
- `data.attributes.is_symmetric` (boolean): Whether both people read the same word, as Friend does, rather than a different one on each side, as Parent / Child does. It is frozen once the product supplied the type or a relationship uses it, because turning it round would rewrite what people wrote years ago.
- `data.attributes.system_behavior` (string): Either genealogy_parentage, which feeds the family tree, or romantic, which feeds romantic history, or null. It is attached to the supplied type itself rather than to its name or its category, so renaming one or moving it elsewhere changes the words on screen and nothing more. A type you invent never acquires one.
- `data.attributes.position` (integer): Where the type sits inside its category, counting from 1. Retired types are numbered along with the rest.
- `data.attributes.is_system` (boolean): Whether the product supplied the type with the account. A supplied type may be reworded, moved and retired, never deleted, and its direction never changes.
- `data.attributes.is_active` (boolean): Whether the type is offered when a new relationship is written. False stops it being chosen again and touches nothing already written.
- `data.attributes.relationship_count` (integer): How many relationships are written with this type, across every vault of your account. A relationship in the bin is not counted. It decides both whether the type may be deleted and whether its direction may still move.
- `data.attributes.created_at` (timestamp): When the type was added, as a count of seconds since 1970 rather than a written date.
- `data.attributes.updated_at` (timestamp): When it last changed, as a count of seconds. Equal to created_at until it first changes.
- `data.links` (object): Where to find this record.
- `data.links.self` (string): The absolute address this record is read from.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://my.monicahq.com/api/v1/relationship-types \
  -X POST \
  -H "Authorization: Bearer $MONICA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "relationship_category_id": "7d1f4a83-2c06-4e59-9b27-8f3a5d0e6c14",
      "name": "Godparent / Godchild",
      "role_a": "Godparent",
      "role_b": "Godchild",
      "is_symmetric": "false",
      "is_active": "true"
  }'
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/relationship-types', {
  method: 'POST',
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    relationship_category_id: '7d1f4a83-2c06-4e59-9b27-8f3a5d0e6c14',
    name: 'Godparent / Godchild',
    role_a: 'Godparent',
    role_b: 'Godchild',
    is_symmetric: 'false',
    is_active: 'true',
  }),
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->post('https://my.monicahq.com/api/v1/relationship-types', [
    'relationship_category_id' => '7d1f4a83-2c06-4e59-9b27-8f3a5d0e6c14',
    'name' => 'Godparent / Godchild',
    'role_a' => 'Godparent',
    'role_b' => 'Godchild',
    'is_symmetric' => 'false',
    'is_active' => 'true',
]);
```

## Response

`201`

```json
{
    "data": {
        "type": "relationship_type",
        "id": "c60d8f14-9a27-4b53-8e01-2d7f5c3a6b48",
        "attributes": {
            "relationship_category_id": "7d1f4a83-2c06-4e59-9b27-8f3a5d0e6c14",
            "name": "Godparent / Godchild",
            "role_a": "Godparent",
            "role_b": "Godchild",
            "is_symmetric": false,
            "system_behavior": null,
            "position": 6,
            "is_system": false,
            "is_active": true,
            "relationship_count": 0,
            "created_at": 1756339200,
            "updated_at": 1756425600
        },
        "links": {
            "self": "https://my.monicahq.com/api/v1/relationship-types/c60d8f14-9a27-4b53-8e01-2d7f5c3a6b48"
        }
    }
}
```
