# check_affiliate_code

Source: https://modulify.ai/docs/api/account/check-affiliate-code

Checks whether a referral code is free before you claim it.

- Title: Check a referral code is free
- Scope: `account:read`
- Access: Read only
- Endpoint: `POST /v1/check_affiliate_code`

Codes are unique across Modulify, so a code somebody else holds is reported as taken. Always check before setting one with `update_affiliate`, because a code cannot be changed once a referral has used it.

A free code answers `ok` with `Affiliate code is available.`, and a taken one `not-ok` with `Affiliate code is not available.` A code must be 3 to 12 letters and digits, and anything else is refused with `Code is not valid, please check again!` It acts only for the account the token belongs to and needs no workspace. See [Affiliates](https://modulify.ai/docs/plans/affiliates#change-your-code-or-your-payout-email).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/check_affiliate_code`, sending the inputs below as a JSON object. The token needs the `account:read` scope.

It only reads and changes nothing, so retrying it is safe.

```bash
curl -X POST https://api.modulify.ai/v1/check_affiliate_code \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"code":"CODE"}'
```

Over MCP, the same method is the [check_affiliate_code tool](https://modulify.ai/docs/mcp/account/check-affiliate-code).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string | Yes | The code to test, 3 to 12 letters and digits. It is compared in lowercase. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.