> For the complete documentation index, see [llms.txt](https://developer.collibra.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.collibra.com/tutorials/create-data-with-collibra-rest-api.md).

# Create data with Collibra REST API

In this tutorial you create a community, a domain, some assets and definitions in Collibra Platform using the Collibra REST API.

```bash
curl -X POST \
  https://<your_collibra_url>/rest/2.0/communities \
  -H 'Content-Type: application/json' \
  -d '{
	"name": "Finance",
	"description": "The part of the organization that manages its money."
}'
```

You start by signing in and creating a root community. You create a domain within the community and add an asset and a definition for that asset. You then learn to perform bulk operations, creating multiple sub-communities and domains.

The goal is to have a structure such as the one below in your Collibra Platform:

<img src="/files/qNdVtryDMe0H2iwKuIwb" alt="" width="50%">

## Prerequisites

* Access to Collibra.
* Postman or an alternative HTTP API client.

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Some references might be specific to the Postman application.</p></div>

{% hint style="info" %}
For more information on how to install Postman and authenticate, see the [Collibra REST API authentication](/tutorials/collibra-rest-api-authentication.md) tutorial.
{% endhint %}

## The API documentation

The API references are part of your Collibra Platform environment. You need to be logged in to access them.

To access the API documentation:

| User access   | API documentation                                                                                                                                     |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| Sysadmin role | In the top-right corner of any Collibra page, click <img src="/files/r9yMxwz9IFK3FAqFh8cK" alt="" data-size="line"> and select **API documentation**. |
| All roles     | In a browser, go to https\://\<your\_collibra\_url>/docs/index.html.                                                                                  |

You can also consult the API documentation on the [Collibra Developer Portal](/api/references/data-governance.md).

## Authenticate

Use a [JSON Web Token](/tutorials/collibra-rest-api-authentication-with-json-web-token.md) or basic authentication for your API calls. For basic authentication, include a header key `Authorization` with the value `Basic <Base64_encoded_values>`, where the encoded values are `<username>:<password>`.

```bash
curl -H 'Authorization: Basic QWRtaW46YWRtaW4='
```

## Create a community

In this section, you create a root community named **Finance** and give it a meaningful description. A root community in one that does not have a parent community.

```bash
curl -X POST \
  https://<your_collibra_url>/rest/2.0/communities \
  -H 'Content-Type: application/json' \
  -d '{
	"name": "Finance",
	"description": "The part of the organization that manages its money."
}'
```

To create a community, use the `POST` method and the `/communities` endpoint of the **Communities** resource.

```
POST https://<your_collibra_url>/rest/2.0/communities
```

To successfully create a root community, you must provide the community name in a JSON body. It is not mandatory, but good practice to have meaningful descriptions for the Collibra Platform resources you create.

<img src="/files/wsUlBMCB4ijNAtgbmgxT" alt="" width="50%">

The parameters used to create the root community are:

| Parameter   | Mandatory | Type   | Description                                     |
| ----------- | --------- | ------ | ----------------------------------------------- |
| description | No        | String | Describes the community.                        |
| name        | Yes       | String | Sets the name of the community. Must be unique. |

The response contains information about the newly created community, including the Universally Unique Identifier (UUID), which you use in the next steps to identify the **Finance** community.

<img src="/files/MQAxNcYCADvQ02V5EOF4" alt="" width="50%">

## Create a domain

Domains are logical groupings of assets. They belong to communities and have different domain types. In this section, you create a **Glossary** domain named **Finance Gloassary**, which belongs to the **Finance** community.

```bash
curl -X POST \
  https://<your_collibra_url>/rest/2.0/domains \
  -H 'Content-Type: application/json' \
  -d '{
	"name": "Finance Glossary",
	"description": "A collection of finance related assets.",
	"communityId": "<Finance_community_id>",
	"typeId": "00000000-0000-0000-0000-000000010001"
}'
```

To create a domain, use the `POST` method and the `/domains` endpoint of the **Domains** resource.

```
POST https://<your_collibra_url>/rest/2.0/domains
```

To successfully create a domain, you must provide the domain name, the domain type ID and the community ID the domain belongs to.

For the **Finance Glossary** domain, use the community ID that you received after creating the **Finance** community and *00000000-0000-0000-0000-000000010001* as the **typeId**. This is the out-of-the-box UUID of the **Glossary** domain type.

<img src="/files/qyVfNXRw1aKz6cpNrucG" alt="" width="50%">

The parameters used to create the domain are:

| Parameter   | Mandatory | Type   | Description                                                            |
| ----------- | --------- | ------ | ---------------------------------------------------------------------- |
| communityId | Yes       | UUID   | Sets the community the domain belongs to. The community must exist.    |
| description | No        | String | Describes the domain.                                                  |
| name        | Yes       | String | Sets the name of the domain. Must be unique within the same community. |
| typeId      | Yes       | UUID   | Sets the domain type.                                                  |

The response contains information about the newly created domain, including the Universally Unique Identifier (UUID), which you use in the next steps to identify the **Finance Glossary** domain.

<img src="/files/28LtwEif45VoKBTLt8rL" alt="" width="50%">

## Create an asset

Now that you have created a glossary, you can start adding assets to it. In this section you add a business term in the **Finance Glossary** domain.

```bash
curl -X POST \
  https://<your_collibra_url>/rest/2.0/assets \
  -H 'Content-Type: application/json' \
  -d '{
	"name": "Customer Lifetime Value",
	"typeId": "00000000-0000-0000-0000-000000011001",
	"domainId": "<Finance_Glossary_domain_id>"
}'
```

To create an asset, use the `POST` method and the `/assets` endpoint of the **Assets** resource.

```
POST https://<your_collibra_url>/rest/2.0/assets
```

To successfully create an asset, you must provide the asset name, the asset type ID and the domain ID the asset belongs to.

For the **Customer Lifetime Value** asset, use the domain ID that you received after creating the **Finance Glossary** domain and *00000000-0000-0000-0000-000000011001* as the **typeId**. This is the out-of-the-box UUID of the **Business Term** asset type.

<img src="/files/m28H0JuZXVKnHRNGsJ8O" alt="" width="50%">

The parameters used to create the asset are:

| Parameter | Mandatory | Type   | Description                                                        |
| --------- | --------- | ------ | ------------------------------------------------------------------ |
| domainId  | Yes       | UUID   | Sets the domain the asset belongs to. The domain must exist.       |
| name      | Yes       | String | Sets the name of the asset. Must be unique within the same domain. |
| typeId    | Yes       | UUID   | Sets the asset type.                                               |

The response contains information about the newly created asset, including the Universally Unique Identifier (UUID), which you will use in the next steps to identify the **Customer Lifetime Value** asset.

<img src="/files/HfXrs2UvqKuTao6uSgMT" alt="" width="50%">

## Create a definition

The definition of an asset is just one of its attributes. In this section you add a definition to the **Customer Lifetime Value** asset.

```bash
curl -X POST \
  https://<your_collibra_url>/rest/2.0/attributes \
  -H 'Content-Type: application/json' \
  -d '{
	"assetId": "<Customer_Lifetime_Value_asset_id>",
	"typeId": "00000000-0000-0000-0000-000000000202",
	"value": "The monetary value of a customer relationship."
}'
```

To create a definition, use the `POST` method and the `/attributes` endpoint of the **Attributes** resource.

```
POST https://<your_collibra_url>/rest/2.0/attributes
```

To successfully create a definition, you must provide the definition, the attribute type ID, and the asset ID the definition is for.

For the **Customer Lifetime Value** definition, use the asset ID that you received after creating the **Customer Lifetime Value** asset and *00000000-0000-0000-0000-000000000202* as the **typeId**. This is the out-of-the-box UUID of the **Definition** attribute type.

<img src="/files/2OKNJlnE26wFsig7rPyp" alt="" width="50%">

The parameters used to create the definition are:

| Parameter | Mandatory | Type   | Description                                                                    |
| --------- | --------- | ------ | ------------------------------------------------------------------------------ |
| assetyId  | Yes       | UUID   | Identifies the asset that the attribute belongs to. The asset must exist.      |
| typeId    | Yes       | UUID   | Sets the attribute type.                                                       |
| value     | Yes       | Object | Sets the value of the attribute. The expected type for a definition is string. |

The response contains information about the newly created definition.

<img src="/files/CpNVt2LbskmyVdNPz6ld" alt="" width="50%">

## Create multiple resources

To create multiple resources with a single call, use the `POST` method and the `/bulk` endpoint of the resource you need to create. Provide the required parameters in a JSON array.

Let's add the missing pieces to the Finance community by creating a series of sub-communities and a couple of domains.

To create the **Accounting**, **Accounts Payable**, **Accounts Receivable**, **Forecasting** and **Payroll** sub-communities, you must provide their names and the ID of the parent community. You know the ID of the parent community from the response you received after creating the **Finance** community.

```bash
curl -X POST \
  https://<your_collibra_url>/rest/2.0/communities/bulk \
  -H 'Content-Type: application/json' \
  -d '[
	{
		"name": "Accounting",
		"parentId": "<Finance_community_id>"
	},
	{
		"name": "Accounts Payable",
		"parentId": "<Finance_community_id>"
	},
	{
		"name": "Accounts Receivable",
		"parentId": "<Finance_community_id>"
	},
	{
		"name": "Forecasting",
		"parentId": "<Finance_community_id>"
	},
	{
		"name": "Payroll",
		"parentId": "<Finance_community_id>"
	}
]'
```

<img src="/files/3IjAfkHN7ZQIrYnaulQI" alt="" width="50%">

The response contains information about the newly created communities, including the Universally Unique Identifier (UUID) for each of them.

<img src="/files/5zw8g5n02qnxNKnxrXKR" alt="" width="50%">

To create the **Accounting Policies** and **Forecasting Policies** domains, you must provide their names, the community IDs the domains belong to and the domain type IDs. Use the community IDs that you received after creating the sub-communities and *00000000-0000-0000-0000-000000030013* as the **typeId**. This is the out-of-the-box UUID of the **Policy** domain type.

```bash
curl -X POST \
  https://<your_collibra_url>/rest/2.0/domains/bulk \
  -H 'Content-Type: application/json' \
  -d '[
	{
		"name": "Accounting Policies",
		"typeId": "00000000-0000-0000-0000-000000030013",
		"communityId": "<Accounting_community_id>"
	},
	{
		"name": "Forecasting Policies",
		"typeId": "00000000-0000-0000-0000-000000030013",
		"communityId": "<Forecasting_community_id>"
	}
]'
```

<img src="/files/M4FLTImeJ1Sz4yqSOSwp" alt="" width="50%">

The response contains information about the newly created domains.

<img src="/files/EJNyS6GZRHavXYN3Abso" alt="" width="50%">

## Response codes

Common response codes when creating resources are:

| Code | Meaning                                                                 |
| ---- | ----------------------------------------------------------------------- |
| 201  | The resource has been created.                                          |
| 400  | Bad request. The body of the response contains details about the error. |
| 401  | The current user is not authenticated.                                  |

## Summary

By following this tutorial you have used the Collibra REST API to:

* Create a root community with a meaningful description.
* Add sub-communities to a root community.
* Create domains within communities.
* Add assets to domains.
* Add definitions to assets.
* Get the UUID of newly created Collibra resources from the response of an API call.

## Next steps

The next tutorial guides you through an example of how to retrieve data from Collibra Platform and add an asset via the Collibra REST API.

## Additional resources

* Consult the REST API documentation provided with your version of Collibra Platform.
* Read the Collibra [API documentation](/api/references/data-governance.md).
