AppMage

Invite Code Management

This endpoint group provides methods for managing invite codes, allowing for listing, creation, updating, and deletion of codes used for various purposes within the application.

Endpoints

POST /api/rpc (Method: InviteCodeRpc.getData)

  • Description: Lists invite codes.

  • Request Body:

    {
      "method": "InviteCodeRpc.getData",
      "params": {
        "filter": {},
        "sort": {},
        "page": 1,
        "pageSize": 25
      }
    }
  • Parameters:

    Name Type Required Description
    filter Object No An object to filter the invite codes.
    sort Object No An object to specify the sorting order.
    page Number No The page number for pagination. Defaults to 1.
    pageSize Number No The number of items per page. Defaults to 25.
  • Response:

    {
      "success": true,
      "data": {
        "data": [
          {
            "_id": "65e6d0a4a8b7c6d5e4f3a2b1",
            "code": "INVITE123",
            "maxUses": 10,
            "currentUses": 0,
            "isEnabled": true,
            "expiresAt": null,
            "notes": "Initial invite code",
            "createdAt": "2023-01-01T00:00:00.000Z",
            "updatedAt": "2023-01-01T00:00:00.000Z"
          }
        ],
        "totalCount": 1
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "InviteCodeRpc.getData",
        "params": {
          "page": 1,
          "pageSize": 10
        }
      }'

POST /api/rpc (Method: InviteCodeRpc.create)

  • Description: Creates a new invite code.

  • Request Body:

    {
      "method": "InviteCodeRpc.create",
      "params": {
        "code": "NEWCODE456",
        "maxUses": 5,
        "isEnabled": true,
        "expiresAt": "2024-12-31T23:59:59.999Z",
        "notes": "Special promotion code"
      }
    }
  • Parameters:

    Name Type Required Description
    code String Yes The unique, human-readable invite code. Must be at least 3 characters.
    maxUses Number Yes Maximum number of times the code can be used. Must be at least 1.
    isEnabled Boolean No Whether the code is currently active. Defaults to true.
    expiresAt Date No Optional expiration date for the code.
    notes String No Administrative notes about the code's purpose or recipient.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "65e6d0a4a8b7c6d5e4f3a2b1",
        "code": "NEWCODE456",
        "maxUses": 5,
        "currentUses": 0,
        "isEnabled": true,
        "expiresAt": "2024-12-31T23:59:59.999Z",
        "notes": "Special promotion code",
        "createdAt": "2023-01-01T00:00:00.000Z",
        "updatedAt": "2023-01-01T00:00:00.000Z"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "InviteCodeRpc.create",
        "params": {
          "code": "PROMOCODE",
          "maxUses": 100,
          "expiresAt": "2024-12-31T23:59:59.999Z"
        }
      }'

POST /api/rpc (Method: InviteCodeRpc.update)

  • Description: Updates an existing invite code.

  • Request Body:

    {
      "method": "InviteCodeRpc.update",
      "params": {
        "_id": "65e6d0a4a8b7c6d5e4f3a2b1",
        "isEnabled": false,
        "notes": "Code disabled due to abuse"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes MongoDB ObjectId of the invite code to update.
    code String No The unique, human-readable invite code. Must be at least 3 characters.
    maxUses Number No Maximum number of times the code can be used. Must be at least 1.
    currentUses Number No How many times the code has been used.
    isEnabled Boolean No Whether the code is currently active.
    expiresAt Date No Optional expiration date for the code.
    notes String No Administrative notes about the code's purpose or recipient.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "65e6d0a4a8b7c6d5e4f3a2b1",
        "code": "INVITE123",
        "maxUses": 10,
        "currentUses": 0,
        "isEnabled": false,
        "expiresAt": null,
        "notes": "Code disabled due to abuse",
        "createdAt": "2023-01-01T00:00:00.000Z",
        "updatedAt": "2023-01-01T00:00:00.000Z"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "InviteCodeRpc.update",
        "params": {
          "_id": "65e6d0a4a8b7c6d5e4f3a2b1",
          "maxUses": 20
        }
      }'

POST /api/rpc (Method: InviteCodeRpc.delete)

  • Description: Deletes an invite code.

  • Request Body:

    {
      "method": "InviteCodeRpc.delete",
      "params": {
        "_id": "65e6d0a4a8b7c6d5e4f3a2b1"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes MongoDB ObjectId of the invite code to delete.
  • Response:

    {
      "success": true,
      "data": {
        "success": true
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "InviteCodeRpc.delete",
        "params": {
          "_id": "65e6d0a4a8b7c6d5e4f3a2b1"
        }
      }'