# Get Public Card

Public business cards on Becard form the core functionality. We need to distinguish between public and secured digital business cards. The initial step is always the same, but subsequent actions may vary, as there could be a need for PIN validation. This is indicated in the response after the initial <mark style="color:blue;">`GET`</mark> Prefetch step.

We protect digital cards, particularly against search engine indexing and external attacks, through dual validation, irrespective of whether they are public or secured digital business cards. In the first step, we search and retrieve the basic data of the desired card.&#x20;

Occasionally, we receive a '<mark style="color:orange;">`Secret`</mark>' and a '<mark style="color:orange;">`SecretHash`</mark>,' which contains the signature key for further querying in the second step through the <mark style="color:green;">`POST`</mark> request. Upon successful query authentication, contact information and social media channels are provided.

### Step 1: Prefetch ground card data and get secret tokens.

As <mark style="color:orange;">`IDENTIFICATION_ID`</mark> you are able to choose between <mark style="color:red;">`UUID`</mark>, <mark style="color:red;">`USERNAME`</mark>, <mark style="color:red;">`PRODUCT-`</mark> or a <mark style="color:red;">`QRCODE SERIAL NUMBER`</mark> to find and prefetch a public digital business card.

<mark style="color:blue;">`GET`</mark> `/v1/public/card/{IDENTIFICATION_ID}/prefetch`

#### Path Parameters

