---
title: "Registers a slash command for a Discord bot in a specific guild."
method: POST
path: "/registerSlashCommand"
---

# Registers a slash command for a Discord bot in a specific guild.

`POST /registerSlashCommand`

This function creates and registers a new slash command for a Discord bot within a specified guild. It allows for the definition of the command's name, description, options, and permissions. The function returns a Promise that resolves to the registered command object.

## Request body

- object
  - `body` object — Body of the registerSlashCommand sls call
    - `arguments` unknown[], required
      - unknown
    - `auth` object — Authentication object
      - `strategy` 'apikey' — Authentication strategy
      - `variables` unknown[] — Variables for the authentication strategy
        - unknown
    - `packageName` string — @microfox/discord

## Response `200`

Successfully registered the slash command

- object
  - `id` string, required — The ID of the registered command
  - `application_id` string, required — The ID of the application the command belongs to
  - `guild_id` string, required — The ID of the guild the command is registered in
  - `name` string, required — The name of the command
  - `description` string, required — The description of the command
  - `options` DiscordSlashCommandOptionSchema[] — The options of the command — unresolved $ref
  - `default_member_permissions` string — Default permissions required to use the command
  - `dm_permission` boolean — Whether the command can be used in DMs
  - `version` string, required — The version of the command

## Other responses

- `400` — Bad Request - Invalid parameters provided
- `403` — Forbidden - Bot doesn't have permission to create slash commands in the guild
- `404` — Not Found - The specified guild ID does not exist
- `500` — Internal Server Error

## Changes

- **2025-05-29** `2deb154b9766` — 10 info
  - added the non-success response with the status `403`
  - added the non-success response with the status `404`
  - the response property `application_id` became required for the status `200`
  - the response property `description` became required for the status `200`
  - …6 more
- **2025-05-28** `d03e8c66c195` — 8 breaking, 2 info
  - the response property `application_id` became optional for the status `200`
  - the response property `description` became optional for the status `200`
  - the response property `error` became optional for the status `400`
  - the response property `error` became optional for the status `500`
  - …6 more

[Change history](https://skmtc.dev/microfox-ai/apis/microfox-discord-sdk-api/changes/registerSlashCommand/post.md)

---

[API](https://skmtc.dev/microfox-ai/apis/microfox-discord-sdk-api.md) · [All operations](https://skmtc.dev/microfox-ai/apis/microfox-discord-sdk-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/microfox-ai/microfox-discord-sdk-api/revisions/7cb5b64ae924/schema)
