> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # CreateTag # Package: blog # Namespace: TagService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/blog/tags/create-tag.md ## Permission Scopes: Manage Blog: SCOPE.DC-BLOG.MANAGE-BLOG ## Introduction Creates a new tag with the provided label if a tag with the same label doesn't already exist. --- ## REST API ### Schema ``` Method: createTag Description: Creates a new tag with the provided label if a tag with the same label doesn't already exist. URL: https://www.wixapis.com/v3/tags Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: label Method parameters: param name: fieldsets | type: array | description: List of additional tag fields to include in the response. For example, use the `URL` fieldset to retrieve the url field in the response in addition to the tag's base fields. Base fields don’t include any of the supported fieldset values. By default only the tag's base fields are returned. - enum: UNKNOWN, URL param name: label | type: label | description: Tag label. The label for each tag in a blog must be unique. | required: true param name: language | type: language | description: Tag language. 2-or-4-letter language code in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. param name: slug | type: slug | description: Preferred tag slug. For example, `'tag-slug'`. Return type: CreateTagResponse - name: tag | type: Tag | description: Created tag. - name: id | type: string | description: Tag GUID. - name: label | type: string | description: Tag label. A blog can't have two tags with the same label. - name: slug | type: string | description: Part of a tag's URL that refers to a specific tag. For example, `'https:/example.com/tags/{my-tag-slug}'` - name: createdDate | type: string | description: Date the tag was created. - name: updatedDate | type: string | description: Date the tag was last updated. - name: url | type: PageUrl | description: Tag URL. The `url` directs you to a page that lists every post with the specified tag. - name: base | type: string | description: The base URL. For premium sites, this is the domain. For free sites, this is the site URL. For example, `mysite.wixsite.com/mysite`. - name: path | type: string | description: The relative path for the page within the site. For example, `/product-page/a-product`. - name: publishedPostCount | type: integer | description: Number of published posts with this tag. - name: translationId | type: string | description: GUID of the tag's translations when [Wix Multilingual](https://support.wix.com/en/article/wix-multilingual-translating-your-blog) is installed on a site. All translations of a single tag share the same `translationId`. - name: language | type: string | description: Tag language. 2-or-4-letter language code in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. ``` ### Examples ### CreateTag ```curl ~~~cURL curl -X POST \ 'https://www.wixapis.com/blog/v3/tags/' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' -d '{ "label": "vacation", "language": "en" }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.blog.TagService.createTag(label, options) Description: Creates a new tag with the provided label if a tag with the same label doesn't already exist. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: label Method parameters: param name: label | type: string | description: Tag label. The label for each tag in a blog must be unique. | required: true param name: options | type: CreateTagOptions none - name: language | type: string | description: Tag language. 2-or-4-letter language code in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. - name: slug | type: string | description: Preferred tag slug. For example, `'tag-slug'`. - name: fieldsets | type: array | description: List of additional tag fields to include in the response. For example, use the `URL` fieldset to retrieve the url field in the response in addition to the tag's base fields. Base fields don’t include any of the supported fieldset values. By default only the tag's base fields are returned. - enum: UNKNOWN, URL Return type: PROMISE - name: tag | type: Tag | description: Created tag. - name: _id | type: string | description: Tag GUID. - name: label | type: string | description: Tag label. A blog can't have two tags with the same label. - name: slug | type: string | description: Part of a tag's URL that refers to a specific tag. For example, `'https:/example.com/tags/{my-tag-slug}'` - name: _createdDate | type: Date | description: Date the tag was created. - name: _updatedDate | type: Date | description: Date the tag was last updated. - name: url | type: string | description: Tag URL. The `url` directs you to a page that lists every post with the specified tag. - name: publishedPostCount | type: integer | description: Number of published posts with this tag. - name: translationId | type: string | description: GUID of the tag's translations when [Wix Multilingual](https://support.wix.com/en/article/wix-multilingual-translating-your-blog) is installed on a site. All translations of a single tag share the same `translationId`. - name: language | type: string | description: Tag language. 2-or-4-letter language code in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. ``` ### Examples ### createTag ```javascript import { tags } from '@wix/blog'; async function createTag(label,options) { const response = await tags.createTag(label,options); }; ``` ### createTag (with elevated permissions) ```javascript import { tags } from '@wix/blog'; import { auth } from '@wix/essentials'; async function myCreateTagMethod(label,options) { const elevatedCreateTag = auth.elevate(tags.createTag); const response = await elevatedCreateTag(label,options); } ``` ### createTag (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { tags } from '@wix/blog'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { tags }, // Include the auth strategy and host as relevant }); async function createTag(label,options) { const response = await myWixClient.tags.createTag(label,options); }; ``` ---