# Process Data Model API

The Process Data Model API allows you to completely or partially reload your data models, ensuring that the latest data from your source system is available. This is a RESTful API that allows you run GET requests to retrieve information and POST requests to trigger the data model loads.

## Required parameters - Data pool and data model IDs

To use this API, you need both the data pool ID and data model ID, both of which can be found from your URL when viewing that area of the Celonis Platform.

### Data pool ID

Your data pool ID will be in the following format:


```
[https://TEAMNAME.REALM.celonis.cloud/integration/ui/pools/DATA_POOL_ID/](null)
```

### Data model ID

Your data model ID will be in the following format:


```
[https://TEAMNAME.REALM.celonis.cloud/integration/ui/pools/DATAPOOLID/data-configuration/process-data-models/DATA_MODEL_ID?tab=data-model](null)
```

## Authentication methods

To connect to and use the process data model API, you have the following authentication methods available:

- **OAuth client (recommended):** Create an OAuth client by clicking **Admin & Settings** and selecting **Applications**.
The OAuth client needs to have the scope `integration.data-pools` to use all of the APIs. In addition, the client needs to be granted **Edit** permissions on the corresponding data pool.
- **Application key**: Create an application key in **Admin & Settings** as a team admin. The application key requires **Edit** permissions on the corresponding data pool. For more information, see [Application Keys](https://docs.celonis.com/en/application-keys.html).
- **API key**: Using API keys is an effective and secure method of communicating between your and external systems, such as an identity provider. They are created within an individual user profile in your Celonis Platform, with the key’s permissions mirroring those of the user who created them. For security reasons, an API key is only displayed at the time it is created. Therefore you must create a new key if you no longer have access to any you create. For more information, see [API Keys](https://docs.celonis.com/en/creating-api-keys.html).


## Complete data model reload

Using a RESTful API, you can trigger a complete data model load (complete load) with this POST request:


```
POST /integration/api/v1/data-pools/{poolId}/data-models/{dataModelId}/load
```

## Partial data model reload

If you only want to update a subset of tables, you can also perform a partial reload. This does a complete reload of the specified tables only and a reload from cache for the rest.

To perfrom a partial reload you need to query the table list first:


```
GET /integration/api/v1/data-pools/{poolId}/data-models/{dataModelId}/tables
```

This will return the following response parameters:

- **id**: The ID of the table configuration in the data model (required for the partial data model reload).
- **dataModelId**: The ID of the data model.
- **dataSourceId**: The ID of the data connection if applicable.
- **name**: The name of the table.
- **alias**: The alias of the table.
- **aliasOrName**: The alias if defined or the name of the table.


Note the IDs of the table to which you would like to sync and then execute the following:


```
POST /integration/api/v1/data-pools/{poolId}/data-models/{dataModelId}/load/partial-sync
```

In the body of this request, you will need to specify the tables as a list of IDs:


```
["table_id1", "table_id2"]
```

## Last load information

In order to query information about the last data model load, use the following endpoint:


```
GET /integration/api/v1/data-pools/{poolId}/data-models/{dataModelId}/last-load
```

## Python example

The following is an example of how this API can be used in Python:


```
`import requests` \
 \
`realm = 'xyz' # e.g. eu-1, us-1, eu-2` \
`tenant = 'xyz' # the name of your team (your subdomain)` \
`api_key = 'xyz' # the API key` \
`pool_id = 'xyz' # the Data Pool ID (see above)` \
`data_model_id = 'xyz' # the Data Model ID (see above)` \
 \
`url = "https://{}.{}.celonis.cloud/integration/api/v1/data-pools/{}/data-models/{}/load".format(tenant, realm, pool_id, data_model_id)` \
 \
`requests.post(url, headers={'authorization': "Bearer {}".format(api_key)})`
```