Skip to content

Discord Integration API

Complete API reference for Discord role delivery integration.

Overview

Pixlpay supports Discord role delivery for stores using the Discord platform. When customers purchase products that include Discord roles, the roles are queued for delivery to their Discord account.

How It Works

Pixlpay uses a Custom Discord Bot approach for role delivery. Store owners create their own Discord bot and configure it to point to Pixlpay's webhook endpoint. Roles are delivered when customers use the /claim command.

1. Customer purchases product with Discord role
2. Role queued to delivery queue (pending)
3. Customer runs /claim in Discord server
4. Discord sends interaction to Pixlpay webhook
5. Pixlpay uses store's bot token to assign role
6. Customer receives role instantly

Key Benefits

FeatureDescription
Zero HostingNo VPS or server required
Always OnlineDiscord's infrastructure ensures 100% uptime
Easy Setup~5 minutes to configure
Instant DeliveryRoles assigned immediately when customer runs /claim
SecureBot token encrypted, Ed25519 signature verification

Setup Requirements

  1. Create a Discord Application at Discord Developer Portal
  2. Add a Bot to your application
  3. Get your credentials:
    • Application ID: Found in General Information
    • Public Key: Found in General Information (64 hex characters)
    • Bot Token: Found in Bot section
  4. Configure the Interactions Endpoint URL in your Discord application
  5. Invite the bot to your Discord server with Manage Roles permission

Full Setup Guide


API Endpoints

Get Custom Bot Configuration

http
GET /api/v1/tenant/discord/custom-bot
Authorization: Bearer YOUR_API_TOKEN
X-Tenant-Id: YOUR_STORE_ID

Response:

json
{
  "configured": true,
  "bot": {
    "application_id": "123456789012345678",
    "is_enabled": true,
    "slash_commands_registered": true,
    "last_interaction_at": "2025-01-20T14:30:00Z",
    "stats": {
      "total_interactions": 150,
      "total_roles_assigned": 120,
      "total_roles_removed": 10,
      "total_errors": 5,
      "success_rate": 96.0
    }
  },
  "interactions_url": "https://api.pixlpay.net/webhook/discord/interactions/your-store"
}

Save Custom Bot Credentials

http
POST /api/v1/tenant/discord/custom-bot
Authorization: Bearer YOUR_API_TOKEN
X-Tenant-Id: YOUR_STORE_ID
Content-Type: application/json

Request Body:

json
{
  "application_id": "123456789012345678",
  "public_key": "abc123def456...",
  "bot_token": "MTIzNDU2Nzg5MDEyMzQ1Njc4.ABcDEf.ghIJklMNopQRstUVwxYZ"
}
FieldTypeRequiredDescription
application_idstringYesDiscord Application ID (numeric snowflake)
public_keystringYesEd25519 public key (64 hex characters)
bot_tokenstringYesBot token from Discord Developer Portal

Response:

json
{
  "message": "Custom bot configured and commands registered successfully!",
  "bot": {
    "application_id": "123456789012345678",
    "is_enabled": true,
    "slash_commands_registered": true
  },
  "interactions_url": "https://api.pixlpay.net/webhook/discord/interactions/your-store"
}

Test Bot Connection

http
POST /api/v1/tenant/discord/custom-bot/test
Authorization: Bearer YOUR_API_TOKEN
X-Tenant-Id: YOUR_STORE_ID

Response (Success):

json
{
  "connected": true,
  "bot_name": "My Store Bot",
  "bot_id": "123456789012345678",
  "bot_avatar": "https://cdn.discordapp.com/avatars/123456789012345678/abc123.png"
}

Response (Failure):

json
{
  "connected": false,
  "error": "Invalid bot token"
}

Enable/Disable Bot

http
POST /api/v1/tenant/discord/custom-bot/toggle
Authorization: Bearer YOUR_API_TOKEN
X-Tenant-Id: YOUR_STORE_ID
Content-Type: application/json

Request Body:

json
{
  "enabled": true
}

Response:

json
{
  "message": "Bot enabled",
  "is_enabled": true
}

Register Slash Commands

Re-register /claim, /check, and /help commands if they are missing.

http
POST /api/v1/tenant/discord/custom-bot/register-commands
Authorization: Bearer YOUR_API_TOKEN
X-Tenant-Id: YOUR_STORE_ID

Response:

json
{
  "message": "Commands registered successfully! They may take up to an hour to appear globally.",
  "slash_commands_registered": true
}

Get Bot Invite URL

http
GET /api/v1/tenant/discord/custom-bot/invite-url
Authorization: Bearer YOUR_API_TOKEN
X-Tenant-Id: YOUR_STORE_ID

Response:

json
{
  "url": "https://discord.com/api/oauth2/authorize?client_id=123456789012345678&permissions=268435456&scope=bot%20applications.commands"
}

Get Bot Statistics

http
GET /api/v1/tenant/discord/custom-bot/stats
Authorization: Bearer YOUR_API_TOKEN
X-Tenant-Id: YOUR_STORE_ID

Response:

json
{
  "stats": {
    "total_interactions": 150,
    "total_roles_assigned": 120,
    "total_roles_removed": 10,
    "total_errors": 5,
    "success_rate": 96.0,
    "last_interaction_at": "2025-01-20T14:30:00Z",
    "is_active": true
  }
}

Remove Custom Bot

http
DELETE /api/v1/tenant/discord/custom-bot
Authorization: Bearer YOUR_API_TOKEN
X-Tenant-Id: YOUR_STORE_ID

Response:

json
{
  "message": "Custom bot removed"
}

Discord Slash Commands

Once configured, customers can use these commands in your Discord server:

CommandDescription
/claimClaim all pending role deliveries
/checkView pending and recent role deliveries
/helpShow available commands and instructions

Discord Interactions Webhook

Pixlpay receives Discord interactions at:

POST https://api.pixlpay.net/webhook/discord/interactions/{store-slug}

This webhook:

  • Verifies Ed25519 signatures using your Public Key
  • Handles PING verification (type 1)
  • Processes slash commands (type 2)
  • Processes button clicks (type 3)

You do not need to implement this webhook - Pixlpay handles everything. Just set the URL in your Discord application's settings.


Error Responses

All endpoints return consistent error formats:

401 Unauthorized

json
{
  "success": false,
  "error": "Unauthorized",
  "message": "Invalid or missing API token"
}

403 Forbidden

json
{
  "success": false,
  "error": "Forbidden",
  "message": "Token does not have required scope"
}

404 Not Found

json
{
  "success": false,
  "error": "Not Found",
  "message": "Operation not found"
}

422 Unprocessable Entity

json
{
  "success": false,
  "error": "Validation Error",
  "message": "The given data was invalid",
  "errors": {
    "application_id": ["Application ID must be a numeric Discord snowflake."]
  }
}

429 Too Many Requests

json
{
  "success": false,
  "error": "Too Many Requests",
  "message": "Rate limit exceeded",
  "retry_after": 60
}

Rate Limits

Standard API rate limits apply (60 requests per minute).


Delivery Queue Status Values

StatusDescription
pendingAwaiting delivery (customer needs to run /claim)
completedSuccessfully delivered
failedFailed after maximum retry attempts
expiredExpired without being claimed (default: 72 hours)

Delivery Source Values:

ValueDescription
interactionDelivered via Custom Bot /claim command
autoAutomatically delivered (future feature)
manualManually delivered by store owner

Built for game developers, by game developers.