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

# Approve token transfer

> Set up a one-time Permit2 allowance for gas-sponsored token transfers.

Required when using [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account) with `gas_sponsorship=true`. This allowance only needs to be set up once per token.

**With gas sponsorship (`gas_sponsorship=true`):**
- Returns EIP-712 typed data for the owner to sign off-chain
- Submit signature + typed data to [/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction)
- Only works for tokens that support EIP-2612 permit (e.g., USDC)

Some tokens, like USDT and WETH, do not support EIP-2612 permit. For these tokens, set `gas_sponsorship=false` to receive an unsigned transaction that the owner must sign, submit, and pay gas for.



## OpenAPI

````yaml /v2/combined_spec.json post /v2/gas_sponsorship/approve_transfer
openapi: 3.1.0
info:
  title: Compass API
  description: Compass Labs DeFi API
  version: 0.0.1
servers:
  - url: https://api.compasslabs.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v2/gas_sponsorship/approve_transfer:
    post:
      tags:
        - Gas Sponsorship
      summary: Approve token transfer
      description: >-
        Set up a one-time Permit2 allowance for gas-sponsored token transfers.


        Required when using
        [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account)
        or
        [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account)
        with `gas_sponsorship=true`. This allowance only needs to be set up once
        per token.


        **With gas sponsorship (`gas_sponsorship=true`):**

        - Returns EIP-712 typed data for the owner to sign off-chain

        - Submit signature + typed data to
        [/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction)

        - Only works for tokens that support EIP-2612 permit (e.g., USDC)


        Some tokens, like USDT and WETH, do not support EIP-2612 permit. For
        these tokens, set `gas_sponsorship=false` to receive an unsigned
        transaction that the owner must sign, submit, and pay gas for.
      operationId: v2_gas_sponsorship_approve_transfer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApproveTransferRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApproveTransferResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            from compass_api_sdk import CompassAPI, models


            with CompassAPI(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as compass_api:

                res = compass_api.gas_sponsorship.gas_sponsorship_approve_transfer(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.Chain.BASE, token="USDT", gas_sponsorship=False)

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { CompassApiSDK } from "@compass-labs/api-sdk";

            const compassApiSDK = new CompassApiSDK({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await compassApiSDK.gasSponsorship.gasSponsorshipApproveTransfer({
                owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
                chain: "base",
                token: "USDT",
              });

              console.log(result);
            }

            run();
components:
  schemas:
    ApproveTransferRequest:
      properties:
        owner:
          type: string
          title: Owner
          description: The wallet address that owns the Earn Account.
          default: '0x06A9aF046187895AcFc7258450B15397CAc67400'
          examples:
            - '0x06A9aF046187895AcFc7258450B15397CAc67400'
        chain:
          $ref: '#/components/schemas/Chain'
          description: Blockchain network
          default: base
          examples:
            - base
        token:
          type: string
          title: Token
          description: The token you would like to transfer with gas sponsorship.
          examples:
            - USDC
            - WETH
            - '0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8'
          default: USDT
        gas_sponsorship:
          type: boolean
          title: Gas Sponsorship
          description: >-
            Optionally request gas sponsorship. If set to `true`, EIP-712
            signature data will be returned that must be signed by the `owner`
            and submitted to the `/gas_sponsorship/prepare` endpoint.
          default: false
      type: object
      required:
        - owner
        - chain
        - token
      title: ApproveTransferRequest
      default:
        chain: base
        owner: '0x06A9aF046187895AcFc7258450B15397CAc67400'
        token: USDT
    ApproveTransferResponse:
      properties:
        transaction:
          anyOf:
            - $ref: '#/components/schemas/UnsignedTransaction'
            - type: 'null'
          description: Unsigned approval transaction. Present when gas_sponsorship=false.
        eip_712:
          anyOf:
            - $ref: '#/components/schemas/PermitTypedDataResponse-Output'
            - type: 'null'
          description: >-
            EIP-712 typed data for off-chain permit signing. Present when
            gas_sponsorship=true.
      type: object
      title: ApproveTransferResponse
      example:
        eip_712:
          domain:
            chainId: 8453
            name: USD Coin
            verifyingContract: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
            version: '2'
          message:
            deadline: '1735689600'
            nonce: '0'
            owner: '0x4A83b4413CF41C3244027e1590E35a0F48403F0c'
            spender: '0x000000000022D473030F116dDEE9F6B43aC78BA3'
            value: >-
              115792089237316195423570985008687907853269984665640564039457584007913129639935
          primaryType: Permit
          types:
            EIP712Domain:
              - name: name
                type: string
              - name: version
                type: string
              - name: chainId
                type: uint256
              - name: verifyingContract
                type: address
            Permit:
              - name: owner
                type: address
              - name: spender
                type: address
              - name: value
                type: uint256
              - name: nonce
                type: uint256
              - name: deadline
                type: uint256
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Chain:
      type: string
      enum:
        - base
        - ethereum
        - arbitrum
        - hyperevm
        - tempo
      title: Chain
      description: The chain to use.
    UnsignedTransaction:
      properties:
        chainId:
          type: string
          title: Chainid
          description: The chain id of the transaction
        data:
          type: string
          title: Data
          description: The data of the transaction
        from:
          type: string
          title: From
          description: The sender of the transaction
        gas:
          anyOf:
            - type: string
            - type: 'null'
          title: Gas
          description: The gas of the transaction
        to:
          type: string
          title: To
          description: The recipient of the transaction
        value:
          type: string
          title: Value
          description: The value of the transaction
        nonce:
          type: string
          title: Nonce
          description: The nonce of the address
        maxFeePerGas:
          type: string
          title: Maxfeepergas
          description: The max fee per gas of the transaction
        maxPriorityFeePerGas:
          type: string
          title: Maxpriorityfeepergas
          description: The max priority fee per gas of the transaction
      type: object
      required:
        - chainId
        - data
        - from
        - gas
        - to
        - value
        - nonce
        - maxFeePerGas
        - maxPriorityFeePerGas
      title: UnsignedTransaction
      example:
        chainId: '0x2105'
        data: >-
          0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d
        from: '0x4A83b4413CF41C3244027e1590E35a0F48403F0c'
        gas: '0x7a120'
        maxFeePerGas: '0x59682f00'
        maxPriorityFeePerGas: '0x3b9aca00'
        nonce: '0x5'
        to: '0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67'
        value: '0x0'
    PermitTypedDataResponse-Output:
      properties:
        domain:
          $ref: >-
            #/components/schemas/compass__api_backend__v2__models__gas_sponsorship__permit_typed_data__EIP712Domain
          description: EIP-712 domain separator
        types:
          $ref: >-
            #/components/schemas/compass__api_backend__v2__models__gas_sponsorship__permit_typed_data__EIP712Types
          description: EIP-712 type definitions
        primaryType:
          type: string
          const: Permit
          title: Primarytype
          description: Primary type for the structured data
        message:
          $ref: '#/components/schemas/PermitMessage'
          description: Permit message data
      type: object
      required:
        - domain
        - types
        - primaryType
        - message
      title: PermitTypedDataResponse
      description: Response containing EIP-712 typed data for ERC-20 Permit signing.
      example:
        domain:
          chainId: 8453
          name: USD Coin
          verifyingContract: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
          version: '2'
        message:
          deadline: '1735689600'
          nonce: '0'
          owner: '0x4A83b4413CF41C3244027e1590E35a0F48403F0c'
          spender: '0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1'
          value: '100000000'
        primaryType: Permit
        types:
          EIP712Domain:
            - name: name
              type: string
            - name: version
              type: string
            - name: chainId
              type: uint256
            - name: verifyingContract
              type: address
          Permit:
            - name: owner
              type: address
            - name: spender
              type: address
            - name: value
              type: uint256
            - name: nonce
              type: uint256
            - name: deadline
              type: uint256
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    compass__api_backend__v2__models__gas_sponsorship__permit_typed_data__EIP712Domain:
      properties:
        name:
          type: string
          title: Name
          description: Token name
        version:
          type: string
          title: Version
          description: Token version (usually '1' or '2')
        chainId:
          type: integer
          title: Chainid
          description: Chain ID
        verifyingContract:
          type: string
          title: Verifyingcontract
          description: Token contract address
      type: object
      required:
        - name
        - version
        - chainId
        - verifyingContract
      title: EIP712Domain
      description: The EIP-712 domain separator for ERC-20 Permit.
    compass__api_backend__v2__models__gas_sponsorship__permit_typed_data__EIP712Types:
      properties:
        EIP712Domain:
          items:
            $ref: '#/components/schemas/EIP712DomainField'
          type: array
          title: Eip712Domain
          description: EIP712Domain type definition
        Permit:
          items:
            $ref: '#/components/schemas/PermitField'
          type: array
          title: Permit
          description: Permit type definition
      type: object
      required:
        - EIP712Domain
        - Permit
      title: EIP712Types
      description: The type definitions for EIP-712 structured data (ERC-20 Permit).
    PermitMessage:
      properties:
        owner:
          type: string
          title: Owner
          description: Token owner address
        spender:
          type: string
          title: Spender
          description: Address authorized to spend tokens
        value:
          type: string
          title: Value
          description: Amount to approve (as string)
        nonce:
          type: string
          title: Nonce
          description: Current permit nonce for the owner
        deadline:
          type: string
          title: Deadline
          description: Permit expiry timestamp
      type: object
      required:
        - owner
        - spender
        - value
        - nonce
        - deadline
      title: PermitMessage
      description: The message data for an ERC-20 Permit.
    EIP712DomainField:
      properties:
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
      type: object
      required:
        - name
        - type
      title: EIP712DomainField
      description: A field in the EIP712Domain type definition.
    PermitField:
      properties:
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
      type: object
      required:
        - name
        - type
      title: PermitField
      description: A field in the Permit type definition.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````