---
updatedAt: 2026-04-22T18:44:05.000Z
agentTools:
  projectIndex: https://fuul.readme.io/llms.txt
---

# Create Affiliate Code

Creates a new affiliate code for a user, enabling them to earn commissions on referred user activity.

## When to Use This Endpoint

- Onboarding new affiliates into your program
- Allowing users to become affiliates through self-service signup
- Migrating existing affiliates from another system
- Creating affiliate codes programmatically during user registration

## When NOT to Use This Endpoint

- Updating existing affiliate codes (use PUT /v1/affiliates/{userIdentifier})
- Checking if code is available (use GET /v1/affiliates/codes/{code}/availability)
- Creating referral codes for end-users (use POST /v1/referral_codes)

## Important Constraints

- **Signature Required**: Must provide valid signature proving address ownership
- **Code Format**: Letters, numbers, and dashes only (auto-generated from name if not provided)
- **Uniqueness**: Code must be unique across entire project
- **Name Required**: Affiliate name is mandatory
- **XRPL Signatures**: Must provide `signature_public_key` for XRPL addresses

## Signature Verification

Message to sign: `"I confirm that I am creating the ${code} code"`

Examples:
- EVM: Sign with wallet (ethers.js, web3.js, viem)
- Solana: Sign with Phantom/Solflare wallet
- XRPL: Sign with XRPL wallet (include public key)

## Code Generation

If `code` not provided:
- Auto-generated from `name` parameter
- Spaces → dashes
- Special characters removed
- Example: "John Doe" → "john-doe"

## Common Errors

- **400 Bad Request**:
  - Invalid signature
  - Code already exists (try different code)
  - Invalid user identifier format
  - Invalid code format (must be alphanumeric with dashes)
- **403 Forbidden**: API key lacks required permissions

## Best Practices

- Validate signature client-side before API call
- Check code availability first using GET /v1/affiliates/codes/{code}/availability
- Provide clear code naming guidelines to affiliates
- Store affiliate info locally for faster lookups

## Related Endpoints

- GET /v1/affiliates/codes/{code}/availability - Check if code exists
- PUT /v1/affiliates/{userIdentifier} - Update affiliate code
- GET /v1/affiliates/{userIdentifier} - Get affiliate data


# OpenAPI definition

