
# 사전 설정 속성 매핑 프로필 적용

`POST /v1/connections/{connection_id}/attribute-mappings:apply-profile` · 권한 `connections:write`

엔터프라이즈 연결의 고정 대상 규칙(이메일, 이름, 그룹 등)을 사전 설정 프로필의 규칙으로 교체합니다. SAML의 경우 `entra`, `okta`, `google`, `ping`, `jumpcloud`, `keycloak`, OIDC의 경우 `generic`을 사용합니다. 저장된 `user_metadata.<key>` 규칙은 유지됩니다. SAML 주체 속성은 변경되지 않습니다. 주체는 별도로 설정하며, 변경하면 연결된 ID가 고아 상태가 되기 때문입니다. [목록 교체](put.md)와 마찬가지로 `If-Match`가 필요합니다. 이미 적용된 프로필을 다시 적용하면 아무것도 기록되지 않습니다. 쓰기 작업은 프로필 이름과 함께 `connection.attribute_mappings_replaced`로 감사 기록됩니다.

## 요청

| 필드 | 유형 | 필수 | 설명 |
|---|---|---|---|
| `connection_id` | path | yes | 엔터프라이즈 연결 ID(`conn_…`). |
| `If-Match` | header | yes | 마지막 조회의 `ETag`. 없으면 `428`, 오래된 값이면 `412`. |
| `profile` | string | yes | `entra`, `okta`, `google`, `ping`, `jumpcloud`, `keycloak`(SAML) 또는 `generic`(OIDC). |

## 응답

`200 OK`와 함께 저장된 목록([속성 매핑 조회](get.md) 참조)과 새 `ETag`를 반환합니다.

## 오류

| HTTP | code | 발생 시점 |
|---|---|---|
| 404 | `not_found` | 이 환경에 연결이 없거나 엔터프라이즈 연결이 아닙니다. |
| 409 | `conflict` | 연결의 프로토콜에는 속성 매핑이 없습니다(LDAP). |
| 412 | `precondition_failed` | `If-Match`가 현재 버전과 일치하지 않거나 목록이 동시에 변경되었습니다. |
| 422 | `validation_failed` | `profile`이 없거나, 알 수 없거나, 연결 프로토콜의 사전 설정이 아닙니다(`/profile`). 또는 유지되는 `user_metadata` 규칙이 다른 NameFormat으로 프로필 속성을 읽습니다(`/profile`, `conflicts_with_stored_mappings`). |
| 428 | `precondition_required` | `If-Match` 헤더가 없습니다. |
| 401 | `unauthenticated` | 자격 증명이 없거나, 잘못되었거나, 취소되었습니다. |
| 403 | `insufficient_permissions` | 자격 증명에 필요한 권한이 없습니다. |
| 429 | `rate_limited` | 호출 한도를 초과했습니다. `Retry-After` 기간 이후에 다시 시도하십시오. |
| 503 | `service_unavailable` | 종속 구성 요소를 일시적으로 사용할 수 없습니다. `Retry-After` 기간 이후에 다시 시도하십시오. |

## 예제

```bash
curl -X POST "https://api.eu.keenauth.com/v1/connections/conn_01j9xp6q0r1s5t7v9w1x3y5z7b/attribute-mappings:apply-profile" \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -H 'If-Match: "6f1c…"' \
  -d '{"profile":"entra"}'
```

```bash
keenauth connections attribute-mappings apply-profile conn_01j9xp6q0r1s5t7v9w1x3y5z7b --profile entra --if-match '"6f1c…"'
```
