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

# Update a person entity

> Update attributes and data for an existing person — for person entities in the gu1 KYC and risk analysis platform, with examples for update use cases.

## Overview

Updates an existing person's attributes and data. This endpoint automatically triggers a re-evaluation of the person's risk score and emits real-time update events.

## Endpoint

```
PATCH http://api.gu1.ai/entities/{id}
```

## Authentication

Requires a valid API key in the Authorization header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

<ParamField path="id" type="string" required>
  The gu1 ID of the person to update
</ParamField>

## Request Body

All fields are optional - only include the fields you want to update.

<ParamField body="name" type="string">
  Update the person's display name
</ParamField>

<Note>
  **External ID** cannot be updated with this endpoint. Use [Change external ID](/en/api-reference/person/change-external-id) (`POST /entities/change-external-id`) with a mandatory `reason` (min. 5 characters).
</Note>

<ParamField body="taxId" type="string">
  Update tax identification number
</ParamField>

<ParamField body="countryCode" type="string">
  Update ISO 3166-1 alpha-2 country code
</ParamField>

<ParamField body="attributes" type="object">
  Update custom attributes (merges with existing attributes)
</ParamField>

<ParamField body="entityData" type="object">
  Update person-specific data (merges with existing entityData)
</ParamField>

<ParamField body="status" type="string">
  Update person status. Available statuses:

  * `pending` - Initial state, awaiting processing
  * `under_review` - Under manual review
  * `active` - Approved and active
  * `suspended` - Temporarily suspended (requires `reason`)
  * `blocked` - Permanently blocked (requires `reason`)
  * `rejected` - Rejected during onboarding (requires `reason`)

  **Note**: Status changes to `suspended`, `blocked`, or `rejected` require a `reason` field for audit purposes.
</ParamField>

<ParamField body="reason" type="string">
  Required when changing status to `suspended`, `blocked`, or `rejected`. Provides audit trail for status changes.
</ParamField>

<ParamField body="riskMatrixId" type="string">
  UUID of the risk matrix to associate with this person. Updates which rules are used for risk evaluation.
</ParamField>

## Response

<ResponseField name="entity" type="object">
  The updated person object with all current values
</ResponseField>

<ResponseField name="evaluation" type="object">
  Newly created evaluation triggered by the update

  * `id` - Evaluation ID
  * `entityId` - Entity ID
  * `decision` - "PENDING" (awaiting processing)
  * `evaluationType` - "SYSTEM"
  * `reasons` - Array with "Re-evaluation triggered by attribute change"
</ResponseField>

<ResponseField name="previousEntity" type="object">
  The person state before the update (for audit/comparison)
</ResponseField>

<Note>
  This endpoint does **not** return `rulesResult` or `rulesExecutionSummary`. The rules engine is not executed on update; those fields are only returned by endpoints that run rules (create, create-automatic, enrich, refresh, analyze).
</Note>

## Behavior

When you update a person, the system automatically:

1. **Records the change** in the entity events log with a before/after snapshot
2. **Triggers re-evaluation** to recalculate risk score based on new data
3. **Emits real-time event** to notify connected clients of the update
4. **Maintains audit trail** for compliance and review purposes

## Examples

### Update Person Income and Occupation

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "entityData": {
        "person": {
          "income": 95000,
          "occupation": "Senior Software Engineer"
        }
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000',
    {
      method: 'PATCH',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        entityData: {
          person: {
            income: 95000,
            occupation: 'Senior Software Engineer'
          }
        }
      })
    }
  );

  const result = await response.json();
  console.log('Updated person:', result.entity);
  console.log('Re-evaluation triggered:', result.evaluation.id);
  ```

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

  response = requests.patch(
      'http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'entityData': {
              'person': {
                  'income': 95000,
                  'occupation': 'Senior Software Engineer'
              }
          }
      }
  )

  result = response.json()
  print(f"Updated person: {result['entity']['name']}")
  print(f"Re-evaluation ID: {result['evaluation']['id']}")
  ```
</CodeGroup>

### Update Contact Information

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "entityData": {
        "person": {
          "email": "new.email@example.com",
          "phone": "+54 11 9876-5432",
          "address": "Av. Libertador 2500, Buenos Aires"
        }
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000',
    {
      method: 'PATCH',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        entityData: {
          person: {
            email: 'new.email@example.com',
            phone: '+54 11 9876-5432',
            address: 'Av. Libertador 2500, Buenos Aires'
          }
        }
      })
    }
  );

  const result = await response.json();
  console.log('Contact information updated');
  ```

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

  response = requests.patch(
      'http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'entityData': {
              'person': {
                  'email': 'new.email@example.com',
                  'phone': '+54 11 9876-5432',
                  'address': 'Av. Libertador 2500, Buenos Aires'
              }
          }
      }
  )

  result = response.json()
  print("Contact information updated")
  ```
</CodeGroup>

