> ## 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.

# List Entities

> List and filter entities in your gu1 organization by type, risk score, status, country, or custom fields, with cursor pagination for large sets.

## Overview

Retrieves a list of entities with optional filtering by type, country, tax ID, or external ID. Returns up to 100 entities per request.

## Endpoint

```
GET http://api.gu1.ai/entities
```

## Authentication

Requires a valid API key in the Authorization header:

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

## Query Parameters

<ParamField query="type" type="string">
  Filter by entity type. Available values:

  * `person`
  * `company`
</ParamField>

<ParamField query="country" type="string">
  Filter by ISO 3166-1 alpha-2 country code (e.g., "US", "BR", "AR")
</ParamField>

<ParamField query="taxId" type="string">
  Filter by exact tax identification number
</ParamField>

<ParamField query="externalId" type="string">
  Filter by your external identifier
</ParamField>

## Response

<ResponseField name="entities" type="array">
  Array of entity objects, each containing:

  * `id` - gu1's internal ID
  * `externalId` - Your external ID
  * `organizationId` - Your organization ID
  * `type` - Entity type
  * `name` - Entity name
  * `taxId` - Tax ID
  * `countryCode` - Country code
  * `nationality` - Nationality (ISO 3166-1 alpha-2 at root, or `null`)
  * `riskScore` - Risk score (0-100)
  * `riskFactors` - Array of risk factors
  * `status` - Entity status
  * `kycVerified` - KYC verification status
  * `kycProvider` - KYC provider name
  * `kycData` - KYC verification data
  * `entityData` - Type-specific data
  * `attributes` - Custom attributes
  * `createdAt` - Creation timestamp
  * `updatedAt` - Last update timestamp
  * `deletedAt` - Deletion timestamp (null if active)
</ResponseField>

## Examples

### List All Entities

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "http://api.gu1.ai/entities" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('http://api.gu1.ai/entities', {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  });

  const data = await response.json();
  console.log(`Found ${data.entities.length} entities`);
  ```

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

  response = requests.get(
      'http://api.gu1.ai/entities',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY'
      }
  )

  data = response.json()
  print(f"Found {len(data['entities'])} entities")
  ```
</CodeGroup>

### Filter by Entity Type

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "http://api.gu1.ai/entities?type=company" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'http://api.gu1.ai/entities?type=company',
    {
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      }
    }
  );

  const data = await response.json();
  const companies = data.entities;
  console.log(`Found ${companies.length} companies`);
  ```

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

  response = requests.get(
      'http://api.gu1.ai/entities',
      headers={'Authorization': 'Bearer YOUR_API_KEY'},
      params={'type': 'company'}
  )

  companies = response.json()['entities']
  print(f"Found {len(companies)} companies")
  ```
</CodeGroup>

### Filter by Country

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "http://api.gu1.ai/entities?country=BR&type=company" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'http://api.gu1.ai/entities?country=BR&type=company',
    {
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      }
    }
  );

  const data = await response.json();
  console.log(`Found ${data.entities.length} Brazilian companies`);
  ```

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

  response = requests.get(
      'http://api.gu1.ai/entities',
      headers={'Authorization': 'Bearer YOUR_API_KEY'},
      params={
          'country': 'BR',
          'type': 'company'
      }
  )

  brazilian_companies = response.json()['entities']
  print(f"Found {len(brazilian_companies)} Brazilian companies")
  ```
</CodeGroup>

### Find by External ID

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "http://api.gu1.ai/entities?externalId=customer_12345" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'http://api.gu1.ai/entities?externalId=customer_12345',
    {
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      }
    }
  );

  const data = await response.json();
  const entity = data.entities[0]; // External IDs should be unique
  console.log('Found entity:', entity.name);
  ```

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

  response = requests.get(
      'http://api.gu1.ai/entities',
      headers={'Authorization': 'Bearer YOUR_API_KEY'},
      params={'externalId': 'customer_12345'}
  )

  entities = response.json()['entities']
  if entities:
      print(f"Found entity: {entities[0]['name']}")
  ```
</CodeGroup>

### Find by Tax ID

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "http://api.gu1.ai/entities?taxId=20-12345678-9" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'http://api.gu1.ai/entities?taxId=20-12345678-9',
    {
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      }
    }
  );

  const data = await response.json();
  if (data.entities.length > 0) {
    console.log('Entity found:', data.entities[0].name);
  }
  ```

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

  response = requests.get(
      'http://api.gu1.ai/entities',
      headers={'Authorization': 'Bearer YOUR_API_KEY'},
      params={'taxId': '20-12345678-9'}
  )

  entities = response.json()['entities']
  if entities:
      print(f"Entity found: {entities[0]['name']}")
  ```
</CodeGroup>

## Response Example

