{
  "openapi": "3.1.0",
  "info": {
    "title": "Deno webhook API",
    "version": "1.0.0",
    "description": "Let another Yapin’ bot warn members, add notes, post to the mod log and look up records in a server whose admin created a key. Human-readable docs: https://deno.win/developers/"
  },
  "servers": [
    {
      "url": "https://deno.win"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/hook/{server_id}": {
      "post": {
        "summary": "Run an action",
        "operationId": "runAction",
        "parameters": [
          {
            "name": "server_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "properties": {
                      "action": {
                        "const": "ping"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "user_id"
                    ],
                    "properties": {
                      "action": {
                        "const": "warn"
                      },
                      "user_id": {
                        "type": "string",
                        "description": "The member to warn. Moderators and admins are refused, and so is Deno itself."
                      },
                      "reason": {
                        "type": "string",
                        "description": "Up to 150 characters. Defaults to “No reason given”. Moderators see it as via <source>: <reason>."
                      },
                      "source": {
                        "type": "string",
                        "description": "Your bot’s name, up to 40 characters. It is shown next to the action so moderators know where it came from."
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "user_id"
                    ],
                    "properties": {
                      "action": {
                        "const": "note"
                      },
                      "user_id": {
                        "type": "string",
                        "description": "The member the note is about."
                      },
                      "reason": {
                        "type": "string",
                        "description": "The note itself, up to 150 characters."
                      },
                      "source": {
                        "type": "string",
                        "description": "Your bot’s name, up to 40 characters."
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "properties": {
                      "action": {
                        "const": "modlog"
                      },
                      "content": {
                        "type": "string",
                        "description": "Plain text, up to 1500 characters. Use this or embed."
                      },
                      "embed": {
                        "type": "object",
                        "properties": {
                          "title": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "description": {
                            "type": "string",
                            "maxLength": 1500
                          },
                          "color": {
                            "type": "string",
                            "pattern": "^#[0-9a-fA-F]{6}$"
                          }
                        }
                      },
                      "source": {
                        "type": "string",
                        "description": "Shown in the card’s footer as via <source>."
                      }
                    }
                  }
                ],
                "discriminator": {
                  "propertyName": "action"
                }
              },
              "examples": {
                "ping": {
                  "value": {
                    "action": "ping"
                  }
                },
                "warn": {
                  "value": {
                    "action": "warn",
                    "user_id": "3f2a9c1e-5b7d-4e21-9a40-8c6d1e0f7b52",
                    "reason": "Posted a scam link",
                    "source": "GuardBot"
                  }
                },
                "note": {
                  "value": {
                    "action": "note",
                    "user_id": "3f2a9c1e-5b7d-4e21-9a40-8c6d1e0f7b52",
                    "reason": "Verified by GuardBot",
                    "source": "GuardBot"
                  }
                },
                "modlog": {
                  "value": {
                    "action": "modlog",
                    "embed": {
                      "title": "Raid blocked",
                      "description": "Blocked 12 joins in 10 seconds.",
                      "color": "#ff7a12"
                    },
                    "source": "GuardBot"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The key works. server is the server’s name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "server": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok",
                    "server"
                  ]
                },
                "example": {
                  "ok": true,
                  "server": "Pixel Lounge"
                }
              }
            }
          },
          "202": {
            "description": "Accepted. Deno has checked the request and queued the post, so you get the answer fast. A failure while posting is not reported back.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok",
                    "queued"
                  ]
                },
                "example": {
                  "ok": true,
                  "queued": true
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Not JSON, not an object, an unknown action, or a field is missing or wrong. The error text says which.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                },
                "example": {
                  "error": "Unknown action. Use ping, warn, note or modlog."
                }
              }
            }
          },
          "401": {
            "description": "Unknown server or wrong key. Deno never says which, on purpose.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                },
                "example": {
                  "error": "Unknown webhook or wrong token."
                }
              }
            }
          },
          "405": {
            "description": "A method other than POST (or GET for the lookup).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                },
                "example": {
                  "error": "Use POST, or GET for the user lookup."
                }
              }
            }
          },
          "409": {
            "description": "The server has no mod log channel (modlog only).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                },
                "example": {
                  "error": "This server has no mod log channel yet."
                }
              }
            }
          },
          "413": {
            "description": "The body is over 16 KB.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                },
                "example": {
                  "error": "The body is too large (16 KB at most)."
                }
              }
            }
          },
          "429": {
            "description": "Too many requests, or too many wrong keys. A retry_after (seconds) is included when waiting helps.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "retry_after": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "error",
                    "retry_after"
                  ]
                },
                "example": {
                  "error": "Slow down: 60 requests a minute per server.",
                  "retry_after": 10
                }
              }
            }
          },
          "502": {
            "description": "Something failed on Deno’s side. Try again in a moment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                },
                "example": {
                  "error": "Something went wrong on our side. Try again."
                }
              }
            }
          }
        }
      }
    },
    "/hook/{server_id}/user/{user_id}": {
      "get": {
        "summary": "Look up a member",
        "operationId": "lookupMember",
        "parameters": [
          {
            "name": "server_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "user_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "warnings counts active (not removed) warnings, cases is every case on record for the member, and recent is the newest five, newest first. type is one of warn, timeout, untimeout, kick, ban, tempban, unban or note.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user_id": {
                      "type": "string"
                    },
                    "warnings": {
                      "type": "integer"
                    },
                    "cases": {
                      "type": "integer"
                    },
                    "recent": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "type": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "removed": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "reason",
                          "created_at",
                          "removed"
                        ]
                      }
                    }
                  },
                  "required": [
                    "user_id",
                    "warnings",
                    "cases",
                    "recent"
                  ]
                },
                "example": {
                  "user_id": "3f2a9c1e-5b7d-4e21-9a40-8c6d1e0f7b52",
                  "warnings": 2,
                  "cases": 5,
                  "recent": [
                    {
                      "id": 41,
                      "type": "warn",
                      "reason": "via GuardBot: Posted a scam link",
                      "created_at": "2026-10-23T11:20:00.000Z",
                      "removed": false
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unknown server or wrong key. Deno never says which, on purpose.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                },
                "example": {
                  "error": "Unknown webhook or wrong token."
                }
              }
            }
          },
          "429": {
            "description": "Too many requests, or too many wrong keys. A retry_after (seconds) is included when waiting helps.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "retry_after": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "error",
                    "retry_after"
                  ]
                },
                "example": {
                  "error": "Slow down: 60 requests a minute per server.",
                  "retry_after": 10
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "denoEvent": {
      "post": {
        "summary": "A moderation event sent to the address the admin chose",
        "description": "Signed with HMAC-SHA256 in `X-Deno-Signature`. Answer 2xx within 3 seconds; there are no retries.",
        "parameters": [
          {
            "name": "X-Deno-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^sha256=[0-9a-f]{64}$"
            }
          },
          {
            "name": "X-Deno-Event",
            "in": "header",
            "required": true,
            "schema": {
              "enum": [
                "case",
                "test"
              ]
            }
          },
          {
            "name": "X-Deno-Server",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "event": {
                    "type": "string"
                  },
                  "server_id": {
                    "type": "string"
                  },
                  "created_at": {
                    "type": "string"
                  },
                  "data": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "integer"
                      },
                      "type": {
                        "type": "string"
                      },
                      "user_id": {
                        "type": "string"
                      },
                      "moderator_id": {
                        "type": "string"
                      },
                      "reason": {
                        "type": "string"
                      },
                      "minutes": {
                        "type": "null"
                      },
                      "created_at": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "type",
                      "user_id",
                      "moderator_id",
                      "reason",
                      "minutes",
                      "created_at"
                    ]
                  }
                },
                "required": [
                  "id",
                  "event",
                  "server_id",
                  "created_at",
                  "data"
                ]
              },
              "example": {
                "id": "6f1c0a52-3b4d-4e8a-9c71-2d5e8f0a1b34",
                "event": "case",
                "server_id": "0b8e5c1a-6d2f-4c37-9a15-7e4d3b2a1f90",
                "created_at": "2026-10-23T11:21:12.000Z",
                "data": {
                  "id": 42,
                  "type": "ban",
                  "user_id": "3f2a9c1e-5b7d-4e21-9a40-8c6d1e0f7b52",
                  "moderator_id": "8d1c4e7a-2b5f-4a93-b6e0-1f7a9c3d5e28",
                  "reason": "Raid",
                  "minutes": null,
                  "created_at": "2026-10-23T11:21:12.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "The key (dh_…) an admin created under Connect other bots."
      }
    }
  }
}
