# Credit Holmes

CreditHolmes are used to request the credit analysis of a tax ID.

The analysis retrieves credit information from official sources for a given CPF or CNPJ, helping you evaluate the creditworthiness of a borrower.

### The CreditHolmes object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique id for the credit holmes. |
| `taxId` | STRING | CPF or CNPJ of the entity to be analyzed. |
| `competence` | STRING | Month and year of the credit analysis in YYYY-MM format. Example: "2022-06". |
| `status` | STRING | Current status of the credit analysis. Options: "created", "success", "failed". |
| `result` | OBJECT | Credit analysis result containing financial and credit data for the tax ID. |
| `tags` | LIST OF STRINGS | Tags associated with the credit holmes. |
| `created` | STRING | Creation datetime. Example: "2022-01-01T00:00:00.000000+00:00". |
| `updated` | STRING | Last update datetime. Example: "2022-01-01T00:00:00.000000+00:00". |

### Create Credit Holmes

`POST /v2/credit-holmes`

Create credit holmes requests to analyze the credit profile of a tax ID.

You can create up to 100 requests in a single call.

Before you create a Credit Holmes, make sure you have your customer's express authorization to verify their information in the Central Bank's SCR.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `taxId` | REQUIRED | CPF (11 digits) or CNPJ (14 digits) of the entity to analyze. Example: "012.345.678-90" |
| `competence` | OPTIONAL | Month and year of analysis in YYYY-MM format. Defaults to two months before the current date. Example: "2022-06" |
| `tags` | OPTIONAL | List of strings to tag the entity for future queries. |

**Request**

```python
import starkinfra

holmes = starkinfra.creditholmes.create([
    starkinfra.CreditHolmes(
        tax_id="012.345.678-90",
        competence="2022-06",
        tags=["credit-analysis"]
    )
])

for sherlock in holmes:
    print(sherlock)
```

**Response**

```python
CreditHolmes(
    id=5719405850615809,
    tax_id=012.345.678-90,
    competence=2022-06,
    status=created,
    result=None,
    tags=['credit-analysis'],
    created=2022-06-01T00:00:00.000000+00:00,
    updated=2022-06-01T00:00:00.000000+00:00
)
```

### List Credit Holmes

`GET /v2/credit-holmes`

List and filter all credit holmes requests in your workspace. Results are returned paged.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `status` | OPTIONAL | Filter credit holmes by the specified status. |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |
| `ids` | OPTIONAL | List of strings to get specific entities by ids. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |

**Request**

```python
import starkinfra

holmes = starkinfra.creditholmes.query(limit=10)

for sherlock in holmes:
    print(sherlock)
```

**Response**

```python
CreditHolmes(
    id=5719405850615809,
    tax_id=012.345.678-90,
    competence=2022-06,
    status=solved,
    result={...},
    tags=['credit-analysis'],
    created=2022-06-01T00:00:00.000000+00:00,
    updated=2022-06-01T00:00:00.000000+00:00
)
```

### Get a Credit Holmes

`GET /v2/credit-holmes/:id`

Get a single credit holmes by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the credit holmes entity. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |

**Request**

```python
import starkinfra

sherlock = starkinfra.creditholmes.get("5719405850615809")

print(sherlock)
```

**Response**

```python
CreditHolmes(
    id=5719405850615809,
    tax_id=012.345.678-90,
    competence=2022-06,
    status=solved,
    result={...},
    tags=['credit-analysis'],
    created=2022-06-01T00:00:00.000000+00:00,
    updated=2022-06-01T00:00:00.000000+00:00
)
```

### List Credit Holmes Logs

`GET /v2/credit-holmes/log`

Get a paged list of all credit holmes logs. A log tracks a change in the credit holmes entity according to its life cycle.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `ids` | OPTIONAL | List of credit holmes ids linked to the desired logs. |
| `types` | OPTIONAL | Filter logs by log type. Options: "created", "failed", "success". |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |

**Request**

```python
import starkinfra

logs = starkinfra.creditholmes.log.query(limit=10)

for log in logs:
    print(log)
```

**Response**

```python
Log(
    id=5155165527080961,
    type=created,
    created=2022-06-01T00:00:00.000000+00:00,
    holmes=CreditHolmes(id=5719405850615809, status=created, ...)
)
```

### Get a Credit Holmes Log

`GET /v2/credit-holmes/log/:id`

Get a single credit holmes log by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the credit holmes log entity. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |

**Request**

```python
import starkinfra

log = starkinfra.creditholmes.log.get("5155165527080961")

print(log)
```

**Response**

```python
Log(
    id=5155165527080961,
    type=created,
    created=2022-06-01T00:00:00.000000+00:00,
    holmes=CreditHolmes(id=5719405850615809, status=created, ...)
)
```

## Available Languages

Code samples on this page are in Python. The same content is available with samples in:

- [Python](https://docs.starkinfra.com/api/v2/credit-holmes-python.md)
- [Node.js](https://docs.starkinfra.com/api/v2/credit-holmes-node.md)
- [PHP](https://docs.starkinfra.com/api/v2/credit-holmes-php.md)
- [Java](https://docs.starkinfra.com/api/v2/credit-holmes-java.md)
- [Ruby](https://docs.starkinfra.com/api/v2/credit-holmes-ruby.md)
- [Elixir](https://docs.starkinfra.com/api/v2/credit-holmes-elixir.md)
- [.NET](https://docs.starkinfra.com/api/v2/credit-holmes-dotnet.md)
- [Go](https://docs.starkinfra.com/api/v2/credit-holmes-go.md)
- [Clojure](https://docs.starkinfra.com/api/v2/credit-holmes-clojure.md)
- [cURL](https://docs.starkinfra.com/api/v2/credit-holmes-curl.md)
