# Pix Key Holmes

PixKeyHolmes are used by a Pix participant to verify whether a Pix key is registered in DICT, the Brazilian Central Bank's key directory.

Here we will show you how to create and manage them.

### The Pix Key Holmes Object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique id for the Pix key holmes. |
| `status` | STRING | Current status. Options: "created", "solving", "solved", "failed". |
| `keyId` | STRING | Pix key under verification. |
| `result` | STRING | Verification result. Options: "registered", "unregistered". Empty until the status is "solved". |
| `tags` | LIST OF STRINGS | Tags associated with the Pix key holmes. |
| `created` | STRING | Creation datetime. Example: "2020-04-23T23:00:00.000000+00:00". |
| `updated` | STRING | Last update datetime. Example: "2020-04-23T23:00:00.000000+00:00". |

### Create Pix Key Holmes

`POST /v2/pix-key-holmes`

Request the verification of one or more Pix keys in DICT.

You can create up to 100 Pix key holmes in a single request.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `keyId` | REQUIRED | Pix key to be verified. Can be a CPF, CNPJ, phone, e-mail or EVP (random) key. |
| `tags` | OPTIONAL | Array of strings to tag the entity for future queries. |

**Request**

```python
import starkinfra

holmes = starkinfra.pixkeyholmes.create([
    starkinfra.PixKeyHolmes(
        key_id="jon.snow@starkinfra.com",
        tags=["key-check"]
    )
])

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

**Response**

```python
[
    PixKeyHolmes(
        id="5656565656565656",
        status="solving",
        key_id="jon.snow@starkinfra.com",
        result="",
        tags=["key-check"],
        created="2022-01-01T00:00:00+00:00",
        updated="2022-01-01T00:00:00+00:00"
    )
]
```

### List Pix Key Holmes

`GET /v2/pix-key-holmes`

List and filter all Pix key holmes. Results are 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. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |
| `ids` | OPTIONAL | List of strings to get specific entities by ids. |
| `keyId` | OPTIONAL | Filter by the verified Pix key. |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `status` | OPTIONAL | Filter by status. Options: "created", "solving", "solved", "failed". |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |

**Request**

```python
import starkinfra

holmes = starkinfra.pixkeyholmes.query(
    limit=10,
    status="solved"
)

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

**Response**

```python
<generator object query at 0x...>

PixKeyHolmes(
    id="5656565656565656",
    status="solved",
    key_id="jon.snow@starkinfra.com",
    result="registered",
    tags=["key-check"],
    created="2022-01-01T00:00:00+00:00",
    updated="2022-01-01T00:00:05+00:00"
)
```

### Get a Pix Key Holmes

`GET /v2/pix-key-holmes/:id`

Get a single Pix key holmes by its id.

**Parameters**

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

**Request**

```python
import starkinfra

sherlock = starkinfra.pixkeyholmes.get("5656565656565656")

print(sherlock)
```

**Response**

```python
PixKeyHolmes(
    id="5656565656565656",
    status="solved",
    key_id="jon.snow@starkinfra.com",
    result="registered",
    tags=["key-check"],
    created="2022-01-01T00:00:00+00:00",
    updated="2022-01-01T00:00:05+00:00"
)
```

### List Pix Key Holmes Logs

`GET /v2/pix-key-holmes/log`

Get a paged list of all Pix key holmes logs.

**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. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |
| `ids` | OPTIONAL | Filter by Pix key holmes log ids. |
| `holmesIds` | OPTIONAL | Filter logs by the Pix key holmes ids they belong to. |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `types` | OPTIONAL | Filter by log types. Options: "solving", "solved". |

**Request**

```python
import starkinfra

logs = starkinfra.pixkeyholmes.log.query(
    limit=10,
    types="solved"
)

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

**Response**

```python
<generator object query at 0x...>

Log(
    id="6767676767676767",
    type="solved",
    holmes=PixKeyHolmes(
        id="5656565656565656",
        status="solved",
        key_id="jon.snow@starkinfra.com",
        result="registered",
        tags=["key-check"],
        created="2022-01-01T00:00:00+00:00",
        updated="2022-01-01T00:00:05+00:00"
    ),
    errors=[],
    created="2022-01-01T00:00:05+00:00"
)
```

### Get a Pix Key Holmes Log

`GET /v2/pix-key-holmes/log/:id`

Get a single Pix key holmes log by its id.

**Parameters**

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

**Request**

```python
import starkinfra

log = starkinfra.pixkeyholmes.log.get("6767676767676767")

print(log)
```

**Response**

```python
Log(
    id="6767676767676767",
    type="solved",
    holmes=PixKeyHolmes(
        id="5656565656565656",
        status="solved",
        key_id="jon.snow@starkinfra.com",
        result="registered",
        tags=["key-check"],
        created="2022-01-01T00:00:00+00:00",
        updated="2022-01-01T00:00:05+00:00"
    ),
    errors=[],
    created="2022-01-01T00:00:05+00:00"
)
```

## 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/pix-key-holmes-python.md)
- [Node.js](https://docs.starkinfra.com/api/v2/pix-key-holmes-node.md)
- [PHP](https://docs.starkinfra.com/api/v2/pix-key-holmes-php.md)
- [Java](https://docs.starkinfra.com/api/v2/pix-key-holmes-java.md)
- [Ruby](https://docs.starkinfra.com/api/v2/pix-key-holmes-ruby.md)
- [Elixir](https://docs.starkinfra.com/api/v2/pix-key-holmes-elixir.md)
- [.NET](https://docs.starkinfra.com/api/v2/pix-key-holmes-dotnet.md)
- [Go](https://docs.starkinfra.com/api/v2/pix-key-holmes-go.md)
- [Clojure](https://docs.starkinfra.com/api/v2/pix-key-holmes-clojure.md)
- [cURL](https://docs.starkinfra.com/api/v2/pix-key-holmes-curl.md)