```json theme={null}
{
  "entities": [
    {
      "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",
      "nationality": "AR",
      "riskScore": 25,
      "riskFactors": [
        {
          "factor": "new_customer",
          "impact": 15,
          "description": "Customer registered within last 30 days"
        }
      ],
      "status": "active",
      "kycVerified": true,
      "kycProvider": "gueno_ai",
      "kycData": {
        "verificationDate": "2024-10-03T14:30:00Z",
        "overallStatus": "approved"
      },
      "entityData": {
        "person": {
          "firstName": "María",
          "lastName": "González",
          "dateOfBirth": "1985-03-15",
          "nationality": "AR",
          "occupation": "Software Engineer",
          "income": 85000
        }
      },
      "attributes": {
        "email": "maria.gonzalez@example.com",
        "phone": "+54 11 1234-5678"
      },
      "createdAt": "2024-10-03T14:30:00.000Z",
      "updatedAt": "2024-10-03T14:35:00.000Z",
      "deletedAt": null
    },
    {
      "id": "660e9511-f39c-52e5-b827-557766551111",
      "externalId": "company_789",
      "organizationId": "8e2f89ab-c216-4eb4-90eb-ca5d44499aaa",
      "type": "company",
      "name": "Tech Solutions S.A.",
      "taxId": "12.345.678/0001-90",
      "countryCode": "BR",
      "nationality": "BR",
      "riskScore": 35,
      "riskFactors": [
        {
          "factor": "new_business",
          "impact": 20,
          "description": "Company incorporated less than 2 years ago"
        }
      ],
      "status": "active",
      "kycVerified": true,
      "kycProvider": "gueno_ai",
      "kycData": {
        "verificationDate": "2024-10-03T15:00:00Z",
        "overallStatus": "approved"
      },
      "entityData": {
        "company": {
          "legalName": "Tech Solutions Sociedade Anônima",
          "tradeName": "Tech Solutions",
          "incorporationDate": "2020-06-15",
          "industry": "Software Development",
          "employeeCount": 50,
          "revenue": 5000000
        }
      },
      "attributes": {
        "website": "https://techsolutions.com.br",
        "registeredAddress": "Av. Paulista, 1000, São Paulo"
      },
      "createdAt": "2024-10-03T15:00:00.000Z",
      "updatedAt": "2024-10-03T15:05:00.000Z",
      "deletedAt": null
    }
  ]
}
```

## Use Cases

### High Risk Entity Monitoring

Query all entities and filter by risk score in your application:

```javascript theme={null}
const response = await fetch('http://api.gu1.ai/entities', {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});

const data = await response.json();
const highRiskEntities = data.entities.filter(e => e.riskScore > 70);

console.log(`Found ${highRiskEntities.length} high-risk entities requiring review`);
highRiskEntities.forEach(entity => {
  console.log(`- ${entity.name} (Risk: ${entity.riskScore})`);
});
```

### KYC Compliance Dashboard

Get all unverified entities for compliance dashboard:

```python theme={null}
import requests

response = requests.get(
    'http://api.gu1.ai/entities',
    headers={'Authorization': 'Bearer YOUR_API_KEY'},
    params={'type': 'person'}
)

entities = response.json()['entities']
unverified = [e for e in entities if not e['kycVerified']]

print(f"Unverified customers: {len(unverified)}")
for entity in unverified:
    print(f"- {entity['name']} ({entity['externalId']})")
```

### Transaction Volume Analysis

List all transactions for a specific period (combine with date filtering in your app):

```javascript theme={null}
const response = await fetch(
  'http://api.gu1.ai/entities?type=transaction',
  {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  }
);

const data = await response.json();
const transactions = data.entities;

const totalVolume = transactions.reduce((sum, txn) => {
  return sum + (txn.entityData?.transaction?.amount || 0);
}, 0);

console.log(`Total transaction volume: $${totalVolume.toLocaleString()}`);
console.log(`Transaction count: ${transactions.length}`);
```

### Country-Specific Compliance

Get all entities from a specific country for regulatory reporting:

```python theme={null}
import requests

response = requests.get(
    'http://api.gu1.ai/entities',
    headers={'Authorization': 'Bearer YOUR_API_KEY'},
    params={'country': 'US'}
)

us_entities = response.json()['entities']

# Separate by type
companies = [e for e in us_entities if e['type'] == 'company']
persons = [e for e in us_entities if e['type'] == 'person']

print(f"US Companies: {len(companies)}")
print(f"US Persons: {len(persons)}")
```

## Pagination

The API currently returns up to 100 entities per request. If you have more than 100 entities and need pagination:

1. **Use specific filters** to narrow down results (type, country, etc.)
2. **Implement client-side pagination** by storing the last `createdAt` timestamp
3. **Contact support** for enterprise pagination features

Example with timestamp-based pagination:

```javascript theme={null}
let allEntities = [];
let lastCreatedAt = null;

async function fetchAllEntities() {
  const response = await fetch('http://api.gu1.ai/entities?type=company', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  });

  const data = await response.json();

  // Filter by last timestamp if this is not the first batch
  const newEntities = lastCreatedAt
    ? data.entities.filter(e => new Date(e.createdAt) > new Date(lastCreatedAt))
    : data.entities;

  allEntities = allEntities.concat(newEntities);

  if (newEntities.length > 0) {
    lastCreatedAt = newEntities[newEntities.length - 1].createdAt;
  }

  return allEntities;
}
```

## Error Responses

### 401 Unauthorized

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

### 500 Internal Server Error

```json theme={null}
{
  "error": "Failed to search entities"
}
```

## Limits

* **Maximum results per request**: 100 entities
* **Query parameters**: Can be combined for advanced filtering
* **Rate limits**: Apply based on your plan tier

## Next Steps

* [Get Entity Details](/api-reference/entities/get) - Retrieve complete information for a specific entity
* [Create Entity](/api-reference/entities/create) - Add new entities to your organization
* [Update Entity](/api-reference/entities/update) - Modify entity attributes
* [Batch Operations](/en/api-reference/entities/upsert) - Process multiple entities at once
