# Generate code

`POST https://api.nexus.gg/v1/manage/members`

Creates a creator code for one of your players and returns it.

You mint the code first, against a `playerId` you already have, and the creator claims it later through the link workflow. The code attributes from the moment it exists, so sales earn against it while it is still unclaimed.

That fits programs where the content comes before the creator relationship: generate a code alongside every user-made level, for example, and sales on that level are already attributed if and when its author signs up.

Call it once per player. If that `playerId` already has a code in the group, the existing code is returned instead of a second one being created, so the call is safe to retry.

A new code is seven lowercase letters and digits (for example `k3m9x2p`). Until it is claimed the code is publisher-managed: you own it, and it belongs to no Nexus account. If the player has already linked a Nexus account to your group, the new code is attached to that account instead.

This method authenticates with a **secret** (`nexus_sk_...`) key.

## Authorizations

- `X-SHARED-SECRET` (string, header, required) - Send your **secret** API key (`nexus_sk_...`) in the `X-SHARED-SECRET` header. [Generate one](/authentication/api-keys/) in the Publisher Dashboard.

## Query parameters

- `groupId` (string) - Creator group.

## Request body (`application/x-www-form-urlencoded`)

- `playerId` (string, required) - Your own identifier for the player the code is created for. Reuse the same value to look the player up later.
- `playerMetadata` (object) - Additional player information to be applied to this member (such as their in game display name)

## Responses

### 200

The player's creator code, together with the group it belongs to. Returned whether the code was created by this call or already existed.

#### Body (`application/json`)

- `groupId` (string) - ID of the creator group
- `groupName` (string) - Name of the creator group
- `playerId` (string) - Unique Identifier provided when this code was created
- `playerMetadata` (object) - Additional player information to be applied to this member (such as their in game display name)
- `code` (string) - The creator code. Seven lowercase letters and digits.

### 400

The request could not be fulfilled. Either `playerId` was missing, or `groupId` did not match a creator group on your publisher account. Branch on `code`, not on `message`.

#### Body (`application/json`)

- `code` (string) - CodeNotInGroup: Creator group is private, and specified code is not linked to it<br /> InvalidGroup: No creator group was found with the specified groupId<br/> InvalidAuthCode: AuthCode provided is not valid or the nexus it represents is not a member of your program<br/> ExpiredAuthCode: AuchCode provided has expired<br/> NexusNotFound: No Nexus was found to match the provided code<br/> PlayerNotInGroup: No group member found for the given playerId<br/> PlayerAlreadyLinked: The playerId provided has already been linked with a group member<br/> MemberAlreadyLinked: The nexus represented by the auth code specified is already a member of your group and has been linked with a different playerId. Allowed values: InvalidGroup, CodeNotInGroup, InvalidAuthCode, ExpiredAuthCode, NexusNotFound, PlayerNotInGroup, UnknownError, PlayerAlreadyLinked, MemberAlreadyLinked.
- `message` (string) - A human-readable explanation. Log it; do not match on it, as the wording can change. Branch on `code` instead.
