# RE:VIVE

{% hint style="warning" %}
If you wish to use RE:VIVE before its official release, please reach out to <contact@redreamer.io> to request early access as the product is currently under development.
{% endhint %}

Welcome to the RE:VIVE - Redeem as Settlement section of the API documentation. The RE:DREAMER API documentation below outlines the essential steps to enable your end-users to utilize NFTs as settlement in your web store.

## NFT Redemption as Settlement

Redemption process:

1. Select "NFT Redemption" as your preferred settlement method at checkout.
2. The shop will initiate a request to create an RE:VIVE order.
3. You will be redirected to the RE:DREAMER website.
4. On the RE:DREAMER website, connect your wallet.
5. A list of available NFTs for the order will be displayed.
6. Choose an NFT to redeem.
7. RE:DREAMER will redirect you back to the shop after the redemption process is complete.

### Prerequisite

To make use of RE:VIVE, a redemption protocol smart contract called RE:ALM is required. You will need to pass the address of your RE:ALM smart contract as `realm_address` in the request body parameter to create an order. Please contact our team at <contact@redreamer.io> to obtain the `realm_address`.

### STEP 1: Create an Order

To initiate an order for the product that the end-user wishes to redeem, send a POST request to the following endpoint:

## Create an Order

<mark style="color:green;">`POST`</mark> `/api/v1/revive/:network/orders`

Create an order for the product that the end-user wishes to redeem.

#### Path Parameters

| Name                                      | Type   | Description                                                                                                                 |
| ----------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------- |
| network<mark style="color:red;">\*</mark> | String | Unique identifier of the network. Please refer to the "Network" section located on the "General" page for more information. |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| x-api-key<mark style="color:red;">\*</mark> | String | API key.    |

#### Request Body

| Name                                                  | Type            | Description                                                                                                                              |
| ----------------------------------------------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| contract\_addresses<mark style="color:red;">\*</mark> | Array of String | A list of eligible NFT smart contract addresses that can be used for settlement.                                                         |
| realm\_address<mark style="color:red;">\*</mark>      | String          | The address of the redemption protocol smart contract that is specifically created for the redemption operator.                          |
| redirect\_link<mark style="color:red;">\*</mark>      | String          | A URL that the end-user will be directed to after the redemption process is complete and has been broadcasted to the blockchain network. |
| item\_url<mark style="color:red;">\*</mark>           | String          | A URL of the image of the item that the end-user wishes to redeem.                                                                       |
| item\_name<mark style="color:red;">\*</mark>          | String          | The name of the item that the end-user wishes to redeem.                                                                                 |
| custom\_id<mark style="color:red;">\*</mark>          | String          | The unique identifier of the order, as provided by the shop owner.                                                                       |

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

```json
{
    "uuid": String,
    "network": String,
    "contract_addresses": [
        String
    ],
    "realm_address": String,
    "custom_id": String,
    "item_name": String,
    "item_url": String,
    "redirect_link": String,
    "created_at": "2023-03-27T04:10:33.608518518Z"
}
```

{% endtab %}
{% endtabs %}

To obtain details about a created order, issue a GET request to the specified endpoint:

## Retrieve Order Details

<mark style="color:blue;">`GET`</mark> `/api/v1/revive/:network/orders/:uuid`

Get detailed information about a created order.

#### Path Parameters

| Name    | Type   | Description                                                                                                                 |
| ------- | ------ | --------------------------------------------------------------------------------------------------------------------------- |
| network | String | Unique identifier of the network. Please refer to the "Network" section located on the "General" page for more information. |
| uuid    | String | The unique identifier of the order for which the information is being retrieved.                                            |

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

```
{
    "uuid": String,
    "network": String,
    "contract_addresses": [
        String
    ],
    "realm_address": String,
    "custom_id": String,
    "item_name": String,
    "item_url": String,
    "redirect_link": String,
    "created_at": "0001-01-01T00:00:00Z"
}
```

{% endtab %}
{% endtabs %}

### STEP 2: List NFTs for an Order

To retrieve the list of NFTs eligible for redemption for a specific order, send a GET request to the following endpoint:

## List NFTs for an Order

<mark style="color:blue;">`GET`</mark> `/api/v1/revive/:network/nfts`

Returns a list of eligible NFTs owned by the connected wallet for a specific order.

#### Path Parameters

| Name                                      | Type   | Description                                                                                                                 |
| ----------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------- |
| network<mark style="color:red;">\*</mark> | String | Unique identifier of the network. Please refer to the "Network" section located on the "General" page for more information. |

#### Query Parameters

| Name                                          | Type   | Description                                                                                |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------ |
| order\_uuid<mark style="color:red;">\*</mark> | String | The unique identifier of the order for which the list of eligible NFTs is being retrieved. |

#### Headers

| Name                                            | Type   | Description                                                |
| ----------------------------------------------- | ------ | ---------------------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | `Bearer ${token}`. Replace `${token}` with the actual JWT. |

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

```json
{
    "data": [
        {
            "id": String,
            "uuid": String,
            "network": String,
            "contract_address": String,
            "token_id": Integer,
            "is_valid": Boolean,
            "is_redeemable": Boolean,
            "created_at": "0001-01-01T00:00:00Z",
            "updated_at": "0001-01-01T00:00:00Z",
            "deleted_at": "0001-01-01T00:00:00Z",
            "name": String,
            "description": String,
            "image": String,
            "external_url": String,
            "animation_url": String,
            "attributes": []
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### STEP 3: Use NFT as Settlement

To use the selected NFT as settlement, send a POST request to the following endpoint:

## Use an NFT as settlement for specific order

<mark style="color:green;">`POST`</mark> `/api/v1/revive/:network/redemption`

Settle an order by redeeming the selected NFT.

#### Path Parameters

| Name                                      | Type   | Description                                                                                                                 |
| ----------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------- |
| network<mark style="color:red;">\*</mark> | String | Unique identifier of the network. Please refer to the "Network" section located on the "General" page for more information. |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| x-api-key<mark style="color:red;">\*</mark> | String | API key.    |

#### Request Body

| Name                                                | Type        | Description                                                                                                     |
| --------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------- |
| user\_input\_data<mark style="color:red;">\*</mark> | JSON Object | Additional key-value pairs `{"key":"value",...}` which can be used to store shipping information.               |
| token\_id<mark style="color:red;">\*</mark>         | Integer     | Unique identifier for an NFT within a specific smart contract.                                                  |
| realm\_address<mark style="color:red;">\*</mark>    | String      | The address of the redemption protocol smart contract that is specifically created for the redemption operator. |
| redeemer\_address<mark style="color:red;">\*</mark> | String      | The address of the user.                                                                                        |
| order\_uuid<mark style="color:red;">\*</mark>       | String      | The unique identifier of the order for which the list of eligible RNFTs is being retrieved.                     |
| contract\_address<mark style="color:red;">\*</mark> | String      | The address of the smart contract for the selected NFT.                                                         |
| custom\_id<mark style="color:red;">\*</mark>        | String      | The unique identifier of the order, as provided by the shop owner.                                              |

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

```json
{
    "uuid": String,
    "order_uuid": String,
    "network": String,
    "contract_address": String,
    "token_id": Integer,
    "status": "redeemed",
    "redeemer_address": String,
    "user_input_data": {
        "additionalProp1": {}
    },
    "created_at": "2023-03-24T09:55:34.664463Z",
    "updated_at": "2023-03-24T09:55:34.664463Z"
}
```

{% endtab %}
{% endtabs %}
