# Documents

This resource corresponds to a digitized document hosted on Public Mint's servers in `file` format.

{% tabs %}
{% tab title="ENDPOINTS" %}

```
POST /documents
GET /documents/:id
GET /documents
DELETE /documents/:id
```

{% endtab %}
{% endtabs %}

## The `document` object

The `document` object represents a digitized document (generally a government ID or proof of address) in the shape of a file uploaded to Public Mint's servers.

A `document` is identified by a unique, random `id` and relates to a user's `identityId`.&#x20;

{% tabs %}
{% tab title="DOCUMENT OBJECT" %}

```javascript
{
    "id": "e9cbc096-bb79-438b-93ac-7c15dfdb1274",
    "identityId": "971c3241-9876-471e-b0b3-40040893efd0",
    "status": "pending",
    "label": "identity card",
    "description": "identity card of jonh smith",
    "extension": ".png",
    "fileUrl": "https://pmint-custodial-api-tst-identity-docs.s3.amazonaws.com/97/1c/32/41/LaDRHrVEScopeYBT.png",
    "documentType": "IdentityCard",
    "documentSide": "FrontSide",
    "createdAt": "2021-02-17T14:03:51.974Z",
    "updatedAt": "2021-02-17T14:03:51.974Z",
    "deletedAt": null
}
```

{% endtab %}
{% endtabs %}

## POST /documents

<mark style="color:green;">`POST`</mark> `[ENVIRONMENT HOSTNAME]/documents`

This endpoint allows you to submit a new document to the database. If all parameters are valid, a new record will be added to the database.

#### Request Body

| Name         | Type   | Description                                                                                                                                                                                                                                                                                             |
| ------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| description  | string | Description associated to the document                                                                                                                                                                                                                                                                  |
| documentSide | string | <p>Side of the document<br><br><strong>Must be one of the following:</strong><br> <strong>- FrontSide</strong><br> <strong>- BackSide</strong></p>                                                                                                                                                      |
| documentType | string | <p>Type of the document<br><br><strong>Must be one of the following:</strong><br> <strong>- IdentityCard;</strong><br> <strong>- DriverLicense;</strong><br> <strong>- Passport;</strong><br> <strong>- ResidencePermit;</strong><br> <strong>- UtilityBill;</strong><br> <strong>- Other.</strong></p> |
| identityId   | string | Id of the identity associated to the document.                                                                                                                                                                                                                                                          |
| label        | string | Label for the document.                                                                                                                                                                                                                                                                                 |
| file         | object | <p>Document file<br><br><strong>Requirements:</strong><br> <strong>- Needs to be a file;</strong><br> <strong>- Needs to be the last field in the       form</strong></p>                                                                                                                               |

{% tabs %}
{% tab title="200 Deposit successfully inserted in the database." %}

```javascript
{
    "id": "e9cbc096-bb79-438b-93ac-7c15dfdb1274",
    "identityId": "971c3241-9876-471e-b0b3-40040893efd0",
    "status": "pending",
    "label": "identity card",
    "description": "identity card of jonh smith",
    "extension": ".png",
    "fileUrl": "https://pmint-custodial-api-tst-identity-docs.s3.amazonaws.com/97/1c/32/41/LaDRHrVEScopeYBT.png",
    "documentType": "IdentityCard",
    "documentSide": "FrontSide",
    "createdAt": "2021-02-17T14:03:51.974Z",
    "updatedAt": "2021-02-17T14:03:51.974Z",
    "deletedAt": null
}
```

{% endtab %}
{% endtabs %}

#### Example Call

{% tabs %}
{% tab title="Request" %}

```javascript
POST [ENVIRONMENT HOSTNAME]/documents


```

{% endtab %}

{% tab title="Curl" %}

```
curl --location --request POST 'https://api.tst.publicmint.io/documents' \
--header 'apiKey: J8fMImECtv0jAYXJ8D6gS48z45B3YeC5' \
--form 'description="identity card of jonh smith"' \
--form 'label="identity card"' \
--form 'identityId="971c3241-9876-471e-b0b3-40040893efd0"' \
--form 'documentType="IdentityCard"' \
--form 'documentSide="FrontSide"' \
--form 'file=@"/Users/foo/Screen Shot 2021-02-04 at 14.33.01.png"'
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": "e9cbc096-bb79-438b-93ac-7c15dfdb1274",
    "identityId": "971c3241-9876-471e-b0b3-40040893efd0",
    "status": "pending",
    "label": "identity card",
    "description": "identity card of jonh smith",
    "extension": ".png",
    "fileUrl": "https://pmint-custodial-api-tst-identity-docs.s3.amazonaws.com/97/1c/32/41/LaDRHrVEScopeYBT.png",
    "documentType": "IdentityCard",
    "documentSide": "FrontSide",
    "createdAt": "2021-02-17T14:03:51.974Z",
    "updatedAt": "2021-02-17T14:03:51.974Z",
    "deletedAt": null
}
```