| Name                                                 | Type   | Description |
| ---------------------------------------------------- | ------ | ----------- |
| IDENTIFICATION\_ID<mark style="color:red;">\*</mark> | string |             |

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": 200,
    "uuid": "As43ydsm1D0VRgN",
    "username": "pablo-martinez",
    "name": "Pablo Matinez",
    "isBusiness": false,
    "organisation": "Zara Moda",
    "position": "Director de marketing",
    "department": null,
    "description": {
        "en": "El creador de la moda."
    },
    "redirection": null,
    "focus": "contact",
    "color": "#a80000",
    "avatar": {
        "uuid": "Ws5A0Z5qH4rjQo2",
        "src": "https://cdn.becard.me/live/avatar/card-1679525723296-As43ydsm1D0VRgN.jpg",
        "mim_type": "image/jpeg",
        "extension": "jpg",
        "size": "6.04 KB"
    },
    "template": "card",
    "settings": {
        "show_login_button": true,
        "show_becard_logo": true,
        "logo_src": "https://cdn.becard.me/live/logo/card-1679525962953-As43ydsm1D0VRgN.png",
        "icon_src": null,
        "header_src": "https://cdn.becard.me/live/cover/card-1679526250056-As43ydsm1D0VRgN.jpg",
        "favicon_src": null,
        "background_src": null,
        "enable_backgrounds": false,
        "show_avatar": true,
        "save_avatar": true,
        "enable_contact_book": false,
        "show_vcf_link": true,
        "enable_qrCode": true,
        "enable_pushNotifications": false,
        "push_notifications": "vbrLeT5riv*****",
        "newsletter": {
            "email": true,
            "name": true,
            "phone": false
        },
        "affiliate": false
    },
    "secure_domain": null,
    "lang": "en",
    "secret": "JDJ5JDEwJERMMDQySmphbVlBZDk*****",
    "secretHash": "ZXhwaXJlcz0xNjk3NzU4M***"
}
```

{% endtab %}
{% endtabs %}

### Step 1.1: Prefetch if PIN required

If a digital business card requires a PIN, the signature key must be requested. After successful PIN validation, a `signature` is generated, which is appended as a QUERY parameter to the ENDPOINT in [step 1](#step-1-prefetch-ground-card-data-and-get-secret-tokens.). Therefore, the query is repeated once more with an additional signature.

<mark style="color:orange;">**Please note: The signature is only valid for 10 minutes.**</mark>

<mark style="color:green;">`POST`</mark> `/v1/public/card/{UUID}/validate`

#### Path Parameters

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| UUID<mark style="color:red;">\*</mark> | String |             |

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Accept<mark style="color:red;">\*</mark>       | String | application/json |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json |

#### Request Body

| Name                                  | Type   | Description                                   |
| ------------------------------------- | ------ | --------------------------------------------- |
| pin<mark style="color:red;">\*</mark> | String | <mark style="color:red;">`PIN OF CARD`</mark> |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "signature": "expires=1701811422&track=disable&signature=b9d78a09a6204eb14ba37df51e5c13411313a3521a8390c4d1703daaa096d4bc"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```json
{
    "message": "Access validation failed!",
    "status": "Unauthorized",
    "code": 401
}
```

{% endtab %}

{% tab title="404: Not Found " %}

```json
{
    "message": "This card is not found or no longer exists!",
    "errors": {
        "Card": [
            "This card is not found or no longer exists!"
        ]
    }
}
```

{% endtab %}
{% endtabs %}

### Step 2: Use your Secret Hash-Tokens to get contact details.

To get query parameter <mark style="color:orange;">`signature`</mark> and <mark style="color:orange;">`expires`</mark> you need to decrypt the <mark style="color:yellow;">`base64 encoded`</mark> <mark style="color:red;">`secretHash`</mark> of the prefetched card. This tokens valid maximum 5 minutes.

<mark style="color:green;">`POST`</mark> `/v1/public/card/{UUID}`

#### Path Parameters

| Name                                   | Type   | Description                 |
| -------------------------------------- | ------ | --------------------------- |
| UUID<mark style="color:red;">\*</mark> | string | UUID of the prefetched card |

#### Query Parameters

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| expires<mark style="color:red;">\*</mark>   | int    |             |
| signature<mark style="color:red;">\*</mark> | string |             |

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json |
| Accept<mark style="color:red;">\*</mark>       | String | application/json |

#### Request Body

| Name                                   | Type   | Description                   |
| -------------------------------------- | ------ | ----------------------------- |
| hash<mark style="color:red;">\*</mark> | string | Secret of the prefetched card |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "uuid": "As43ydsm1D0VRgN",
    "addresses": [
        {
            "uuid": "Arx77je1LOQZ17u",
            "pos": null,
            "zipcode": "28036",
            "city": "Madrid",
            "address_line1": "Av. Concha Espina 1",
            "address_line2": null,
            "space_address": false,
            "space_default": null,
            "country": {
                "iso2": "ES",
                "name": "Spain",
                "phone_prefix": "+34"
            }
        }
    ],
    "contacts": [
        {
            "type": "phone",
            "name": null,
            "value": "+34-960-130-004"
        },
        {
            "type": "email",
            "name": null,
            "value": "info@youremail.es"
        },
        {
            "type": "website",
            "name": null,
            "value": "https://example.es"
        },
        {
            "type": "mobile",
            "name": null,
            "value": "+43-960-130-005"
        }
    ],
    "social_media": [
        {
            "uuid": "KpwkiHNIDydInXm",
            "pos": null,
            "name": "Facebook",
            "url": null,
            "url_space": null,
            "color": {
                "primary": "#1877F2",
                "secondary": "#FFFFFF"
            },
            "class_icon": null,
            "description": null,
            "settings": null,
            "assets": null,
            "link": "https://facebook.com/zara",
            "username": "zara",
            "target": "https://facebook.com/",
            "template": {
               ..
            }
        },
        ..
    ],
    "hasFiles": 2,
    "videoFrame": {
        "link": "https://www.youtube.com/watch?v=gKCmezkfWbE",
        "autoload": false,
        "video_presence": "button_frame",
        "btn_position": "middle",
        "source": "youtube",
        "source_link": "https://www.youtube.com/embed/gKCmezkfWbE",
        "source_type": "text/html",
        "cover": "https://i.ytimg.com/vi/gKCmezkfWbE/maxresdefault.jpg"
    }
}
```

{% endtab %}

{% tab title="403: Forbidden " %}

```json
{
    "message": "Please reload this digital card!"
}
```

{% endtab %}
{% endtabs %}
