# Guild Template Resource

### Guild Template Object

Represents a code that when used, creates a guild based on a snapshot of an existing guild.

###### Guild Template Structure

| Field                     | Type                                                                  | Description                                                                      |
| ------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| code                      | string                                                                | the template code (unique ID)                                                    |
| name                      | string                                                                | template name                                                                    |
| description               | ?string                                                               | the description for the template                                                 |
| usage\_count              | integer                                                               | number of times this template has been used                                      |
| creator\_id               | snowflake                                                             | the ID of the user who created the template                                      |
| creator                   | [user](/guides/http-api-resources-user#user-object) object            | the user who created the template                                                |
| created\_at               | ISO8601 timestamp                                                     | when this template was created                                                   |
| updated\_at               | ISO8601 timestamp                                                     | when this template was last synced to the source guild                           |
| source\_guild\_id         | snowflake                                                             | the ID of the guild this template is based on                                    |
| serialized\_source\_guild | partial [guild](/guides/http-api-resources-guild#guild-object) object | the guild snapshot this template contains; placeholder IDs are given as integers |
| is\_dirty                 | ?boolean                                                              | whether the template has unsynced changes                                        |

###### Example Guild Template Object

```json
{
  "code": "hgM48av5Q69A",
  "name": "Friends & Family",
  "description": "",
  "usage_count": 49605,
  "creator_id": "132837293881950208",
  "creator": {
    "id": "132837293881950208",
    "username": "hoges",
    "avatar": "79b0d9f8c340f2d43e1f78b09f175b62",
    "discriminator": "0001",
    "public_flags": 129
  },
  "created_at": "2020-04-02T21:10:38+00:00",
  "updated_at": "2020-05-01T17:57:38+00:00",
  "source_guild_id": "678070694164299796",
  "serialized_source_guild": {
    "name": "Friends & Family",
    "description": null,
    "region": "us-west",
    "verification_level": 0,
    "default_message_notifications": 0,
    "explicit_content_filter": 0,
    "preferred_locale": "en-US",
    "afk_timeout": 300,
    "roles": [
      {
        "id": 0,
        "name": "@everyone",
        "permissions": 104324689,
        "color": 0,
        "hoist": false,
        "mentionable": false
      }
    ],
    "channels": [
      {
        "name": "Text Channels",
        "position": 1,
        "topic": null,
        "bitrate": 64000,
        "user_limit": 0,
        "nsfw": false,
        "rate_limit_per_user": 0,
        "parent_id": null,
        "permission_overwrites": [],
        "id": 1,
        "type": 4
      },
      {
        "name": "general",
        "position": 1,
        "topic": null,
        "bitrate": 64000,
        "user_limit": 0,
        "nsfw": false,
        "rate_limit_per_user": 0,
        "parent_id": 1,
        "permission_overwrites": [],
        "id": 2,
        "type": 0
      }
    ],
    "afk_channel_id": null,
    "system_channel_id": 2,
    "system_channel_flags": 0,
    "icon_hash": null
  },
  "is_dirty": null
}
```

## Get Guild Template

/guilds/templates/[{template.code}](/guides/http-api-resources-guild-template#guild-template-object)

Returns a [guild template](/guides/http-api-resources-guild-template#guild-template-object) object for the given code.

## Get Guild Templates

/guilds/[{guild.id}](/guides/http-api-resources-guild#guild-object)/templates

Returns an array of [guild template](/guides/http-api-resources-guild-template#guild-template-object) objects. Requires the `MANAGE_GUILD` permission.

## Create Guild Template

/guilds/[{guild.id}](/guides/http-api-resources-guild#guild-object)/templates

Creates a template for the guild. Requires the `MANAGE_GUILD` permission. Returns the created [guild template](/guides/http-api-resources-guild-template#guild-template-object) object on success.

###### JSON Params

| Field        | Type    | Description                                     |
| ------------ | ------- | ----------------------------------------------- |
| name         | string  | name of the template (1-100 characters)         |
| description? | ?string | description for the template (0-120 characters) |

## Sync Guild Template

/guilds/[{guild.id}](/guides/http-api-resources-guild#guild-object)/templates/[{template.code}](/guides/http-api-resources-guild-template#guild-template-object)

Syncs the template to the guild's current state. Requires the `MANAGE_GUILD` permission. Returns the [guild template](/guides/http-api-resources-guild-template#guild-template-object) object on success.

## Modify Guild Template

/guilds/[{guild.id}](/guides/http-api-resources-guild#guild-object)/templates/[{template.code}](/guides/http-api-resources-guild-template#guild-template-object)

Modifies the template's metadata. Requires the `MANAGE_GUILD` permission. Returns the [guild template](/guides/http-api-resources-guild-template#guild-template-object) object on success.

###### JSON Params

| Field        | Type    | Description                                     |
| ------------ | ------- | ----------------------------------------------- |
| name?        | string  | name of the template (1-100 characters)         |
| description? | ?string | description for the template (0-120 characters) |

## Delete Guild Template

/guilds/[{guild.id}](/guides/http-api-resources-guild#guild-object)/templates/[{template.code}](/guides/http-api-resources-guild-template#guild-template-object)

Deletes the template. Requires the `MANAGE_GUILD` permission. Returns the deleted [guild template](/guides/http-api-resources-guild-template#guild-template-object) object on success.

## Related pages

- [API Reference](./api-reference-index.md)
- [App Fundamentals](./app-fundamentals-index.md)
- [Best Practices](./best-practices-index.md)
- [Bots & Companion Apps](./bots-companion-apps-index.md)
- [Building Games](./building-games-index.md)
- [Building on Discord](./building-on-discord-index.md)
- [Change Log](./change-log-index.md)
- [Communities & Servers](./communities-servers-index.md)
- [Components](./components-index.md)
- [Core Concepts](./core-concepts-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
