> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Check Mapping

> Which required template columns a draft mapping still lacks

[← Imports](https://code.dcycle.io/api-reference/imports/overview.md)

Ask which template columns a mapping still needs before the mapping step can go on, without saving anything and without reading the file's rows. Call it whenever the person changes the mapping or a fixed value, and let them continue once `unmapped_required` is empty.

It is the same answer [Suggest Mapping](https://code.dcycle.io/api-reference/imports/suggest-mapping.md) and [Confirm Mapping](https://code.dcycle.io/api-reference/imports/confirm-mapping.md) return in `unmapped_required`, and the same rule automatic imports stop on, so a client never keeps its own copy of it.

A column is listed when:

* the template requires it (`requirement.must_assign` in [Get a template](https://code.dcycle.io/api-reference/imports/get-template.md)) and it has no source column, no fixed value and no template default. A default taken from another column (`{"from_column": "start_date"}`) counts while that column has a value, as far down the chain as it goes. A value the page the file was uploaded from fills or fixes counts too.
* another mapped column asks for it (`requirement.must_assign_with`): a wastes file that maps each row's company needs a facility column. A fixed value does not answer it, since the rows name it one by one.

## Request

### Headers

**x-api-key** `string` *required*

Your API key for authentication

**Example:** `sk_live_1234567890abcdef`

**x-organization-id** `string` *required*

Your organization UUID

**Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`

### Path Parameters

**import\_id** `string` *required*

UUID of the import session

**Example:** `"11111111-1111-1111-1111-111111111111"`

### Body Parameters

**mapping** `object` *required*

The draft mapping, `{target_column: source_column | null}`. Keys that are not template columns are ignored, and source columns are not checked against the file (the confirm does that).

**Example:** `{"check_in_date": "Check in", "country": null}`

**constant\_values** `object`

The draft fixed values, `{target_column: value}`. Blank values do not count.

**Example:** `{"country": "ES"}`

## Response

**unmapped\_required** `array[string]`

The template columns the mapping still needs, in the template's order: first the required ones with nothing, then those another mapped column asks for. Empty when the mapping step can go on.

## Example

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dcycle.io/v2/imports/11111111-1111-1111-1111-111111111111/mapping/check" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "mapping": {"check_in_date": "Check in"},
    "constant_values": {"country": "ES"}
  }'
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import requests
import os

headers = {
    "x-api-key": os.getenv("DCYCLE_API_KEY"),
    "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
    "Content-Type": "application/json",
}

import_id = "11111111-1111-1111-1111-111111111111"

response = requests.post(
    f"https://api.dcycle.io/v2/imports/{import_id}/mapping/check",
    headers=headers,
    json={"mapping": {"check_in_date": "Check in"}, "constant_values": {"country": "ES"}},
)

print(f"Still needed: {response.json()['unmapped_required']}")
```

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "unmapped_required": ["rooms(optional)"]
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 404 Not Found

**Cause:** The import session does not exist or belongs to another organization. Both cases return the same response.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"code": "NOT_FOUND", "detail": "ImportSessionModel with id='1b2c3d4e-5f60-7182-93a4-b5c6d7e8f901' not found"}
```

## Related Endpoints

> [card] [Suggest Mapping](https://code.dcycle.io/api-reference/imports/suggest-mapping.md)
>
> Suggested mapping, with what it still lacks

> [card] [Confirm Mapping](https://code.dcycle.io/api-reference/imports/confirm-mapping.md)
>
> Persist the chosen mapping


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.