> ## 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 Slack channel or to a person in Slack

> Link the ticket to a Slack channel (by `channelId` or `channelName`) or to the direct messages of one person (by Slack member `slackUserId` or `email`). Primo posts a first message 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, and the previous thread gets a last message. Refused when Slack links are not open for the company (403 `SlackTicketLinksDisabledError`), no Slack workspace is connected (409 `SlackNotConnectedError`), the ticket was raised from Slack and keeps its thread (409 `SlackSourcedTicketLinkLockedError`), the channel is used to raise tickets (409 `SlackIntakeChannelLinkRefusedError`), or Primo cannot post to that channel or person (422 `SlackLinkTargetUnavailableError`: unknown, archived, not joined by the Primo app, or no Slack member with that email). Answers the link with its `status`; `getTicket` returns it too. To remove it, use `unlinkTicketFromSlack`.

Key: WriteScope: Company


## OpenAPI

````yaml https://api.getprimo.com/openapi.json put /tickets/{ticketId}/slack-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}/slack-link:
    put:
      tags:
        - Tickets
      summary: Link a ticket to a Slack channel or to a person in Slack
      description: >-
        Link the ticket to a Slack channel (by `channelId` or `channelName`) or
        to the direct messages of one person (by Slack member `slackUserId` or
        `email`). Primo posts a first message 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, and the previous
        thread gets a last message. Refused when Slack links are not open for
        the company (403 `SlackTicketLinksDisabledError`), no Slack workspace is
        connected (409 `SlackNotConnectedError`), the ticket was raised from
        Slack and keeps its thread (409 `SlackSourcedTicketLinkLockedError`),
        the channel is used to raise tickets (409
        `SlackIntakeChannelLinkRefusedError`), or Primo cannot post to that
        channel or person (422 `SlackLinkTargetUnavailableError`: unknown,
        archived, not joined by the Primo app, or no Slack member with that
        email). Answers the link with its `status`; `getTicket` returns it too.
        To remove it, use `unlinkTicketFromSlack`.
      operationId: linkTicketToSlack
      parameters:
        - name: ticketId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LinkTicketToSlackBody'
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TicketSlackLinkOutput_Output'
components:
  schemas:
    LinkTicketToSlackBody:
      type: object
      properties:
        target:
          description: >-
            A channel, by id or name, or a person, by Slack member id or email,
            whose direct messages with the Primo app hold the thread
          anyOf:
            - type: object
              properties:
                kind:
                  type: string
                  const: CHANNEL
                channelId:
                  description: Slack channel id, e.g. `C0123ABCD`
                  type: string
                  minLength: 1
              required:
                - kind
                - channelId
              additionalProperties: false
            - type: object
              properties:
                kind:
                  type: string
                  const: CHANNEL
                channelName:
                  description: Slack channel name, with or without `#`, e.g. `it-team`
                  type: string
                  minLength: 1
              required:
                - kind
                - channelName
              additionalProperties: false
            - type: object
              properties:
                kind:
                  type: string
                  const: DM
                slackUserId:
                  description: Slack member id of the person, e.g. `U0123ABCD`
                  type: string
                  minLength: 1
              required:
                - kind
                - slackUserId
              additionalProperties: false
            - type: object
              properties:
                kind:
                  type: string
                  const: DM
                email:
                  description: Email of the person in Slack
                  type: string
                  format: email
                  pattern: >-
                    ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
              required:
                - kind
                - email
              additionalProperties: false
      required:
        - target
    TicketSlackLinkOutput_Output:
      type: object
      properties:
        connected:
          type: boolean
          description: Whether the company has a Slack workspace connected to Primo
        link:
          description: Null when the ticket is not linked to Slack
          anyOf:
            - type: object
              properties:
                origin:
                  description: >-
                    `LINKED`: linked by hand. `TICKET_SOURCE`: the Slack thread
                    the ticket was raised in, which cannot change
                  type: string
                  enum:
                    - LINKED
                    - TICKET_SOURCE
                kind:
                  description: A Slack channel, or the direct messages of one person
                  type: string
                  enum:
                    - CHANNEL
                    - DM
                label:
                  description: The channel name (`#it-team`) or the person name
                  anyOf:
                    - type: string
                    - type: 'null'
                url:
                  description: Opens the channel or the direct messages in Slack
                  type: string
                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. `SLACK_DISCONNECTED`:
                    the Slack workspace was disconnected from Primo.
                    `CHANNEL_UNAVAILABLE`: the channel was archived or Primo
                    left it
                  type: string
                  enum:
                    - ACTIVE
                    - SLACK_DISCONNECTED
                    - CHANNEL_UNAVAILABLE
              required:
                - origin
                - kind
                - 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.