> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getprimo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Link a ticket to a Microsoft Teams channel

> Link the ticket to a standard Teams channel, by `channelId` or by the names of its team and channel (`teamName` and `channelName`, matched ignoring case). A link puts the ticket in front of the people in that channel, so it is made when someone asked for it, never as a fallback after an unanswered email. Primo posts a card naming the ticket there, which opens the thread: its replies become public comments on the ticket. A ticket holds one link: linking again replaces it, a Slack link made with `linkTicketToSlack` included, and the previous thread gets a last message. Refused when ticket links are not open for the company (403 `TeamsTicketLinksDisabledError`), no Microsoft 365 tenant is connected (409 `TeamsNotConnectedError`), the ticket was raised from Slack or Teams and keeps its thread (409 `ChatSourcedTicketLinkLockedError`), the channel is used to raise tickets (409 `TeamsIntakeChannelLinkRefusedError`), no channel of the tenant carries that id, or none or more than one carries those names (422 `TeamsLinkTargetUnavailableError`), Microsoft keeps Primo out of the channel, a private one included (422 `TeamsChannelLinkRefusedError`), or Microsoft refuses the Primo app in the team that holds the channel (422 `TeamsAppNotAllowedError`: add the app to that team, or an admin reconnects Teams). Answers the link with its `status`; `getTicket` returns it too. To remove it, use `unlinkTicketFromTeams`.

Key: WriteScope: Company


## OpenAPI

````yaml https://api.getprimo.com/openapi.json put /tickets/{ticketId}/teams-link
openapi: 3.1.1
info:
  title: Public API - BETA
  description: Read docs on https://docs.getprimo.com/
  version: '1.0'
  contact: {}
servers:
  - url: https://api.getprimo.com
security:
  - apikey: []
tags: []
paths:
  /tickets/{ticketId}/teams-link:
    put:
      tags:
        - Tickets
      summary: Link a ticket to a Microsoft Teams channel
      description: >-
        Link the ticket to a standard Teams channel, by `channelId` or by the
        names of its team and channel (`teamName` and `channelName`, matched
        ignoring case). A link puts the ticket in front of the people in that
        channel, so it is made when someone asked for it, never as a fallback
        after an unanswered email. Primo posts a card naming the ticket there,
        which opens the thread: its replies become public comments on the
        ticket. A ticket holds one link: linking again replaces it, a Slack link
        made with `linkTicketToSlack` included, and the previous thread gets a
        last message. Refused when ticket links are not open for the company
        (403 `TeamsTicketLinksDisabledError`), no Microsoft 365 tenant is
        connected (409 `TeamsNotConnectedError`), the ticket was raised from
        Slack or Teams and keeps its thread (409
        `ChatSourcedTicketLinkLockedError`), the channel is used to raise
        tickets (409 `TeamsIntakeChannelLinkRefusedError`), no channel of the
        tenant carries that id, or none or more than one carries those names
        (422 `TeamsLinkTargetUnavailableError`), Microsoft keeps Primo out of
        the channel, a private one included (422
        `TeamsChannelLinkRefusedError`), or Microsoft refuses the Primo app in
        the team that holds the channel (422 `TeamsAppNotAllowedError`: add the
        app to that team, or an admin reconnects Teams). Answers the link with
        its `status`; `getTicket` returns it too. To remove it, use
        `unlinkTicketFromTeams`.
      operationId: linkTicketToTeams
      parameters:
        - name: ticketId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LinkTicketToTeamsBody'
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TicketTeamsLinkOutput_Output'
components:
  schemas:
    LinkTicketToTeamsBody:
      type: object
      properties:
        target:
          description: >-
            A standard Teams channel, by id, or by the names of its team and of
            the channel
          anyOf:
            - type: object
              properties:
                channelId:
                  description: Teams channel id, e.g. `19:abc123@thread.tacv2`
                  type: string
                  minLength: 1
              required:
                - channelId
              additionalProperties: false
            - type: object
              properties:
                teamName:
                  description: Name of the team the channel belongs to, e.g. `IT`
                  type: string
                  minLength: 1
                channelName:
                  description: Name of the channel in that team, e.g. `Support`
                  type: string
                  minLength: 1
              required:
                - teamName
                - channelName
              additionalProperties: false
      required:
        - target
    TicketTeamsLinkOutput_Output:
      type: object
      properties:
        connected:
          type: boolean
          description: Whether the company has a Microsoft Teams tenant connected to Primo
        link:
          description: Null when the ticket is not linked to Teams
          anyOf:
            - type: object
              properties:
                origin:
                  description: >-
                    `LINKED`: linked by hand. `TICKET_SOURCE`: the Teams thread
                    or chat the ticket was raised in, which cannot change
                  type: string
                  enum:
                    - LINKED
                    - TICKET_SOURCE
                label:
                  description: The team and channel (`IT › Support`), null for a chat
                  anyOf:
                    - type: string
                    - type: 'null'
                url:
                  description: Opens the thread in Teams, null for a chat
                  anyOf:
                    - type: string
                    - type: 'null'
                linkedByName:
                  description: Who linked it, null for the thread the ticket was raised in
                  anyOf:
                    - type: string
                    - type: 'null'
                linkedAt:
                  anyOf:
                    - type: string
                      format: date-time
                      pattern: >-
                        ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                    - type: 'null'
                status:
                  description: >-
                    `ACTIVE`: messages reach the thread. `TEAMS_DISCONNECTED`:
                    the Microsoft 365 tenant was disconnected from Primo.
                    `CHANNEL_UNAVAILABLE`: the channel was deleted or Primo can
                    no longer post in it
                  type: string
                  enum:
                    - ACTIVE
                    - TEAMS_DISCONNECTED
                    - CHANNEL_UNAVAILABLE
              required:
                - origin
                - label
                - url
                - linkedByName
                - linkedAt
                - status
              additionalProperties: false
            - type: 'null'
      required:
        - connected
        - link
      additionalProperties: false
  securitySchemes:
    apikey:
      scheme: bearer
      bearerFormat: API key
      type: http
      description: >-
        Use your Primo API key in the Authorization header as `Bearer
        <API_KEY>`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.