> ## Documentation Index
> Fetch the complete documentation index at: https://docs.afkcrypto.com/llms.txt
> Use this file to discover all available pages before exploring further.

# トークン承認（EVM）

> EVM 上で ERC20 の allowance を承認します（POST）。

<Note>
  EVM のみ。`Idempotency-Key` ヘッダーが必要です。
</Note>

<ResponseExample>
  ```json 200 theme={null}
  { "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://basescan.org/tx/0x...", "chainName": "Base" }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /token/approve
openapi: 3.1.0
info:
  title: AFK Crypto API
  description: >-
    AFK Crypto - Non-custodial wallet automation. Simple REST APIs for EVM and
    Solana.
  version: 1.0.0
servers:
  - url: https://api.afkcrypto.com/v1
    description: Production
security:
  - apiKeyAuth: []
paths:
  /token/approve:
    post:
      summary: Approve ERC20 allowance (EVM)
      description: Approve ERC20 allowance on EVM.
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            format: uuid
          description: >-
            Provide a unique Idempotency-Key per user to ensure single
            submission.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApproveRequest'
      responses:
        '200':
          description: Submission accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmissionResponse'
          headers:
            x-request-id:
              $ref: '#/components/headers/XRequestId'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            x-request-id:
              $ref: '#/components/headers/XRequestId'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            x-request-id:
              $ref: '#/components/headers/XRequestId'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            x-request-id:
              $ref: '#/components/headers/XRequestId'
            Retry-After:
              schema:
                type: integer
              description: Seconds until next window
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  schemas:
    ApproveRequest:
      type: object
      properties:
        chain:
          type: string
          description: EVM chain slug.
        from:
          type:
            - string
            - 'null'
          description: >-
            Optional sender wallet; defaults to user's default wallet for the
            chain.
        token:
          type: string
          description: ERC20 token address to approve.
        spender:
          type: string
          description: Spender (router) address to approve.
        amount:
          type: string
          description: Allowance amount in token units (uint256 string).
      required:
        - chain
        - token
        - spender
        - amount
    SubmissionResponse:
      type: object
      properties:
        id:
          type: string
          description: AFK transaction id for the submitted action.
        status:
          type: string
          enum:
            - SUBMITTED
          description: Submission status.
        hash:
          type:
            - string
            - 'null'
          description: >-
            On-chain transaction hash/signature (may be null at submission
            time).
        explorerUrl:
          type:
            - string
            - 'null'
          description: >-
            Direct link to the transaction on a chain explorer. Null until a
            hash/signature exists.
        chainName:
          type: string
          description: >-
            Human-readable chain name for display (e.g., Base, Ethereum,
            Solana).
      required:
        - id
        - status
        - hash
        - explorerUrl
        - chainName
    ApiError:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
        code:
          type: string
          enum:
            - FORBIDDEN
            - UNAUTHORIZED
            - RATE_LIMITED
            - INVALID_INPUT
            - WALLET_NOT_FOUND
            - USER_NOT_LINKED
            - WALLET_NOT_DELEGATED
            - WALLET_ID_REQUIRED
            - CHAIN_UNKNOWN
            - IDEMPOTENT_BODY_MISMATCH
            - IDEMPOTENT_REPLAY
            - PRIVY_RPC_ERROR
            - SEND_FAILED
            - SERVICE_UNAVAILABLE
            - QUOTE_FAILED
            - NOT_FOUND
            - INSUFFICIENT_FUNDS
            - INTERNAL_ERROR
          description: Stable error code for programmatic handling.
        requestId:
          type:
            - string
            - 'null'
          description: Unique request identifier (also in x-request-id header).
      required:
        - error
  headers:
    XRequestId:
      description: Unique request identifier
      schema:
        type: string
  responses:
    ErrorResponse:
      description: Error envelope
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
      headers:
        x-request-id:
          $ref: '#/components/headers/XRequestId'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````