> For the complete documentation index, see [llms.txt](https://docs-swap.crypto-chief.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-swap.crypto-chief.com/api-reference/approve-transaction.md).

# Approve: Transaction

## Approve: Transaction

Builds an unsigned approval as ready-to-sign `steps[]`, in the same step format [`POST /v1/build`](/api-reference/build.md) uses. EVM and TRON only; on Solana, TON and XRP Ledger approvals do not exist and the call is `400 INVALID_REQUEST`.

[`POST /v1/build`](/api-reference/build.md) includes the approval steps a swap needs on its own. This endpoint is for approving ahead of time, for example before quoting, so that the first build already returns a single `swap` step. Approve for the executor your builds will use: [Which executor](/api-reference/approve-spender.md#which-executor).

#### **Approve: Transaction**

<mark style="color:green;">`POST`</mark> `https://swap-api.crypto-chief.com/YOUR_API_KEY/v1/approve/transaction`

**Headers**

| Name         | Value                                                                                                           |
| ------------ | --------------------------------------------------------------------------------------------------------------- |
| Content-Type | `application/json`                                                                                              |
| X-Request-Id | Optional — your id for this call, echoed in the response ([Authentication](/getting-started/authentication.md)) |

**Body**

| Name       | Type   | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ---------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `network`  | string | true     | Network code, case-insensitive                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `token`    | string | true     | The token to approve — address or configured symbol                                                                                                                                                                                                                                                                                                                                                                                                          |
| `amount`   | string | true     | The amount in base units, or `"unlimited"` (case-insensitive) for an approval without a cap. Missing or empty — `400 AMOUNT_INVALID`                                                                                                                                                                                                                                                                                                                         |
| `executor` | string | false    | The executor the approval is for. An executor id, or `dex_router:<dex id>` for a DEX's own router (for example `dex_router:uniswap_v3`). Plain `dex_router` is `400 INVALID_REQUEST` when the network has several DEX routers. Default: the first `enabled` executor in the order [`/v1/liquidity-sources`](/api-reference/liquidity-sources.md) lists them. One that is paused, failed its code check, or is not verified yet is `503 EXECUTOR_UNAVAILABLE` |
| `owner`    | string | false    | The wallet granting the approval. With it, the current allowance decides whether an `approve_reset` step is needed (tokens with the flag `approve_reset_required`), and a Permit2 permission that already covers the amount skips the `permit2_approve` step. Without it, no reset step can be decided and the steps' transactions carry no `from` / `owner_address`                                                                                         |

```json
{
  "network": "ETH_MAINNET",
  "token": "USDT",
  "executor": "oneinch_v6",
  "amount": "1000000000",
  "owner": "0x1F33F99676B65968885adDFaFda3a736424d93C9"
}
```

**Response**

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

```json
{
  "steps": [
    {
      "index": 0,
      "kind": "approve",
      "description": "Approve 1000 USDT to 0x111111125421cA6dc452d289314280a0f8842A65",
      "calls": [
        {"to": "0xdAC17F958D2ee523a2206206994597C13D831ec7", "value": "0", "data": "0x095ea7b3000000000000000000000000111111125421ca6dc452d289314280a0f8842a65000000000000000000000000000000000000000000000000000000003b9aca00"}
      ],
      "transaction": {
        "from": "0x1F33F99676B65968885adDFaFda3a736424d93C9",
        "to": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
        "data": "0x095ea7b3000000000000000000000000111111125421ca6dc452d289314280a0f8842a65000000000000000000000000000000000000000000000000000000003b9aca00",
        "value": "0x0",
        "chainId": "0x1",
        "type": "0x2",
        "maxFeePerGas": "0x2cb417800",
        "maxPriorityFeePerGas": "0x3b9aca00"
      },
      "signer_supported": true,
      "wait_for_confirmation": true,
      "rebuild_after_previous": false
    }
  ]
}
```

With a nonzero current allowance on a token that requires a reset, an `approve_reset` step (`approve(spender, 0)`) comes first. For a Permit2 executor on TRON, a `permit2_approve` step follows the `approve` ([when it is skipped](/getting-started/how-a-swap-works.md#setup-steps)).
{% endtab %}

{% tab title="400 AMOUNT\_INVALID" %}

```json
{
  "error": "AMOUNT_INVALID",
  "message": "amount is required: an amount in base units, or \"unlimited\" for an approval without a limit"
}
```

{% endtab %}

{% tab title="400 INVALID\_REQUEST" %}

```json
{
  "error": "INVALID_REQUEST",
  "message": "approvals do not exist on XRP networks"
}
```

{% endtab %}

{% tab title="503" %}

```json
{
  "error": "EXECUTOR_UNAVAILABLE",
  "message": "executor oneinch_v6 is not available on ETH_MAINNET"
}
```

{% endtab %}
{% endtabs %}

**Fields**

| Field     | Description                                                                                                                                                                                |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `steps[]` | The approval steps in order: `approve_reset` (when needed), `approve`, then `permit2_approve` (Permit2 executors, when needed). [The step object](/api-reference/build.md#the-step-object) |

{% hint style="warning" %}
`unlimited` removes the spending cap for that spender. `exact` amounts — the default in builds — limit the damage a compromised or replaced router can do. Prefer an exact amount unless you have a reason.
{% endhint %}

### Example

`swap()` is defined in [Authentication](/getting-started/authentication.md).

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

```javascript
const { steps } = await swap("approve/transaction", {
  network: "ETH_MAINNET",
  token: "USDT",
  amount: "1000000000",
  owner: "0x1F33F99676B65968885adDFaFda3a736424d93C9",
});
for (const step of steps) console.log(step.kind, step.transaction);
```

{% endtab %}

{% tab title="PHP" %}

```php
$out = swap('approve/transaction', [
    'network' => 'ETH_MAINNET',
    'token'   => 'USDT',
    'amount'  => '1000000000',
    'owner'   => '0x1F33F99676B65968885adDFaFda3a736424d93C9',
]);
foreach ($out['steps'] as $step) print_r($step['kind']);
```

{% endtab %}

{% tab title="GO" %}

```go
out, _, err := swap("approve/transaction", map[string]any{
	"network": "ETH_MAINNET",
	"token":   "USDT",
	"amount":  "1000000000",
	"owner":   "0x1F33F99676B65968885adDFaFda3a736424d93C9",
})
if err != nil {
	log.Fatal(err)
}
for _, step := range out["steps"].([]any) {
	fmt.Println(step.(map[string]any)["kind"])
}
```

{% endtab %}

{% tab title="Python" %}

```python
out = swap("approve/transaction", {
    "network": "ETH_MAINNET",
    "token": "USDT",
    "amount": "1000000000",
    "owner": "0x1F33F99676B65968885adDFaFda3a736424d93C9",
})
for step in out["steps"]:
    print(step["kind"])
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -s -X POST "https://swap-api.crypto-chief.com/$CC_API_KEY/v1/approve/transaction" \
  -H "Content-Type: application/json" \
  -d '{"network":"ETH_MAINNET","token":"USDT","amount":"1000000000","owner":"0x1F33F99676B65968885adDFaFda3a736424d93C9"}'
```

{% endtab %}
{% endtabs %}

### After the approval confirms

Build the swap. A [`/v1/build`](/api-reference/build.md) that finds the allowance in place returns the `swap` step directly, measured and simulated.
