# Deposits (deprecated)

{% hint style="danger" %}
These endpoints are deprecated and will be discontinued by November 1st. Please make sure you migrate your implementation to the new [deposits flow](https://developers.publicmint.io/api/funding/deposit-wire).
{% endhint %}

To initiate a deposit, create a `deposit` object via the `/deposits` endpoint. If you want to create an **ACH** type deposit, you need to have created at least one [transfer method](https://developers.publicmint.io/api/reference/broken-reference) in order to make a deposit.

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

```
POST /deposits
GET /deposits/:id
GET /deposits
```

{% endtab %}
{% endtabs %}

## The `deposit` object

The `deposit` object represents a request for depositing fiat into the blockchain. You can create or retrieve an `identityId`'s deposits via request to the API. Or, if you manage multiple identities in the network, you can also retrieve a list of deposits for all of them.

Deposits are identified by a unique, random `id`, and relate to a user's `identityId`

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

```javascript
{
    "id": "3305af3a-e3c8-4f73-a46b-58c0d6376825",
    "identityId": "971c3241-9876-471e-b0b3-40040893efd0",
    "amount": "12",
    "currency": "USD",
    "blockchainAddress": "0x359f194ce353b1415abff5fcb07baf59f0bda0de",
    "transferMethodInformation": {
        "transferType": "wire"
    },
    "status": "pending",
    "reference": null,
    "createdAt": "2021-02-17T18:02:50.365Z",
    "updatedAt": "2021-02-17T18:02:50.365Z"
}
```

{% endtab %}
{% endtabs %}

## POST /deposits

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

This endpoint allows you to add a new deposit to the database. If all the params are valid, a new record will be inserted in the database with the deposit information.

#### Request Body

| Name                | Type   | Description                                          |
| ------------------- | ------ | ---------------------------------------------------- |
| amount              | string | Amount of the deposit                                |
| currency            | string | Currency associated to the deposit funds             |
| identityId          | string | Id of the identity associated to the deposit         |
| blockchainAddress   | string | Blockchain address to where the funds will be minted |
| transferInformation | object | Deposit transfer information                         |

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

```javascript
{
    "id": "ea5894d2-2657-424a-906e-0f9c345ab48b",
    "identityId": "e65dde2c-4379-42c7-a665-3f476cebb691",
    "transferMethodId": null,
    "amount": "11",
    "currency": "USD",
    "blockchainAddress": "0xF2A511240E0D6b7E9683Ff979b4C4Afb9d3fE2E9",
    "message": null,
    "status": "waiting",
    "fundsTransferDetails": null,
    "reference": null,
    "transferType": "wire",
    "createdAt": "2020-02-19T11:15:08.144Z",
    "updatedAt": "2020-02-19T11:15:08.144Z"
}
```

{% endtab %}

{% tab title="400 Response given when any of the parameters is invalid." %}

```
{
  "code": "invalid_data_format",
  "status": "400"
}
```

{% endtab %}

{% tab title="500 Error when calling the API." %}

```
{
  "code": "internal_server_error",
  "status": "500"

```

{% endtab %}
{% endtabs %}

**Note: The** `transferInformation` **object needs specific information depending on the kind of deposit you intend to create. In the example bellow, you can find the information necessary to create all the deposit types.**

#### Example Call

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

```javascript
POST [ENVIRONMENT HOSTNAME]/deposits

// BODY for Wire deposits

{
	"amount": "11",
	"currency": "USD",
	"identityId": "{{identityId}}",
	"blockchainAddress": "{{identityId}}",
	"transferInformation": {
		"transferType": "wire"
	}
}

// BODY for International Wire deposits

{
	"amount": "11",
	"currency": "USD",
	"identityId": "{{identityId}}",
	"blockchainAddress": "{{blockchainAddress}}",
	"transferInformation": {
		"transferType": "internationalWire"
	}
}

// BODY for USDC deposits

{
	"amount": "11",
	"currency": "USD",
	"identityId": "{{identityId}}",
	"blockchainAddress": "{{blockchainAddress}}",
	"transferInformation": {
		"transferType": "scUsdc"
	}
}
```

{% endtab %}

{% tab title="Curl" %}

```
curl -X POST \
  [ENVIRONMENT HOSTNAME]/deposits \
  -H 'Content-Type: application/json' \
  -H 'apikey: {INSERT API KEY HERE}' \
  -d '{
	"amount": "12",
	"currency": "USD",
	"identityId": "e65dde2c-4379-42c7-a665-3f476cebb691",
	"blockchainAddress": "0xA4597E696a55fD76430945e0940DA17c72337ccC",
	"transferInformation": {
		"transferType": "wire"
	}
}'
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": "3305af3a-e3c8-4f73-a46b-58c0d6376825",
    "identityId": "971c3241-9876-471e-b0b3-40040893efd0",
    "amount": "12",
    "currency": "USD",
    "blockchainAddress": "0x359f194ce353b1415abff5fcb07baf59f0bda0de",
    "transferMethodInformation": {
        "transferType": "wire"
    },
    "status": "waiting",
    "reference": null,
    "createdAt": "2021-02-17T18:02:50.365Z",
    "updatedAt": "2021-02-17T18:02:50.365Z"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
On the **Sandbox** environment, you can use the [settle deposit ](https://developers.publicmint.io/sandbox#settle-deposit)endpoint to simulate and settle the deposit request you created.
{% endhint %}

On the **Sandbox** environment, you can use the [approve KYC ](https://developers.publicmint.io/sandbox#approve-kyc)endpoint to simulate and approve the identity you created.

## GET /deposits/:id

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

This endpoint retrieves a single deposit that you've created by its specific `id` attribute.

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

```
{
    "id": "ee1ce972-0dfc-45fc-98bf-0fc90a7f86db",
    "identityId": "e65dde2c-4379-42c7-a665-3f476cebb691",
    "amount": "12",
    "currency": "USD",
    "blockchainAddress": "0x6257EaCbB030ed1B33d11Aa841B2511B1B444937",
    "message": null,
    "status": "pending",
    "fundsTransferDetails": null,
    "reference": null,
    "transferInformation": {
		    "transferType": "wire"
	  },
    "createdAt": "2020-02-19T11:17:20.567Z",
    "updatedAt": "2020-02-19T11:17:21.241Z"
}
```

{% endtab %}
{% endtabs %}

#### Example Call

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

```javascript
GET [ENVIRONMENT HOSTNAME]/deposits/b22d80d9-0e14-4e4f-8101-881dd7138bc5
```

{% endtab %}

{% tab title="Curl" %}

```
curl -X GET \
  [ENVIRONMENT HOSTNAME]/deposits/7b6bbb41-b0e0-4058-b59e-ea3181f854ec \
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": "3305af3a-e3c8-4f73-a46b-58c0d6376825",
    "identityId": "971c3241-9876-471e-b0b3-40040893efd0",
    "amount": "12",
    "currency": "USD",
    "blockchainAddress": "0x359f194ce353b1415abff5fcb07baf59f0bda0de",
    "transferMethodInformation": {
        "transferType": "wire"
    },
    "status": "waiting",
    "reference": null,
    "createdAt": "2021-02-17T18:02:50.365Z",
    "updatedAt": "2021-02-17T18:02:50.365Z"
}
```

{% endtab %}
{% endtabs %}

## GET /deposits

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

This endpoint returns a list of all your deposits.

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

```
{
    "total": 1,
    "data": [
        {
            "id": "a1132d6d-adfc-4ba9-b1ca-e82eaac8199d",
            "identityId": "e0564926-96e0-42e2-a544-68bc18598e40",
            "amount": "12.12",
            "currency": "USD",
            "blockchainAddress": "0x6257EaCbB030ed1B33d11Aa841B2511B1B444937",
            "message": null,
            "status": "waiting",
            "fundsTransferDetails": null,
            "reference": null,
            "transferInformation": {
                "transferType": "wire"
            },
            "createdAt": "2020-01-24T18:02:22.870Z",
            "updatedAt": "2020-01-24T18:02:22.870Z"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

#### Example Call

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

```javascript
GET [ENVIRONMENT HOSTNAME]/deposits

// PAGINATED

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

{% endtab %}

{% tab title="Curl" %}

```
curl -X GET \
  [ENVIRONMENT HOSTNAME]/deposits/7b6bbb41-b0e0-4058-b59e-ea3181f854ec \
  -H 'apikey: {INSERT API KEY HERE}'
  
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "total": 1,
    "data": [
      {
        "id": "3305af3a-e3c8-4f73-a46b-58c0d6376825",
        "identityId": "971c3241-9876-471e-b0b3-40040893efd0",
        "amount": "12",
        "currency": "USD",
        "blockchainAddress": "0x359f194ce353b1415abff5fcb07baf59f0bda0de",
        "transferMethodInformation": {
            "transferType": "wire"
        },
        "status": "waiting",
        "reference": null,
        "createdAt": "2021-02-17T18:02:50.365Z",
        "updatedAt": "2021-02-17T18:02:50.365Z"
    }]
}
```

{% endtab %}
{% endtabs %}
