---
title: "Redeem key"
icon : "api"
description: "Claim an unused key for a Discord user, or bind a Discord ID onto an unowned claimed key."
---

# Redeem key

<Endpoint
  method="POST"
  path  ="https://api.envyauth.my.id/api/v3/projects/:project_uuid/users/redeem"
/>

Atomically claims a key on behalf of a Discord user. If the key is in the project's unused pool, it moves to the user list and binds to the Discord ID. If the key is already claimed but has no Discord ID, the Discord ID is attached to that existing row.

One key per Discord ID per project is enforced. A Discord ID that already has a key returns `409` with `code: "ALREADY_HAS_KEY"`.

## Request

```bash
curl -X POST https://api.envyauth.my.id/api/v3/projects/<project_uuid>/users/redeem \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"discord_id":"1118453649727823974","key":"<32-char>"}'
```

| Field | Type | Required | Meaning |
|---|---|---|---|
| `discord_id` | string | yes | 17–20 digit Discord snowflake. |
| `key` | string | yes | 32-character key to redeem. |

The Discord username and avatar are resolved server-side; you do not need to pass them.

## Response

<CodeGroup tabs={[
  {
    title: '200 OK · Unclaimed claim',
    lang : 'json',
    code : '{\n  "success": true,\n  "data": {\n    "redeemed":   true,\n    "stage":      "unclaimed_claim",\n    "user_id":    "uuid",\n    "key":        "<32-char>",\n    "key_note":   "Premium",\n    "key_expire": 1761868800\n  },\n  "requestid": "uuid"\n}',
  },
  {
    title: '200 OK · Claimed bind',
    lang : 'json',
    code : '{\n  "success": true,\n  "data": {\n    "redeemed":   true,\n    "stage":      "claimed_bind",\n    "user_id":    "uuid",\n    "key":        "<32-char>",\n    "key_note":   "Premium",\n    "key_expire": 1761868800\n  },\n  "requestid": "uuid"\n}',
  },
  {
    title: '409 Already',
    lang : 'json',
    code : '{\n  "success": false,\n  "error": "This Discord user already has a key in this project",\n  "code":  "ALREADY_HAS_KEY",\n  "requestid": "uuid"\n}',
  },
  {
    title: '410 Expired',
    lang : 'json',
    code : '{\n  "success": false,\n  "error": "Key has expired",\n  "code":  "EXPIRED",\n  "requestid": "uuid"\n}',
  },
  {
    title: '404 Not Found',
    lang : 'json',
    code : '{\n  "success": false,\n  "error": "Key not found in this project",\n  "code":  "NOT_FOUND",\n  "requestid": "uuid"\n}',
  },
  {
    title: '422 Validation',
    lang : 'json',
    code : '{\n  "success": false,\n  "error": "Invalid discord_id format",\n  "code":  "VALIDATION",\n  "requestid": "uuid"\n}',
  },
]} />

`stage` is one of:

| Stage | Meaning |
|---|---|
| `unclaimed_claim` | The key was in the unused pool and is now a user row bound to the Discord ID. |
| `claimed_bind` | The key was already a claimed row with no Discord ID. The Discord ID has now been attached. |
