# Identity Relations

The following endpoints are used to insert, retrieve, or delete entries representing identity relations from the database.&#x20;

{% tabs %}
{% tab title="IDENTITY RELATIONS ENDPOINTS" %}

```
GET /identity-relations/:id
POST /identity-relations/
DELETE /identity-relations/:id
```

{% endtab %}
{% endtabs %}

## The `identity-relation` object

The `identity-relation` object establishes the relation between a **company identity** and a person/company that is also a **company officer.**

A given `identity-relation` is identified by a unique, random `id` parameter.

{% tabs %}
{% tab title="IDENTITY RELATION OBJECT" %}

```javascript
{
    "id": "8b5e19fd-424f-4187-bb5f-a33a54bb38fa",
    "fromIdentity": "6030f456-bcf7-4309-8de2-5ef2871c07d0",
    "toIdentity": "a5b1857d-919f-4faa-859c-be665e5a6d9f",
    "label": "CEO",
    "createdAt": "2020-02-19T15:47:39.993Z",
    "updatedAt": "2020-02-19T15:47:39.993Z"
}
```

{% endtab %}
{% endtabs %}

## GET /identity-relations/:id

<mark style="color:blue;">`GET`</mark> `[ENVIRONMENT HOSTNAME]/identity-relations/:id`

This endpoint allows to retrieve a specific identity relation.

#### Path Parameters

| Name | Type   | Description                 |
| ---- | ------ | --------------------------- |
| id   | string | Id of the identity relation |

{% tabs %}
{% tab title="200 " %}

```
{
    "id": "8b5e19fd-424f-4187-bb5f-a33a54bb38fa",
    "fromIdentity": "6030f456-bcf7-4309-8de2-5ef2871c07d0",
    "toIdentity": "a5b1857d-919f-4faa-859c-be665e5a6d9f",
    "label": "CEO",
    "createdAt": "2020-02-19T15:47:39.993Z",
    "updatedAt": "2020-02-19T15:47:40.944Z"
}
```

{% endtab %}
{% endtabs %}

#### Example Call

{% tabs %}
{% tab title="Request" %}

```javascript
GET [ENVIRONMENT HOSTNAME]/identity-relations/8b5e19fd-424f-4187-bb5f-a33a54bb38fa

```

{% endtab %}

{% tab title="Curl" %}

```
curl -X POST \
  [ENVIRONMENT HOSTNAME]/identity-relations/8b5e19fd-424f-4187-bb5f-a33a54bb38fa \
  -H 'Content-Type: application/json' \
  -H 'apikey: {INSERT YOUR API KEY HERE}' \
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": "8b5e19fd-424f-4187-bb5f-a33a54bb38fa",
    "fromIdentity": "6030f456-bcf7-4309-8de2-5ef2871c07d0",
    "toIdentity": "a5b1857d-919f-4faa-859c-be665e5a6d9f",
    "label": "CEO",
    "createdAt": "2020-02-19T15:47:39.993Z",
    "updatedAt": "2020-02-19T15:47:39.993Z"
}
```

{% endtab %}
{% endtabs %}

## POST /identity-relations

<mark style="color:green;">`POST`</mark> `[ENVIRONMENT HOSTNAME]/identity-relations/`

This endpoint allows you to submit a new identity relation between two `identities` on the database. One of the `identities` must belong to an individual company officer, with the other belonging to the company in question.

#### Request Body

| Name              | Type   | Description                                                |
| ----------------- | ------ | ---------------------------------------------------------- |
| relations         | array  | Array of objects containing the relations information      |
| companyIdentityId | string | Id of the company to whom will be associated the relations |

{% tabs %}
{% tab title="200 Deposit successfully inserted in the database." %}

```javascript
{
    "id": "8b5e19fd-424f-4187-bb5f-a33a54bb38fa",
    "fromIdentity": "6030f456-bcf7-4309-8de2-5ef2871c07d0",
    "toIdentity": "a5b1857d-919f-4faa-859c-be665e5a6d9f",
    "label": "CEO",
    "createdAt": "2020-02-19T15:47:39.993Z",
    "updatedAt": "2020-02-19T15:47:39.993Z"
}
```

{% endtab %}
{% endtabs %}

#### Example Call

{% tabs %}
{% tab title="Request" %}

```javascript
POST [ENVIRONMENT HOSTNAME]/identity-relations/

```

{% endtab %}

{% tab title="Curl" %}

```
curl -X POST \
  [ENVIRONMENT HOSTNAME]/identity-relations \
  -H 'Content-Type: application/json' \
  -H 'apikey: {INSERT YOUR API KEY HERE}' \
  -d '{
  "companyIdentityId": "f51c7041-fdab-4f03-acaf-9c34df178724",
	"relations": [
		{
			"id": "f51c7041-fdab-4f03-acaf-9c34df178724",
			"label": "CEO"
		}
	] 
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": "8b5e19fd-424f-4187-bb5f-a33a54bb38fa",
    "fromIdentity": "6030f456-bcf7-4309-8de2-5ef2871c07d0",
    "toIdentity": "a5b1857d-919f-4faa-859c-be665e5a6d9f",
    "label": "CEO",
    "createdAt": "2020-02-19T15:47:39.993Z",
    "updatedAt": "2020-02-19T15:47:39.993Z"
}
```

{% endtab %}
{% endtabs %}

## DELETE /identity-relations/:id

<mark style="color:red;">`DELETE`</mark> `[ENVIRONMENT HOSTNAME]/identity-relations/:id`

This endpoint is used to delete a specific `identity-relation`.

#### Path Parameters

| Name | Type   | Description                               |
| ---- | ------ | ----------------------------------------- |
| id   | string | Id of the identity relation to be deleted |

{% tabs %}
{% tab title="200 " %}

```





```

{% endtab %}
{% endtabs %}

#### Example Call

{% tabs %}
{% tab title="Request" %}

```javascript
DELETE [ENVIRONMENT HOSTNAME]/identity-relations/edd56760-39e7-45cd-8ca6-21add09ac548

```

{% endtab %}

{% tab title="Curl" %}

```
curl -X DELETE \
  [ENVIRONMENT HOSTNAME]/identity-relations/edd56760-39e7-45cd-8ca6-21add09ac548 \
  -H 'apikey: {INSERT API KEY HERE}'
```

{% endtab %}
{% endtabs %}
