moymo,Docs
Skip to content
HTTP API Resources

Interaction responses ​

When Moymo sends your application an interaction, its token is a credential for 15 minutes. With it you can follow up with more messages and edit or delete what you wrote, without a bot token: a function that was handed an interaction can finish the job without holding any secret. The first answer itself is the body of your HTTP response (see Receiving and responding).

The token goes in the address. The calls need no Authorization header, so keep the address private: anyone who has it can speak as your application in that interaction until it expires.

@original means the first answer: the message you wrote, the one that said your application was thinking, or (after a deferred update) the message the button was on.

Callback types ​

What the body of your HTTP answer to an interaction is: { "type": …, "data": … }.

NameValueAnswersWhat it does
PONG1pingAcknowledges a verification ping
CHANNEL_MESSAGE_WITH_SOURCE4command, component, formWrites a message (data is the message). With flag 64 only the member sees it
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE5command, component, form"App is thinking…" now, the message later
DEFERRED_UPDATE_MESSAGE6component, formAcknowledges a press without changing anything yet
UPDATE_MESSAGE7component, formChanges the message the component is on
APPLICATION_COMMAND_AUTOCOMPLETE_RESULT8autocompletedata.choices: up to 25 { name, value }
MODAL9command, componentOpens a form in front of the member

An answer of another type is refused, and the member is told the application's answer was not acceptable.

Answers your endpoint can return
json
{
  "type": 4,
  "data": { "content": "Rolled **4**" }
}
json
{
  "type": 4,
  "data": { "content": "Only you can see this", "flags": 64 }
}
json
{ "type": 5 }
json
{
  "type": 7,
  "data": { "content": "Rolled **6**", "components": [] }
}
json
{
  "type": 8,
  "data": {
    "choices": [
      { "name": "A d20", "value": 20 },
      { "name": "A d100", "value": 100 }
    ]
  }
}

Message callback data ​

Field
contentText, up to 4000 characters
embedsUp to 10 embeds
componentsUp to 5 rows of components
allowed_mentionsWhom the text may ping. The default is members only
flags64 (EPHEMERAL), 4, 4096. With a deferred answer only 64 counts

Create followup message ​

POST/webhooks/{application.id}/{interaction.token}

Writes another message after the first answer. The body is a message callback data. Followups come after the first response: before it the answer is 409. After a deferred response, the first followup becomes the answer (it replaces the "thinking" message). Returns the message.

An interaction accepts 10 followups in 10 seconds.

RequestPOST/webhooks/{application.id}/
bash
# No Authorization header: the token in the address is the credential.
curl -X POST "https://moymo.net/api/app/v1/webhooks/$APPLICATION_ID/$INTERACTION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "content": "It took a while, but here it is.", "flags": 64 }'
js
// No Authorization header: the token in the address is the credential.
await fetch(`https://moymo.net/api/app/v1/webhooks/${applicationId}/${interaction.token}`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ content: 'It took a while, but here it is.', flags: 64 })
})

Get response message ​

GET/webhooks/{application.id}/{interaction.token}/messages/{message.id}

{message.id} is @original or the id of a message this interaction's application wrote in the channel.

Edit response message ​

PATCH/webhooks/{application.id}/{interaction.token}/messages/{message.id}

Changes a message the application wrote; fields you leave out stay. Editing a "thinking" message writes the answer and clears the flag.

An answer only the member sees (flag 64) is not stored anywhere, so it is replaced as a whole, not merged: send everything it should show. Only the latest such answer of an interaction can be edited.

Delete response message ​

DELETE/webhooks/{application.id}/{interaction.token}/messages/{message.id}

204.

Errors ​

Status
404The interaction is unknown, or the message is not one of this application's in its channel
410The token has expired (15 minutes)
409A followup before the first response
400The message is not acceptable: the sentence says why
429Too many followups

The wiki is for Moymo's members and developers. Something wrong or missing? Use "Suggest a change" on any page.