# One Click Flow

For API Keys with a bound user wallet address, using server-side delegated trading.

## Authorization Flow

```mermaid
sequenceDiagram
    participant User
    participant Client
    participant API
    participant Chain

    Client->>API: GET /1ct/status
    API-->>Client: { status: "disabled" }
    Client->>API: POST /1ct/prepare { deadline }
    API-->>Client: signPayload (EIP-712)
    Client->>User: Request signature
    User->>Client: signature (65 bytes)
    Client->>API: POST /1ct/enable { signature, deadline }
    API->>Chain: delegateBySig
    API-->>Client: { status: "enable" }
```

## Steps

1. Call `GET /api/v1/1ct/status` to check authorization status.
2. If disabled, call `POST /api/v1/1ct/prepare` to get `signPayload`.
3. User wallet performs **EIP-712 signing** on `signPayload`.
4. Call `POST /api/v1/1ct/enable` to submit the signature and enable One Click.
5. Call `/send` endpoints for specific operations.

## Available Send Endpoints

| Operation    | Endpoint                               |
| ------------ | -------------------------------------- |
| Place Order  | `POST /api/v1/orders/send`             |
| Cancel Order | `DELETE /api/v1/orders/{orderId}/send` |
| Deposit      | `POST /api/v1/cash/deposits/send`      |
| Withdraw     | `POST /api/v1/cash/withdrawals/send`   |

## Deposit Prerequisite

> \[!IMPORTANT] The user wallet must first execute an ERC-20 `approve` on the cash token.

The approval owner is the actual depositing user address:

* Using `/cash/deposits/send`: API Key's bound `userAddress`
* Using `/cash/deposits/calldata` (self-submit): transaction sender's wallet address

See [Cash Operations - Deposit Pre-Authorization](https://github.com/AnchoredLabs/anchored-gitbook/blob/main/en/api/cash-operations/README.md#deposit-pre-authorization) for mainnet spender addresses.


---

# 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.anchored.finance/trading-api-docs-en/integration/one-click-flow.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.
