# Claiming a generated code

Generate a code and an authentication code so a creator can claim it to their Nexus account.

Claiming a generated code associates it with a Nexus account, allowing the creator to manage the code themselves.

You can create an authentication code for any code you have generated and manage. The creator then uses this authentication code to go through the account claim process, linking the generated code to their Nexus account. The creator does not need a Nexus account already. The process prompts them to sign up.

The claim process has two steps: generate a code for the creator, then generate an authentication code they can redeem.

## Generate a code

First, generate a code for the creator with this route:

<ApiMethod method="POST" path="/manage/members" />
<LinkCard title="View full reference" description="Parameters, responses, and status codes." href="/api/operations/generatemember/" />

Here's how you call that with `curl`:

```bash
curl -X 'POST' \
  'https://api.nexus.gg/v1/manage/members' \
  -H 'accept: application/json' \
  -H 'X-SHARED-SECRET: nexus_sk_your_key_here' \
  -d '{
    "playerId": "abcd-123-efg",
    "playerMetadata": {
      "displayName": "Popcorn Frog"
    }
  }'
```

The status should be `200 OK` with a JSON response body that looks something like this:

```json
{
  "groupId": "CsRKC8uD0NLtyQ0LOt8Ru",
  "groupName": "Test Group",
  "playerId": "abcd-123-efg",
  "playerMetadata": {
    "displayName": "Popcorn Frog"
  },
  "code": "8ris29f"
}
```

The timing of when you generate a code and how you display it to the creator is up to you. You may do this automatically when they visit your Support-a-Creator Program page in your application or website, or you may require the creator to opt-in before generating a code.

Once you generate a code, you manage it until the creator links it to a Nexus account.

## Generate an authentication code

Again, how you present the creator with the ability to generate an authentication code is up to you. The code expires after 30 minutes, and a single use invalidates it, so generate it as needed.

To generate an authentication code, use this route:

<ApiMethod method="GET" path="/manage/members/{playerId}/authCode" />
<LinkCard title="View full reference" description="Parameters, responses, and status codes." href="/api/operations/generateauthcode/" />

Here's how you call that with `curl`:

```bash
curl -X 'GET' \
  'https://api.nexus.gg/v1/manage/members/abcd-123-efg/authCode' \
  -H 'accept: application/json' \
  -H 'X-SHARED-SECRET: nexus_sk_your_key_here'
```

The status should be `200 OK` with a JSON response body that looks something like this:

```json
{
  "authCode": "495-109",
  "expiresAt": "2022-09-29T21:30:25.400Z"
}
```

Give the creator the generated `authCode` and send them to `https://www.nexus.gg/referral-link`, which prompts them to enter the code and sign in or sign up. You can also link the creator directly to their unique authentication code (example: `https://www.nexus.gg/referral-link/495-109`) instead of having them copy/paste the code.

A new Nexus user goes through Nexus registration, where they can choose their own Support-a-Creator code. The generated code they claimed stays active, and retrieving the creator's referral info returns both the generated and Support-a-Creator codes.

## Next steps

<LinkCard title="Retrieving your members" description="Look up a member's codes and referral info after they claim." href="/creator-code-api/program-management/retrieving-your-members/" />
<LinkCard title="Generating codes for your program" description="Generate and link codes for the creators in your program." href="/creator-code-api/program-management/adding-codes-to-your-program/" />
