> 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-spender.md).

# Approve: Spender

## Approve: Spender

The address a token approval must authorize for an executor — its spender. EVM and TRON only; on Solana, TON and XRP Ledger approvals do not exist and the call is `400 INVALID_REQUEST`.

Most integrations never call this: [`POST /v1/build`](/api-reference/build.md) already returns the approval steps a swap needs. The approve endpoints are for managing allowances yourself — together with [`/v1/approve/allowance`](/api-reference/approve-allowance.md) and [`/v1/approve/transaction`](/api-reference/approve-transaction.md).

#### **Approve: Spender**

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

**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                                                                                                                                                                                                                                                                                            |
| `executor` | string | false    | 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 |

```json
{
  "network": "ETH_MAINNET",
  "executor": "oneinch_v6"
}
```

**Response**

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

```json
{
  "address": "0x111111125421cA6dc452d289314280a0f8842A65"
}
```

{% endtab %}

{% tab title="400" %}

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

{% endtab %}

{% tab title="503" %}

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

Without `executor`, this means no executor of the network is verified yet: retry shortly. Naming an executor that is paused, failed its code check, or does not exist on the network is refused the same way.
{% endtab %}
{% endtabs %}

**Fields**

| Field     | Description                                                     |
| --------- | --------------------------------------------------------------- |
| `address` | The spender to authorize in an `approve` call for this executor |

### Example

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

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

```javascript
const { address } = await swap("approve/spender", {
  network: "ETH_MAINNET",
  executor: "oneinch_v6",
});
console.log(address);
```

{% endtab %}

{% tab title="PHP" %}

```php
$out = swap('approve/spender', ['network' => 'ETH_MAINNET', 'executor' => 'oneinch_v6']);
echo $out['address'], "\n";
```

{% endtab %}

{% tab title="GO" %}

```go
out, _, err := swap("approve/spender", map[string]any{
	"network":  "ETH_MAINNET",
	"executor": "oneinch_v6",
})
if err != nil {
	log.Fatal(err)
}
fmt.Println(out["address"])
```

{% endtab %}

{% tab title="Python" %}

```python
out = swap("approve/spender", {"network": "ETH_MAINNET", "executor": "oneinch_v6"})
print(out["address"])
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -s -X POST "https://swap-api.crypto-chief.com/$CC_API_KEY/v1/approve/spender" \
  -H "Content-Type: application/json" \
  -d '{"network":"ETH_MAINNET","executor":"oneinch_v6"}'
```

{% endtab %}
{% endtabs %}

### Which executor

The spender differs per executor: an approval given to one does not cover another. [`/v1/build`](/api-reference/build.md) chooses the executor per route, so there is no default to match. To approve ahead of time, read `executor.id` from a quote with `from_address`, approve for that executor, and pass `executors: ["<id>"]` on the builds so the choice stays fixed. An approval to an executor the build does not pick is unused: the build returns its own `approve` step.

For a `dex_router` route, the router to approve is the build's `executor.address`; name it here as `dex_router:<dex id>`. `/v1/liquidity-sources` lists each DEX router as an entry with id `dex_router`, its own `address` and a name after the DEX.