### Update Custom Attributes Only

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "attributes": {
        "accountTier": "premium",
        "loyaltyPoints": 15000,
        "lastLoginDate": "2024-10-03T14:00:00Z"
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000',
    {
      method: 'PATCH',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        attributes: {
          accountTier: 'premium',
          loyaltyPoints: 15000,
          lastLoginDate: '2024-10-03T14:00:00Z'
        }
      })
    }
  );

  const result = await response.json();
  console.log('Attributes updated:', result.entity.attributes);
  ```

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

  response = requests.patch(
      'http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'attributes': {
              'accountTier': 'premium',
              'loyaltyPoints': 15000,
              'lastLoginDate': '2024-10-03T14:00:00Z'
          }
      }
  )

  result = response.json()
  print(f"Attributes updated: {result['entity']['attributes']}")
  ```
</CodeGroup>

### Update Person Status

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "status": "suspended",
      "reason": "Suspicious activity detected - pending investigation"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000',
    {
      method: 'PATCH',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        status: 'suspended',
        reason: 'Suspicious activity detected - pending investigation'
      })
    }
  );

  const result = await response.json();
  console.log('Status updated to:', result.entity.status);
  ```

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

  response = requests.patch(
      'http://api.gu1.ai/entities/550e8400-e29b-41d4-a716-446655440000',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'status': 'suspended',
          'reason': 'Suspicious activity detected - pending investigation'
      }
  )

  result = response.json()
  print(f"Status updated to: {result['entity']['status']}")
  ```
</CodeGroup>

## Response Example

```json theme={null}
{
  "entity": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "externalId": "customer_12345",
    "organizationId": "8e2f89ab-c216-4eb4-90eb-ca5d44499aaa",
    "type": "person",
    "name": "María González",
    "taxId": "20-12345678-9",
    "countryCode": "AR",
    "riskScore": 22,
    "riskFactors": [...],
    "status": "active",
    "kycVerified": true,
    "entityData": {
      "person": {
        "firstName": "María",
        "lastName": "González",
        "dateOfBirth": "1985-03-15",
        "nationality": "AR",
        "occupation": "Senior Software Engineer",
        "income": 95000
      }
    },
    "attributes": {
      "email": "maria.gonzalez@example.com",
      "phone": "+54 11 1234-5678",
      "accountTier": "premium"
    },
    "createdAt": "2024-10-03T14:30:00.000Z",
    "updatedAt": "2024-10-03T16:45:00.000Z",
    "deletedAt": null
  },
  "evaluation": {
    "id": "eval_new_123",
    "entityId": "550e8400-e29b-41d4-a716-446655440000",
    "decision": "PENDING",
    "evaluationType": "SYSTEM",
    "reasons": ["Re-evaluation triggered by attribute change"],
    "rules": [],
    "entitySnapshot": {...}
  },
  "previousEntity": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "entityData": {
      "person": {
        "occupation": "Software Engineer",
        "income": 85000
      }
    },
    "updatedAt": "2024-10-03T14:35:00.000Z"
  }
}
```

## Error Responses

### 404 Not Found

```json theme={null}
{
  "error": "Entity not found"
}
```

### 400 Bad Request - Invalid Data

```json theme={null}
{
  "error": "Validation failed",
  "details": ["Invalid country code format"]
}
```

### 400 Bad Request - Missing Reason for Status Change

```json theme={null}
{
  "error": "Changing status to 'suspended' requires a reason for audit purposes."
}
```

### 401 Unauthorized

```json theme={null}
{
  "error": "Invalid or missing API key"
}
```

### 500 Internal Server Error

```json theme={null}
{
  "error": "Failed to update entity"
}
```

## Use Cases

### Update After KYC Verification

```javascript theme={null}
// After completing KYC verification, update the person
const response = await fetch(`http://api.gu1.ai/entities/${personId}`, {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    attributes: {
      kycVerified: true,
      kycVerificationDate: new Date().toISOString(),
      kycProvider: 'manual_review'
    }
  })
});
```

### Progressive Profile Enrichment

```python theme={null}
# Enrich customer profile as more information becomes available
def update_customer_info(person_id, new_data):
    response = requests.patch(
        f'http://api.gu1.ai/entities/{person_id}',
        headers={
            'Authorization': 'Bearer YOUR_API_KEY',
            'Content-Type': 'application/json'
        },
        json={
            'entityData': {
                'person': new_data
            },
            'attributes': {
                'lastDataUpdate': datetime.now().isoformat(),
                'dataCompleteness': calculate_completeness(new_data)
            }
        }
    )
    return response.json()
```

## Best Practices

1. **Partial Updates**: Only send the fields you want to change - no need to send the entire person
2. **Monitor Re-evaluations**: Check the returned evaluation ID to track risk score recalculation
3. **Audit Trail**: Use the `previousEntity` in the response to maintain change history
4. **Real-time Sync**: Updates emit WebSocket events for real-time UI synchronization
5. **Idempotency**: Safe to retry - updates with same data will not create duplicate events

## Next Steps

* [Get Person](/en/api-reference/person/get) - View updated person details
* [List Persons](/en/api-reference/person/list) - Query persons with filters
* [Upsert Person](/en/api-reference/person/upsert) - Create or update in one operation
