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

# Atualizar link curto

> Altera destino ou configurações de um link curto.



## OpenAPI

````yaml /short-links-api/api-reference/openapi-short-links.json patch /v1/short-links/{id}
openapi: 3.0.3
info:
  title: Notifique API. Links curtos (Short Links)
  description: >-
    API para **criar**, **listar**, **atualizar** e **remover** links curtos do
    workspace (domínio padrão **clicar.co** ou o configurado), além de
    **analytics** (série temporal e quebras) e **lista de cliques** individuais.


    **Autenticação:** API Key em `Authorization: Bearer sk_live_xxxxx` ou
    `x-api-key: sk_live_xxxxx`. O **workspace** é sempre o da chave (cada API
    Key pertence a um workspace); **não** envie `x-workspace-id` na API v1,
    requisições com esse cabeçalho preenchido recebem **400**
    (`WORKSPACE_HEADER_NOT_ALLOWED`).


    **Escopos:** `short_links:read` (GET) e `short_links:manage` (POST, PATCH,
    DELETE).
  version: 1.0.0
servers:
  - url: https://api.notifique.dev
    description: Produção
security:
  - ntfShortLinksBearerAuth: []
  - ntfShortLinksApiKeyHeader: []
tags:
  - name: Short links
    description: CRUD, listagem, analytics e eventos de clique em `/v1/short-links`.
paths:
  /v1/short-links/{id}:
    patch:
      tags:
        - Short links
      summary: Atualizar link curto
      description: Altera destino ou configurações de um link curto.
      operationId: ntfShortLinks_patchV1ShortLinksById
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: ID (cuid) do link.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NtfShortLinks_PatchRequest'
            examples:
              deactivate:
                summary: Desativar redirect
                value:
                  isActive: false
              newTargetAndExpiry:
                summary: Novo destino e data de expiração
                value:
                  targetUrl: https://loja.exemplo.com/nova-landing
                  expiresAt: '2026-06-01T00:00:00.000Z'
              clearExpiry:
                summary: Remover expiração
                value:
                  expiresAt: null
      responses:
        '200':
          description: Link atualizado.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_DetailResponse'
              examples:
                patched:
                  value:
                    success: true
                    data:
                      id: clshort01exampleid0001
                      workspaceId: clws_example_workspace01
                      domain: clicar.co
                      code: promo24
                      targetUrl: https://loja.exemplo.com/nova-landing
                      targetUrlHash: >-
                        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                      outboundAttribution: ''
                      source: API
                      createdByUserId: null
                      expiresAt: '2026-06-01T00:00:00.000Z'
                      deletedAt: null
                      isActive: false
                      clickCount: 128
                      createdAt: '2026-04-18T14:22:00.000Z'
                      updatedAt: '2026-04-20T18:30:00.000Z'
                      shortUrl: https://clicar.co/promo24
        '400':
          description: Validação de corpo ou `targetUrl` inválida na normalização.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
                  - $ref: '#/components/schemas/NtfShortLinks_ValidationErrorResponse'
              examples:
                badTargetUrl:
                  value:
                    success: false
                    error: Bad Request
                    message: 'Invalid URL: ...'
                    code: BAD_REQUEST
        '401':
          description: API Key ausente ou inválida.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
        '403':
          description: Escopo `short_links:manage` ausente.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
        '404':
          description: Link inexistente ou removido.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
              examples:
                notFound:
                  value:
                    success: false
                    error: Not Found
                    message: Not Found
                    code: NOT_FOUND
components:
  schemas:
    NtfShortLinks_PatchRequest:
      type: object
      minProperties: 1
      properties:
        isActive:
          type: boolean
        targetUrl:
          type: string
          minLength: 4
          maxLength: 4096
        expiresAt:
          type: string
          nullable: true
          description: ISO 8601, `null` ou string vazia para limpar expiração.
    NtfShortLinks_DetailResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/NtfShortLinks_ShortLinkFull'
    NtfShortLinks_ErrorResponse:
      type: object
      description: Erro genérico da API v1 (short links).
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: 'Rótulo HTTP do erro (ex.: Unauthorized, Bad Request, Not Found).'
        message:
          type: string
          nullable: true
          description: >-
            Mensagem legível para exibir ao usuário (localizada via
            Accept-Language / x-locale quando aplicável).
        code:
          type: string
          nullable: true
          description: >-
            Código estável da API v1 (enum). Sempre presente em erros. Use com o
            status HTTP para decidir retry ou correção. Ver [Respostas de
            erro](/guides/conceitos/resposta-de-erros).
      required:
        - success
        - error
        - message
        - code
    NtfShortLinks_ValidationErrorResponse:
      type: object
      description: >-
        Resposta de validação global (Elysia) para corpo/query inválidos; HTTP
        **400**.
      required:
        - success
        - error
        - message
        - code
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          example: Invalid data
          description: 'Rótulo HTTP do erro (ex.: Unauthorized, Bad Request, Not Found).'
        message:
          type: string
          description: >-
            Mensagem legível para exibir ao usuário (localizada via
            Accept-Language / x-locale quando aplicável).
        fields:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
          description: Erros por campo (formato pode variar conforme versão do validador).
        details:
          type: object
          description: Presente apenas em ambiente de desenvolvimento, quando aplicável.
        code:
          type: string
          description: >-
            Código estável da API v1 (enum). Sempre presente em erros. Use com o
            status HTTP para decidir retry ou correção. Ver [Respostas de
            erro](/guides/conceitos/resposta-de-erros).
    NtfShortLinks_ShortLinkFull:
      type: object
      description: Modelo persistido + `shortUrl`; datas em ISO 8601.
      properties:
        id:
          type: string
        workspaceId:
          type: string
        domain:
          type: string
        code:
          type: string
        targetUrl:
          type: string
        targetUrlHash:
          type: string
          description: SHA-256 hex da URL normalizada.
        outboundAttribution:
          type: string
          description: >-
            Vazio = compartilhado; formato `CANAL:id` liga clique ao envio (SMS,
            WHATSAPP, …).
        source:
          type: string
          enum:
            - AUTO
            - MANUAL
            - API
        createdByUserId:
          type: string
          nullable: true
        expiresAt:
          type: string
          nullable: true
          format: date-time
        deletedAt:
          type: string
          nullable: true
          format: date-time
        isActive:
          type: boolean
        clickCount:
          type: integer
          minimum: 0
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        shortUrl:
          type: string
          format: uri
  securitySchemes:
    ntfShortLinksBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        API Key no header Authorization. Exemplo: `Authorization: Bearer
        sk_live_xxxxx`
    ntfShortLinksApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: 'API Key no header x-api-key. Exemplo: `x-api-key: sk_live_xxxxx`'

````