---
title: 'Create referral code'
description: 'This endpoint allows you to create a referral code'
openapi: POST /api/referral/codes
---

> **For AI agents:** the complete documentation index is at [llms.txt](https://docs.snagsolutions.io/llms.txt). Append `.md` to any page URL for its markdown version.

`POST /api/referral/codes`

`POST https://admin.snagsolutions.io/api/referral/codes`

This endpoint allows you to create a referral code

## Authentication

- `apiKeyAuth` — apiKey in header: `X-API-KEY`

## Request body

- Content type: `application/json`
  - request body (object)
    - `websiteId` (string, uuid)
    - `organizationId` (string, uuid)
    - `userId` (string, uuid)
    - `loyaltyRuleId` (string, uuid, required)
    - `customReferralCode` (string)

## Response 200

200
  - response (object)
    - `id` (string, required)
    - `websiteId` (string, required)
    - `organizationId` (string, required)
    - `referralCode` (string, required)
    - `createdAt` (string, date-time, required)
    - `updatedAt` (string, date-time, required)
    - `deletedAt` (string, date-time, required)
    - `userId` (string, required)

## Response 403

403
  - response (object) — Schema for forbidden response
    - `message` (string, required) — Error message


---

📦 **OpenAPI specs:** Every OpenAPI specification referenced by this documentation is available as a single download — https://docs.snagsolutions.io/api-specs.zip
