# Referrals

Referral codes are a core primitive of Spindl's referral program. Each wallet can create one unique code, that can be shared via the `ref` tag on URLs. Codes can be custom or random, depending on your ideal app experience.

For instance, a shareable link might look:

```
https://app.mydapp.xyz/trade?ref=kunal
                                 ^ referral code
```

The Spindl SDK will automatically capture `ref` URL parameters in Page View events to associate visits with Referrers.​

Referral codes can be created manually through the [Spindl Dashboard](https://app.spindl.xyz/referrals), or programmatically from your app with the Javascript SDK.​

### &#x20;<a href="#get-referrer-code" id="get-referrer-code"></a>

### Get Referrer Code <a href="#get-referrer-code" id="get-referrer-code"></a>

This method can be used to see if a wallet already has a code associated with it.

**SDK Method**

```typescript
getReferrerCode(address: string): Promise<string | undefined>
```

**Parameters**

* Address: The wallet address

**Returns**

A referral code if set​

### &#x20;<a href="#create-referrer-code" id="create-referrer-code"></a>

### Create Referrer Code <a href="#create-referrer-code" id="create-referrer-code"></a>

**SDK Method**

```typescript
createReferrerCode(address: string, code?: string): Promise<string>
```

**Parameters**

* Address: The wallet address
* Code: An optional custom referral code to use. If not set, we'll generate a random code

**Returns**

This will throw a 400 error if the code is invalid / in-use, or the wallet address already has a referral code

#### **​** <a href="#undefined" id="undefined"></a>

### **Validate Referrer Code** <a href="#validate-referrer-code" id="validate-referrer-code"></a>

This method can be used to quickly verify if a code is valid (it doesn't make network calls, so can be called on keystrokes / input changes efficiently)

**SDK Method**

```typescript
validateReferrerCode(code: string): boolean;
```

**Parameters**

* Code: A custom short code, to validate

**Returns**

Returns true if the code is valid.

### Check Referrer Code

This method can be used to see if a custom code is already in use.

**SDK Method**

```typescript
checkReferrerCode(code: string): Promise<boolean>;
```

**Parameters**

* Code: A custom short code, to check if it is available

**Returns**

Returns true if the code is available, false if it is not valid or unavailable


---

# 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.spindl.xyz/spindl/techncial/javascript-sdk-html-script-guide/referrals.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.
