melonly logomelonly logo
melonly logo
Dashboard
Log in

Create a Token

Creates a token. A new token can never outlive the token used to create it, and a server can have up to 25 active tokens.

POST

/api/v1/tokens

Request

curl -X POST "https://api.melonly.com/api/v1/tokens" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "expiresInDays": 90,
  "name": "shift bot (do not delete)"
}'

Response

201

Created

{
  "data": {
    "createdAt": 1794700000000,
    "id": "7527840000000004096",
    "isActive": true,
    "lastUsedAt": 1794776859830,
    "name": "shift bot (do not delete)",
    "serverId": "7294057520392310784",
    "token": "9f2c4e7a1b3d5f60718293a4b5c6d7e8f9a0b1c2d3e4f5061728394a5b6c7d8e"
  }
}

Treat tokens like passwords. Anyone with one can act as your server's staff through the API.

Authorization

Authorizationstringrequired
Your API token as Bearer YOUR_TOKEN. Create one in your server's dashboard settings.

Body

namestringrequired
Token name, 1-50 characters. Must be unique among active tokens.
expiresInDaysinteger | null
Days until it expires, from 1 to 3650. Leave it out for no expiry.

Response

201 Created

createdAtintegerrequired
When the token was created.
idstringrequired
Token ID.
isActivebooleanrequired
Whether the token works.
namestringrequired
Token name.
serverIdstringrequired
Server the token belongs to.
tokenstringrequired
The bearer secret. Store it now; it cannot be retrieved again.
expiresAtinteger | null
When the token expires.
lastUsedAtinteger | null
When the token was last used, to the nearest minute.

Errors

StatusMeaning
400Invalid request. validation_failed lists each invalid field in details.fields.
401Missing, invalid or expired token
409Name taken or active token limit reached
429Rate limited. See Retry-After and details.
500Internal server error