````json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Fuul API",
    "version": "1.0.0",
    "description": "# Fuul API\n\nFuul is a Web3 growth and affiliate marketing platform that enables projects\nto track referrals, manage affiliate programs, and distribute rewards across\nmultiple blockchain networks (EVM, Solana, XRPL, Sui).\n\n## Core Concepts\n\n### Events\nEvents track user actions (conversions) that trigger rewards. Send events\nwhen users complete valuable actions like trades, deposits, or purchases.\n\n### Affiliates\nAffiliates are partners who promote your project. They receive unique codes\nand earn commissions on referred user activity.\n\n### Referral Codes\nEnd-users can generate referral codes to share with friends. Both referrer\nand referee can earn rewards.\n\n### Payouts\nRewards earned through the affiliate/referral program. Can be claimed\non-chain or tracked as points.\n\n## Authentication\n\n### API Keys\nAPI keys are bound to a single project. Include in the Authorization header:\n```\nAuthorization: Bearer YOUR_API_KEY\n```\n\n## Multi-Chain Support\n\nFuul supports multiple blockchain networks. When identifying users, specify:\n- `user_identifier`: The wallet address, email, or opaque UUID\n- `user_identifier_type`: `evm_address` | `solana_address` | `sui_address` | `xrpl_address` | `stellar_address` | `email` | `uuid`\n\n## Smart Contracts\n\nFuul is an on-chain affiliate protocol. The API works in conjunction with\nsmart contracts deployed across multiple EVM networks.\n\n### Contract Architecture\n\n- **FuulManager**: Central contract that handles attributions and claims.\n  Deployed once per network.\n\n- **FuulFactory**: Creates new FuulProject contracts for each project.\n\n- **FuulProject**: Per-project contracts that hold deposited funds and\n  execute payouts. Address returned when creating a project.\n\nFor contract addresses per network, see:\nhttps://docs.fuul.xyz/protocol/smart-contracts\n\n### Claim Flow\n\n1. User earns rewards through referral/affiliate activity\n2. Call `GET /v1/claim-checks/totals` to see claimable amounts\n3. Call `POST /v1/claim-checks/claim` to get a signed claim message\n4. User submits the signature to `FuulManager.claim()` on-chain\n5. Funds are transferred from FuulProject to user's wallet\n\n### Resources\n\n- [Smart Contract Addresses](https://docs.fuul.xyz/protocol/smart-contracts)\n- [Protocol Contracts Source Code](https://github.com/fuul-protocol/protocol-contracts)\n- [Subgraphs](https://docs.fuul.xyz/protocol/subgraphs)\n\n## Rate Limits\n\n- Standard endpoints: 100 requests/minute\n- Batch endpoints: 10 requests/minute\n- Leaderboard endpoints: 60 requests/minute (cached for 1 minute)\n"
  },
  "servers": [
    {
      "url": "https://api.fuul.xyz/api"
    }
  ],
  "components": {
    "responses": {
      "BadRequest": {
        "description": "Bad Request - Invalid request parameters or malformed request body",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "invalid_identifier": {
                "summary": "Invalid user identifier format",
                "value": {
                  "statusCode": 400,
                  "message": "Invalid user identifier format",
                  "error": "Bad Request"
                }
              },
              "missing_field": {
                "summary": "Missing required field",
                "value": {
                  "statusCode": 400,
                  "message": "Missing required field 'dedup_id'",
                  "error": "Bad Request"
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized - Missing or invalid API key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "missing_key": {
                "summary": "Missing API key",
                "value": {
                  "statusCode": 401,
                  "message": "Missing authorization header",
                  "error": "Unauthorized"
                }
              },
              "invalid_key": {
                "summary": "Invalid API key",
                "value": {
                  "statusCode": 401,
                  "message": "Invalid API key",
                  "error": "Unauthorized"
                }
              }
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflict - Resource already exists or conflicts with existing state",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "duplicate_event": {
                "summary": "Event already exists",
                "value": {
                  "statusCode": 409,
                  "message": "Event with this dedup_id already exists",
                  "error": "Conflict"
                }
              },
              "duplicate_code": {
                "summary": "Code already exists",
                "value": {
                  "statusCode": 409,
                  "message": "Affiliate code already exists",
                  "error": "Conflict"
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Too Many Requests - Rate limit exceeded",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "rate_limit": {
                "summary": "Rate limit exceeded",
                "value": {
                  "statusCode": 429,
                  "message": "Rate limit exceeded. Maximum 100 requests per minute.",
                  "error": "Too Many Requests"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "IdentifierType": {
        "type": "string",
        "enum": [
          "evm_address",
          "solana_address",
          "sui_address",
          "xrpl_address",
          "stellar_address",
          "email",
          "uuid"
        ],
        "example": "evm_address",
        "description": "The type of identifier being used for identifying the user."
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "description": "HTTP status code",
            "example": 400
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message",
            "example": "Invalid user identifier format"
          },
          "error": {
            "type": "string",
            "description": "Error type or category",
            "example": "Bad Request"
          }
        },
        "description": "Standard error response structure returned by all endpoints"
      },
      "CreateAffiliateCodeRequest": {
        "type": "object",
        "required": [
          "user_identifier",
          "identifier_type",
          "name",
          "signature"
        ],
        "properties": {
          "user_identifier": {
            "type": "string",
            "example": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "description": "The identifier of the affiliate (address for EVM/Solana or XRPL address).\n"
          },
          "identifier_type": {
            "$ref": "#/components/schemas/IdentifierType"
          },
          "address": {
            "type": "string",
            "example": "0xBfBAdD58B65B54D1a5cEa6d9c730fbd57c182d32",
            "description": "(Deprecated) The address of the affiliate. Use user_identifier instead.\n"
          },
          "name": {
            "type": "string",
            "example": "John Doe",
            "description": "The name of the affiliate\n"
          },
          "signature": {
            "type": "string",
            "example": "signature",
            "description": "The signature of the affiliate address. Message to be signed: \"I confirm that I am creating the ${code} code\".\n"
          },
          "signature_public_key": {
            "type": "string",
            "example": "ED01FC8A43B7A1A85BD19EB73B4C6A66A91A7B6F8B8F8D5F8B8F8D5F8B8F8D5F",
            "description": "The public key used for signature verification (required for XRPL signatures).\n"
          },
          "code": {
            "type": "string",
            "example": "johndoe",
            "description": "The affiliate code to be created. If not present, it's automatically generated from the affiliate name. Can only contain letters, numbers, and dashes.\n"
          },
          "email": {
            "type": "string",
            "example": "john.doe@email.com",
            "description": "The email of the affiliate\n"
          },
          "website": {
            "type": "string",
            "example": "https://www.myblog.com",
            "description": "The website of the affiliate\n"
          },
          "social_media_url": {
            "type": "string",
            "example": "https://twitter.com/johndoe",
            "description": "The social media url of the affiliate\n"
          },
          "content_type": {
            "type": "string",
            "enum": [
              "educational_content",
              "social_influencer",
              "display_ads",
              "aggregator",
              "podcast"
            ],
            "example": "podcast",
            "description": "The content type of the affiliate\n"
          },
          "language": {
            "type": "string",
            "enum": [
              "english",
              "spanish",
              "chinese",
              "turkish",
              "portuguese"
            ],
            "example": "english",
            "description": "The language of the affiliate\n"
          }
        }
      }
    }
  },
  "paths": {
    "/v1/affiliates": {
      "post": {
        "operationId": "createAffiliateCode",
        "summary": "Create Affiliate Code",
        "description": "Creates a new affiliate code for a user, enabling them to earn commissions on referred user activity.\n\n## When to Use This Endpoint\n\n- Onboarding new affiliates into your program\n- Allowing users to become affiliates through self-service signup\n- Migrating existing affiliates from another system\n- Creating affiliate codes programmatically during user registration\n\n## When NOT to Use This Endpoint\n\n- Updating existing affiliate codes (use PUT /v1/affiliates/{userIdentifier})\n- Checking if code is available (use GET /v1/affiliates/codes/{code}/availability)\n- Creating referral codes for end-users (use POST /v1/referral_codes)\n\n## Important Constraints\n\n- **Signature Required**: Must provide valid signature proving address ownership\n- **Code Format**: Letters, numbers, and dashes only (auto-generated from name if not provided)\n- **Uniqueness**: Code must be unique across entire project\n- **Name Required**: Affiliate name is mandatory\n- **XRPL Signatures**: Must provide `signature_public_key` for XRPL addresses\n\n## Signature Verification\n\nMessage to sign: `\"I confirm that I am creating the ${code} code\"`\n\nExamples:\n- EVM: Sign with wallet (ethers.js, web3.js, viem)\n- Solana: Sign with Phantom/Solflare wallet\n- XRPL: Sign with XRPL wallet (include public key)\n\n## Code Generation\n\nIf `code` not provided:\n- Auto-generated from `name` parameter\n- Spaces → dashes\n- Special characters removed\n- Example: \"John Doe\" → \"john-doe\"\n\n## Common Errors\n\n- **400 Bad Request**:\n  - Invalid signature\n  - Code already exists (try different code)\n  - Invalid user identifier format\n  - Invalid code format (must be alphanumeric with dashes)\n- **403 Forbidden**: API key lacks required permissions\n\n## Best Practices\n\n- Validate signature client-side before API call\n- Check code availability first using GET /v1/affiliates/codes/{code}/availability\n- Provide clear code naming guidelines to affiliates\n- Store affiliate info locally for faster lookups\n\n## Related Endpoints\n\n- GET /v1/affiliates/codes/{code}/availability - Check if code exists\n- PUT /v1/affiliates/{userIdentifier} - Update affiliate code\n- GET /v1/affiliates/{userIdentifier} - Get affiliate data\n",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAffiliateCodeRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "tags": [
          "Affiliates"
        ]
      }
    }
  }
}
````