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

# 프로필 수정

<Info>
  **v1 Enterprise API (Coming Soon)**

  이 엔드포인트는 Enterprise 버전에서 제공될 예정입니다.
  현재는 [v0 API](/api-reference/v0/overview)를 사용하세요.
</Info>

기존 프로필의 정보를 수정합니다. 수정된 민감한 정보는 AES-256-GCM으로 암호화되어 저장됩니다.

<Note>
  생년월일이 변경되면 사주팔자가 자동으로 재계산됩니다.
</Note>

***

## Path 파라미터

<ParamField path="id" type="string" required>
  수정할 프로필의 ID입니다. `prf_` 접두사로 시작합니다.
</ParamField>

***

## Request Body 파라미터

<ParamField body="name" type="string">
  사용자 이름입니다. 최대 길이는 20자입니다. 이 값은 암호화되어 저장됩니다.
</ParamField>

<ParamField body="birth_year" type="integer">
  출생 연도입니다. 1900에서 2100 사이의 값이어야 합니다.
</ParamField>

<ParamField body="birth_month" type="integer">
  출생 월입니다. 1에서 12 사이의 값이어야 합니다.
</ParamField>

<ParamField body="birth_day" type="integer">
  출생 일입니다. 1에서 31 사이의 값이어야 합니다.
</ParamField>

<ParamField body="birth_hour" type="integer">
  출생 시입니다. 0에서 23 사이의 값이어야 합니다. `null`로 설정하면 시주 정보가 삭제됩니다.
</ParamField>

<ParamField body="gender" type="string">
  성별입니다. `male` 또는 `female` 중 하나입니다.
</ParamField>

***

## Response

### 성공

프로필 수정에 성공하면 수정된 Profile 객체가 반환됩니다. 민감한 정보는 마스킹되어 반환됩니다.

### 실패

| 상태 코드 | 에러 타입                  | 설명              |
| ----- | ---------------------- | --------------- |
| 400   | `validation_error`     | 요청 데이터가 유효하지 않음 |
| 401   | `authentication_error` | API 키가 유효하지 않음  |
| 404   | `not_found`            | 프로필을 찾을 수 없음    |
| 429   | `rate_limited`         | 요청 한도 초과        |

***

## 요청 예시

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT https://api.sajuapi.dev/v1/profiles/prf_abc123def456 \
    -H "X-API-Key: bs_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "김영희",
      "birth_hour": 10
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.sajuapi.dev/v1/profiles/prf_abc123def456',
    {
      method: 'PUT',
      headers: {
        'X-API-Key': 'bs_live_xxx',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: '김영희',
        birth_hour: 10
      })
    }
  );

  const profile = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.put(
      'https://api.sajuapi.dev/v1/profiles/prf_abc123def456',
      headers={'X-API-Key': 'bs_live_xxx'},
      json={
          'name': '김영희',
          'birth_hour': 10
      }
  )

  profile = response.json()
  ```
</CodeGroup>

***

## 응답 예시

```json theme={null}
{
  "id": "prf_abc123def456",
  "external_id": "user_12345",
  "name": "김**",
  "birth_year": "19**",
  "gender": "male",
  "day_master": "병화",
  "day_master_element": "fire",
  "weakest_element": "water",
  "created_at": "2025-01-15T09:00:00Z",
  "updated_at": "2025-01-16T14:30:00Z"
}
```

***

## 부분 업데이트

요청 본문에 포함된 필드만 업데이트됩니다. 포함되지 않은 필드는 기존 값을 유지합니다.

```javascript theme={null}
// 이름만 변경
await fetch('/v1/profiles/prf_abc123def456', {
  method: 'PUT',
  headers: {
    'X-API-Key': 'bs_live_xxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ name: '새이름' })
});

// 시주 정보 삭제
await fetch('/v1/profiles/prf_abc123def456', {
  method: 'PUT',
  headers: {
    'X-API-Key': 'bs_live_xxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ birth_hour: null })
});
```