{% endtab %}
{% endtabs %}

## GET /documents/:id

<mark style="color:blue;">`GET`</mark> `[ENVIRONMENT HOSTNAME]/documents/:id`

This endpoint retrieves a single document that you own by its specific `id` attribute.

#### Path Parameters

| Name | Type   | Description                        |
| ---- | ------ | ---------------------------------- |
| id   | string | Id of the document to be retrieved |

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

```
{
    "id": "0acb6a86-e21e-45d6-a4e5-70bd4f85ecae",
    "identityId": "e0564926-96e0-42e2-a544-68bc18598e40",
    "status": "active",
    "label": "identity card",
    "description": "identity card of jonh smith",
    "extension": ".jpeg",
    "fileUrl": "https://pmint-custodial-api-tst-identity-docs.s3.amazonaws.com/e0/56/49/26/N5MXjSIhK0bGAOt2.jpeg",
    "documentType": "IdentityCard",
    "documentSide": "FrontSide",
    "createdAt": "2020-01-10T17:24:23.561Z",
    "updatedAt": "2020-01-10T17:24:24.455Z",
    "deletedAt": null
}
```

{% endtab %}
{% endtabs %}

#### Example Call

{% tabs %}
{% tab title="Request" %}

```javascript
GET [ENVIRONMENT HOSTNAME]/documents/0acb6a86-e21e-45d6-a4e5-70bd4f85ecae

```

{% endtab %}

{% tab title="Curl" %}

```
curl -X GET \
  [ENVIRONMENT HOSTNAME]/documents/0acb6a86-e21e-45d6-a4e5-70bd4f85ecae \
  -H "apikey: {INSERT YOUR API KEY HERE}" \
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": "0acb6a86-e21e-45d6-a4e5-70bd4f85ecae",
    "identityId": "e0564926-96e0-42e2-a544-68bc18598e40",
    "status": "active",
    "label": "identity card",
    "description": "identity card of jonh smith",
    "extension": ".jpeg",
    "fileUrl": "https://pmint-custodial-api-tst-identity-docs.s3.amazonaws.com/e0/56/49/26/N5MXjSIhK0bGAOt2.jpeg",
    "documentType": "IdentityCard",
    "documentSide": "FrontSide",
    "createdAt": "2020-01-10T17:24:23.561Z",
    "updatedAt": "2020-01-10T17:24:24.455Z",
    "deletedAt": null
}
```

{% endtab %}
{% endtabs %}

## GET /documents

<mark style="color:blue;">`GET`</mark> `[ENVIRONMENT HOSTNAME]/documents`

This endpoint returns a list of all documents submitted by you.

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

```
{
    "total": 1,
    "data": [
        {
            "id": "0acb6a86-e21e-45d6-a4e5-70bd4f85ecae",
            "identityId": "e0564926-96e0-42e2-a544-68bc18598e40",
            "status": "active",
            "label": "identity card",
            "description": "identity card of jonh smith",
            "extension": ".jpeg",
            "fileUrl": "https://pmint-custodial-api-tst-identity-docs.s3.amazonaws.com/e0/56/49/26/N5MXjSIhK0bGAOt2.jpeg",
            "documentType": "IdentityCard",
            "documentSide": "FrontSide",
            "createdAt": "2020-01-10T17:24:23.561Z",
            "updatedAt": "2020-01-10T17:24:24.455Z",
            "deletedAt": null
        }
    ]
}
```

{% endtab %}
{% endtabs %}

#### Example Call

{% tabs %}
{% tab title="Request" %}

```javascript
GET [ENVIRONMENT HOSTNAME]/documents
  
// PAGINATED

GET [ENVIRONMENT HOSTNAME]/documents?page[number]=1&page[size]=1
```

{% endtab %}

{% tab title="Curl" %}

```
curl -X GET \
  "[ENVIRONMENT HOSTNAME]/documents" \
  -H "apikey: {INSERT YOUR API KEY HERE}" \
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "total": 1,
    "data": [
        {
             "id": "0acb6a86-e21e-45d6-a4e5-70bd4f85ecae",
            "identityId": "e0564926-96e0-42e2-a544-68bc18598e40",
            "status": "active",
            "label": "identity card",
            "description": "identity card of jonh smith",
            "extension": ".jpeg",
            "fileUrl": "https://pmint-custodial-api-tst-identity-docs.s3.amazonaws.com/e0/56/49/26/N5MXjSIhK0bGAOt2.jpeg",
            "documentType": "IdentityCard",
            "documentSide": "FrontSide",
            "createdAt": "2020-01-10T17:24:23.561Z",
            "updatedAt": "2020-01-10T17:24:24.455Z",
            "deletedAt": null
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## DELETE /documents/:id

<mark style="color:red;">`DELETE`</mark> `[ENVIRONMENT HOSTNAME]/documents/:id`

Deletes a specific document by it's id.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | Document id |

{% tabs %}
{% tab title="204 " %}

```
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.publicmint.io/api/reference/documents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
