# Create unified model mapping

> Source: https://truto.one/docs/api-reference/admin/unified-model-mappings/create/

`POST /unified-model-resource-method`

Resource: **Unified Model Mappings**

## Request body

- **`unified_model_id`** _(string)_
  The base unified model to attach the mapping to. Must belong to one of your teams.
- **`resource_name`** _(string)_
  The unified resource name (e.g. `contacts`).
- **`integration_name`** _(string)_
  The integration slug (e.g. `apollo`).
- **`method_name`** _(string)_
  The unified method name (`list`, `get`, `create`, `update`, `delete`, or a custom method).
- **`config`** _(object)_
  The mapping configuration for this method.
  - **`static`** _(unknown)_
    Static value returned for this method without making an HTTP call.
  - **`resource`** _(string | array<object> | object)_
    Integration resource to call. May be a single name, an array of resource fragments, or a `{ expression, resources }` object for dynamic dispatch.
    _One of:_
    - **object**
      - **`expression`** _(string)_
      - **`resources`** _(array<string>)_
  - **`method`** _(string | array<object> | object)_
    Integration method to call.
    _One of:_
    - **object**
      - **`expression`** _(string)_
      - **`methods`** _(array<string>)_
  - **`base_url_mapping`** _(string)_
  - **`path_mapping`** _(string)_
  - **`error_mapping`** _(string)_
  - **`mapping_version`** _(number)_
  - **`response_mapping_method`** _(string)_
    Allowed: `array`, `item`
  - **`response_mapping`** _(string | object)_
    JSONata expression (string) or object-form mapping. The object form is keyed by field name with values that may be JSONata strings, nested objects, or `JsonSchemaObjectProperties`.
  - **`documentation_link`** _(string)_
  - **`related_resources`** _(string | array<object>)_
  - **`request_body_schema`** _(object)_
    Object-form (v2) request body schema; values are partial JSON Schema entries.
  - **`request_body_mapping`** _(string | object)_
  - **`query_mapping`** _(string | object)_
  - **`query_schema`** _(string | object)_
  - **`request_header_mapping`** _(string)_
  - **`response_header_mapping`** _(string)_
  - **`query`** _(object)_
    Static query params merged into the integration request.
  - **`body`** _(object)_
    Static body merged into the integration request.
  - **`before`** _(string | array<object>)_
  - **`after`** _(string | array<object>)_
  - **`is_partial_response`** _(boolean)_
  - **`is_partial_expression`** _(string)_
  - **`side_load`** _(object)_
  - **`file_upload`** _(string | object | array<object>)_
    _One of:_
    - **object**
      - **`file_upload`** _(string)_
        Allowed: `multipart`, `base64`, `upload`
      - **`config`** _(object)_
        Strategy-specific options (e.g. multipart field name, base64 wrapper key).

## Response body

- **`id`** _(string)_
  The ID of the resource-method mapping row.
- **`unified_model_id`** _(string)_
  The base unified model this mapping belongs to.
- **`resource_name`** _(string)_
  The unified resource this mapping serves (e.g. `contacts`).
- **`integration_name`** _(string)_
  The integration slug this mapping serves (e.g. `apollo`).
- **`method_name`** _(string)_
  The unified method this mapping serves (`list`, `get`, `create`, `update`, `delete`, or a custom method name).
- **`config`** _(object)_
  The mapping itself (JSONata expressions, resource/method routing, side loads, …).
  - **`static`** _(unknown)_
    Static value returned for this method without making an HTTP call.
  - **`resource`** _(string | array<object> | object)_
    Integration resource to call. May be a single name, an array of resource fragments, or a `{ expression, resources }` object for dynamic dispatch.
    _One of:_
    - **object**
      - **`expression`** _(string)_
      - **`resources`** _(array<string>)_
  - **`method`** _(string | array<object> | object)_
    Integration method to call.
    _One of:_
    - **object**
      - **`expression`** _(string)_
      - **`methods`** _(array<string>)_
  - **`base_url_mapping`** _(string)_
  - **`path_mapping`** _(string)_
  - **`error_mapping`** _(string)_
  - **`mapping_version`** _(number)_
  - **`response_mapping_method`** _(string)_
    Allowed: `array`, `item`
  - **`response_mapping`** _(string | object)_
    JSONata expression (string) or object-form mapping. The object form is keyed by field name with values that may be JSONata strings, nested objects, or `JsonSchemaObjectProperties`.
  - **`documentation_link`** _(string)_
  - **`related_resources`** _(string | array<object>)_
  - **`request_body_schema`** _(object)_
    Object-form (v2) request body schema; values are partial JSON Schema entries.
  - **`request_body_mapping`** _(string | object)_
  - **`query_mapping`** _(string | object)_
  - **`query_schema`** _(string | object)_
  - **`request_header_mapping`** _(string)_
  - **`response_header_mapping`** _(string)_
  - **`query`** _(object)_
    Static query params merged into the integration request.
  - **`body`** _(object)_
    Static body merged into the integration request.
  - **`before`** _(string | array<object>)_
  - **`after`** _(string | array<object>)_
  - **`is_partial_response`** _(boolean)_
  - **`is_partial_expression`** _(string)_
  - **`side_load`** _(object)_
  - **`file_upload`** _(string | object | array<object>)_
    _One of:_
    - **object**
      - **`file_upload`** _(string)_
        Allowed: `multipart`, `base64`, `upload`
      - **`config`** _(object)_
        Strategy-specific options (e.g. multipart field name, base64 wrapper key).
- **`version`** _(number)_
  Optimistic-concurrency version. Send the current value in a PATCH body; every write increments it.
- **`created_at`** _(string)_
- **`updated_at`** _(string)_

## Code examples

### curl

```bash
curl -X POST 'https://api.truto.one/unified-model-resource-method' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "unified_model_id": "7c5c8cc2-e68e-4af8-84d1-4ceea1489338",
  "resource_name": "contacts",
  "integration_name": "apollo",
  "method_name": "list",
  "config": {}
}'
```

### JavaScript

```javascript
const body = {
  "unified_model_id": "7c5c8cc2-e68e-4af8-84d1-4ceea1489338",
  "resource_name": "contacts",
  "integration_name": "apollo",
  "method_name": "list",
  "config": {}
};

const response = await fetch('https://api.truto.one/unified-model-resource-method', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/unified-model-resource-method"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "unified_model_id": "7c5c8cc2-e68e-4af8-84d1-4ceea1489338",
    "resource_name": "contacts",
    "integration_name": "apollo",
    "method_name": "list",
    "config": {}
}

response = requests.post(url, headers=headers, params=params, json=payload)
print(response.json())
```
