# Add a tag to an external page

`POST /ai/external_pages/{external_page_id}/tags`

> This is a subset of the full specification, limited to the `POST /ai/external_pages/{external_page_id}/tags` operation.
>
> You can find the full specification here: /_bundle/docs/references/@2.18/rest-api/api.intercom.io.yaml

```yaml
openapi: 3.0.1
info:
  title: Intercom API
  version: '2.18'
  description: This is a subset of the full specification, limited to the `POST /ai/external_pages/{external_page_id}/tags` operation.
  contact:
    name: Intercom Developer Hub
    url: https://developers.intercom.com
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
servers:
  - url: https://api.intercom.io
    description: The production API server
  - url: https://api.eu.intercom.io
    description: The european API server
  - url: https://api.au.intercom.io
    description: The australian API server
security:
  - bearerAuth: []
tags:
  - name: AI Content
    description: |
      With the AI Content APIs, you can create and manage External Pages and Content Import Sources for your Fin Content Library.

      &nbsp;

      *External Pages* are pages that you want Fin to be able to answer questions about. The API for External Pages is a great way to ingest into your Fin Content Library pages that are not publicly accessible and hence can't be crawled by Intercom.

      &nbsp;

      *Content Import Sources* are the sources of those pages, and they are used to determine the default audience for the pages (configured via the UI). You should create a Content Import Source for each source of External Pages that you want to ingest into your Fin Content Library.

      &nbsp;

      You can then iterate through the content from that source via its API and POST it to the External Pages endpoint. That endpoint has an *external_id* parameter which allows you to specify the identifier from the source. The endpoint will then either create a new External Page or update an existing one as appropriate.",
  - name: Tags
    description: Everything about tags
paths:
  /ai/external_pages/{external_page_id}/tags:
    post:
      summary: Add a tag to an external page
      tags:
        - AI Content
        - Tags
      parameters:
        - name: Intercom-Version
          in: header
          schema:
            $ref: '#/components/schemas/intercom_version'
        - name: external_page_id
          in: path
          required: true
          description: The unique identifier for the external page which is given by Intercom.
          example: '1234'
          schema:
            type: string
      operationId: attachTagToExternalPage
      description: |
        Apply an existing tag to an external page. Returns the tag that was applied.

        The tag must already exist in the workspace (create tags with the Tags API),
        and the authenticating teammate must have the `manage_knowledge_base_content`
        permission. Pages uploaded as files can't be tagged and return a 404.

        OAuth tokens must have the `read_write_ai_content` scope.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - id
              properties:
                id:
                  type: string
                  description: The unique identifier of the tag to apply, as given by Intercom.
                  example: '7522907'
                admin_id:
                  type: string
                  nullable: true
                  description: Optional id of the teammate to attribute the tagging to. Defaults to the authenticating teammate.
                  example: '1234'
            examples:
              successful:
                summary: Apply a tag
                value:
                  id: '7522907'
      responses:
        '200':
          description: Tag applied
          content:
            application/json:
              examples:
                Tag applied:
                  value:
                    type: tag
                    id: '7522907'
                    name: Independent
                    applied_at: 1663597223
                    applied_by:
                      type: admin
                      id: '1234'
              schema:
                $ref: '#/components/schemas/tag'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Forbidden
          content:
            application/json:
              examples:
                Forbidden:
                  value:
                    type: error.list
                    request_id: 6f3c2b1a-2d4e-4f6a-9b8c-1a2b3c4d5e6f
                    errors:
                      - code: forbidden
                        message: Not authorized to manage knowledge base content
              schema:
                $ref: '#/components/schemas/error'
        '404':
          description: External page, tag or teammate not found
          content:
            application/json:
              examples:
                External page not found:
                  value:
                    type: error.list
                    request_id: d41b7e92-6a03-4f8c-91e5-3c2a8b0f6d74
                    errors:
                      - code: not_found
                        message: Resource Not Found
                Tag not found:
                  value:
                    type: error.list
                    request_id: 8a3e4f88-ae65-433a-b4eb-46780ffc5402
                    errors:
                      - code: tag_not_found
                        message: Tag not found
                Admin not found:
                  value:
                    type: error.list
                    request_id: 7a34a204-9fae-5335-b818-1da0df3b5234
                    errors:
                      - code: admin_not_found
                        message: Admin not found
              schema:
                $ref: '#/components/schemas/error'
components:
  schemas:
    error:
      type: object
      title: Error
      description: The API will return an Error List for a failed request, which will contain one or more Error objects.
      properties:
        type:
          type: string
          description: The type is error.list
          example: error.list
        request_id:
          type: string
          nullable: true
          format: uuid
          description: ''
          example: f93ecfa8-d08a-4325-8694-89aeb89c8f85
        errors:
          type: array
          description: An array of one or more error objects
          items:
            properties:
              code:
                type: string
                description: A string indicating the kind of error, used to further qualify the HTTP response code.
                example: unauthorized
              message:
                type: string
                nullable: true
                description: Optional. Human readable description of the error.
                example: Access Token Invalid
              data:
                type: object
                nullable: true
                additionalProperties: true
                description: Optional. Extra detail about the error, for example `required_permissions` on a 403 `action_forbidden` error.
                example:
                  required_permissions:
                    - read_conversations
            required:
              - code
      required:
        - type
        - errors
    intercom_version:
      description: Intercom API version.</br>If you omit the header, the API uses the version set in your app package, and 1.0 if none is set.
      type: string
      example: '2.18'
      enum:
        - '1.0'
        - '1.1'
        - '1.2'
        - '1.3'
        - '1.4'
        - '2.0'
        - '2.1'
        - '2.2'
        - '2.3'
        - '2.4'
        - '2.5'
        - '2.6'
        - '2.7'
        - '2.8'
        - '2.9'
        - '2.10'
        - '2.11'
        - '2.12'
        - '2.13'
        - '2.14'
        - '2.15'
        - '2.16'
        - '2.17'
        - '2.18'
    reference:
      title: Reference
      type: object
      description: reference to another object
      properties:
        type:
          type: string
          description: ''
          example: contact
        id:
          type: string
          nullable: true
          description: ''
          example: 1a2b3c
    tag:
      title: Tag
      type: object
      x-tags:
        - Tags
      description: A tag allows you to label your contacts, companies, conversations, tickets, articles, internal articles, content snippets and external pages, and list them using that tag.
      properties:
        type:
          type: string
          description: value is "tag"
          example: tag
        id:
          type: string
          description: The id of the tag
          example: '123456'
        name:
          type: string
          description: The name of the tag
          example: Test tag
        applied_at:
          type: integer
          format: timestamp
          nullable: true
          description: The time when the tag was applied to the object. Only present when the tag is returned as part of a tagging operation on a contact, conversation, ticket, article, internal article, content snippet, or external page, when listing the tags on a contact, or when it is returned as part of an external page. `null` when the tag has just been removed from an article, internal article, content snippet or external page. Removing a tag from a contact, conversation or ticket returns the original value.
          example: 1663597223
        applied_by:
          type: object
          nullable: true
          description: The admin who applied the tag. Only present when the tag is returned as part of a tagging operation on a contact, conversation, ticket, article, internal article, content snippet, or external page, when listing the tags on a contact, or when it is returned as part of an external page. `null` when the tag has just been removed from an article, internal article, content snippet or external page. Removing a tag from a contact, conversation or ticket returns the original value. When no admin is recorded, `type` is `nobody_admin` and `id` is `null`.
          allOf:
            - $ref: '#/components/schemas/reference'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  responses:
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          examples:
            Unauthorized:
              value:
                type: error.list
                request_id: 12a938a3-314e-4939-b773-5cd45738bd21
                errors:
                  - code: unauthorized
                    message: Access Token Invalid
          schema:
            $ref: '#/components/schemas/error'
```
