> For the complete documentation index, see [llms.txt](https://docs.afx.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.afx.xyz/api-reference/exchange/referral.md).

# Referral

## Bind Referral

> Bind a referral code to the account.\
> \
> \*\*Signature:\*\* Agent · \*\*Protobuf:\*\* \`MsgBindReferral\`\
> \
> \`\`\`protobuf\
> // package: dex.offchain.referral.v1\
> message MsgBindReferral {\
> &#x20; string referral\_code = 1;\
> }\
> \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"AFX DEX Exchange API","version":"1.0.0"},"servers":[{"url":"https://api.afx.xyz","description":"Mainnet"},{"url":"https://api-testnet.afx.xyz","description":"Testnet"}],"paths":{"/exchange/bindReferral":{"post":{"operationId":"bindReferral","summary":"Bind Referral","tags":["Referral"],"description":"Bind a referral code to the account.\n\n**Signature:** Agent · **Protobuf:** `MsgBindReferral`\n\n```protobuf\n// package: dex.offchain.referral.v1\nmessage MsgBindReferral {\n  string referral_code = 1;\n}\n```\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BindReferralRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/ExchangeOk"}}}}},"components":{"schemas":{"BindReferralRequest":{"type":"object","required":["action","signature","nonce"],"properties":{"action":{"type":"object","required":["type","referralCode"],"properties":{"type":{"type":"string","enum":["bindReferral"]},"referralCode":{"type":"string"}}},"signature":{"$ref":"#/components/schemas/Signature"},"nonce":{"type":"integer","format":"int64","description":"Request nonce as a Unix timestamp in milliseconds. Recommended: current time in milliseconds. Must be unique; do not reuse the same nonce for another signed request."}}},"Signature":{"type":"object","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex, zero-padded to 64 chars"},"s":{"type":"string","description":"32-byte hex, zero-padded to 64 chars"},"v":{"type":"integer","description":"27 or 28"}}},"ExchangeResponse":{"type":"object","properties":{"code":{"type":"integer","description":"`0` = success. See Error Codes section for non-zero values."},"message":{"type":"string"},"data":{"type":"object","nullable":true,"properties":{"txHash":{"type":"string"},"txCode":{"type":"integer"},"txMsg":{"type":"string"}}}}}},"responses":{"ExchangeOk":{"description":"Transaction submitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExchangeResponse"}}}}}}}
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.afx.xyz/api-reference/exchange/referral.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.
