Skip to main content
PATCH
http://api.gu1.ai
/
entities
/
{id}
Update
curl --request PATCH \
  --url http://api.gu1.ai/entities/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "externalId": "<string>",
  "taxId": "<string>",
  "countryCode": "<string>",
  "attributes": {},
  "entityData": {},
  "status": "<string>",
  "reason": "<string>",
  "riskMatrixId": "<string>"
}
'
{
  "entity": {},
  "evaluation": {},
  "previousEntity": {}
}

Overview

Updates an existing company’s attributes and data. This endpoint automatically triggers a re-evaluation of the company’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:
Authorization: Bearer YOUR_API_KEY

Path Parameters

id
string
required
The gu1 ID of the company to update

Request Body

All fields are optional - only include the fields you want to update.
name
string
Update the company’s display name
externalId
string
Update your external identifier
taxId
string
Update tax identification number
countryCode
string
Update ISO 3166-1 alpha-2 country code
attributes
object
Update custom attributes (merges with existing attributes)
entityData
object
Update company-specific data (merges with existing entityData)
status
string
Update company 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.
reason
string
Required when changing status to suspended, blocked, or rejected. Provides audit trail for status changes.
riskMatrixId
string
UUID of the risk matrix to associate with this company. Updates which rules are used for risk evaluation.

Response

entity
object
The updated company object with all current values
evaluation
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”
previousEntity
object
The company state before the update (for audit/comparison)

Behavior

When you update a company, 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 Company Income and Occupation

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": {
      "company": {
        "income": 95000,
        "occupation": "Senior Software Engineer"
      }
    }
  }'

Update Contact Information

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": {
      "company": {
        "email": "new.email@example.com",
        "phone": "+54 11 9876-5432",
        "address": "Av. Libertador 2500, Buenos Aires"
      }
    }
  }'

Update Custom Attributes Only

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"
    }
  }'

Update Company Status

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"
  }'

Response Example

{
  "entity": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "externalId": "business_12345",
    "organizationId": "8e2f89ab-c216-4eb4-90eb-ca5d44499aaa",
    "type": "company",
    "name": "María González",
    "taxId": "20-12345678-9",
    "countryCode": "AR",
    "riskScore": 22,
    "riskFactors": [...],
    "status": "active",
    "kycVerified": true,
    "entityData": {
      "company": {
        "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": {
      "company": {
        "occupation": "Software Engineer",
        "income": 85000
      }
    },
    "updatedAt": "2024-10-03T14:35:00.000Z"
  }
}

Error Responses

404 Not Found

{
  "error": "Entity not found"
}

400 Bad Request - Invalid Data

{
  "error": "Validation failed",
  "details": ["Invalid country code format"]
}

400 Bad Request - Missing Reason for Status Change

{
  "error": "Changing status to 'suspended' requires a reason for audit purposes."
}

401 Unauthorized

{
  "error": "Invalid or missing API key"
}

500 Internal Server Error

{
  "error": "Failed to update entity"
}

Use Cases

Update After KYB Verification

// After completing KYB verification, update the company
const response = await fetch(`http://api.gu1.ai/entities/${companyId}`, {
  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

# Enrich business profile as more information becomes available
def update_business_info(company_id, new_data):
    response = requests.patch(
        f'http://api.gu1.ai/entities/{company_id}',
        headers={
            'Authorization': 'Bearer YOUR_API_KEY',
            'Content-Type': 'application/json'
        },
        json={
            'entityData': {
                'company': 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 company
  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