# Token Approval

<mark style="color:green;">`POST`</mark> `/approve`

This endpoint generates an unsigned transaction for approving token spending. The approval transaction lets a smart contract (or a specified sender address) spend a given amount of tokens on behalf of the recipient. If a sender is provided, the approval will be generated using that address (and only the ENSC asset type is allowed in that case). Otherwise, the recipient’s address is used.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <api_key>` |

**Body**

<table><thead><tr><th width="151">Name</th><th width="121">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>recipient</code></td><td>string</td><td>The wallet address that will receive the approval.</td></tr><tr><td><code>assetType</code></td><td>string</td><td>The asset type, provided as an enum value (e.g., <code>ENSC</code>, <code>USDC</code>, <code>USDT</code>, etc.).</td></tr><tr><td><code>amount</code></td><td>number</td><td>The amount to approve.</td></tr><tr><td><code>sender</code></td><td>string</td><td><em>Optional.</em> If provided, the approval will be generated using this address instead of the recipient. When provided, only <code>ENSC</code> is allowed as the asset type.</td></tr></tbody></table>

Example 1: Approval for Redeeming Assets (No Sender Provided)

**Request**

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

```json
{
  "recipient": "0xRecipientAddressABC123",
  "assetType": "USDC",
  "amount": 50
}
```

{% endtab %}

{% tab title="Response (200) Ok" %}

```json
{
  "status": 200,
  "message": "Unsigned approve transaction generated successfully",
  "data": {
    "to": "0xTokenContractAddressXYZ",
    "value": 0,
    "gasLimit": "0x186a0",
    "gasPrice": "20000000000",
    "nonce": "5",
    "data": "0x095ea7b3000000000000000000000000DEXContractAddressDEF4560000000000000000000000000000000000000000000000000000000000000032",
    "from": "0xRecipientAddressABC123",
    "spender": "0xDEXContractAddressDEF456"
  }
}
```

{% endtab %}

{% tab title="Invalid Recipient (400) bad" %}

```json
{
  "status": 400,
  "error": "Invalid Request",
  "message": "Invalid recipient address",
  "data": null
}
```

{% endtab %}
{% endtabs %}

Example 2: Approval for Transfers (Sender Provided)

**Response**

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

```json
{
  "recipient": "0xRecipientAddressABC123",
  "sender": "0xSenderAddress987654",
  "assetType": "ENSC",
  "amount": 10
}
```

{% endtab %}

{% tab title="Response (200) Ok" %}

```json
{
  "status": 200,
  "message": "Unsigned approve transaction generated successfully",
  "data": {
    "to": "0xTokenContractAddressXYZ",
    "value": 0,
    "gasLimit": "0x186a0",
    "gasPrice": "20000000000",
    "nonce": "12",
    "data": "0x095ea7b3000000000000000000000000SenderAddress987654000000000000000000000000000000000000000000000000000000000000000a",
    "from": "0xSenderAddress987654",
    "spender": "0xSenderAddress987654"
  }
}
```

{% endtab %}

{% tab title="Invalid Asset When Sender is Provided (400) bad" %}

```json
{
  "status": 400,
  "error": "Invalid Asset",
  "message": "When a sender is provided, only ENSC asset type is allowed",
  "data": null
}
```

{% 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://docs.prosperavest.com/integrations/publish-your-docs-2/token-approval.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.
