> ## 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.

# Get link analytics

> Show clicks and aggregated metrics for a short link.



## OpenAPI

````yaml /en/short-links-api/api-reference/openapi-short-links.json get /v1/short-links/{id}/analytics
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: Production
security:
  - ntfShortLinksBearerAuth: []
  - ntfShortLinksApiKeyHeader: []
tags:
  - name: Short links
    description: CRUD, listagem, analytics e eventos de clique em `/v1/short-links`.
paths:
  /v1/short-links/{id}/analytics:
    get:
      tags:
        - Short links
      summary: Get link analytics
      description: Show clicks and aggregated metrics for a short link.
      operationId: ntfShortLinks_getV1ShortLinksAnalytics
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: ID (cuid) do link.
        - name: granularity
          in: query
          schema:
            type: string
            enum:
              - hour
              - day
          description: >-
            Agregação temporal. Qualquer valor que não seja `day` é tratado como
            `hour`.
        - name: start
          in: query
          schema:
            type: string
            format: date-time
          description: Início do intervalo (inclusive), ISO 8601.
        - name: end
          in: query
          schema:
            type: string
            format: date-time
          description: Fim do intervalo (inclusive), ISO 8601.
      responses:
        '200':
          description: Analytics no intervalo solicitado.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_AnalyticsResponse'
              examples:
                byDay:
                  summary: Granularidade diária
                  value:
                    success: true
                    data:
                      granularity: day
                      range:
                        start: '2026-04-13T00:00:00.000Z'
                        end: '2026-04-20T23:59:59.999Z'
                      series:
                        - bucketStart: '2026-04-13T00:00:00.000Z'
                          clicksTotal: 5
                        - bucketStart: '2026-04-14T00:00:00.000Z'
                          clicksTotal: 12
                        - bucketStart: '2026-04-15T00:00:00.000Z'
                          clicksTotal: 8
                      breakdown:
                        country:
                          - key: BR
                            clicks: 20
                          - key: US
                            clicks: 3
                          - key: (unknown)
                            clicks: 2
                        deviceType:
                          - key: mobile
                            clicks: 18
                          - key: desktop
                            clicks: 7
        '400':
          description: '`start` ou `end` inválidos (data não parseável).'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
              examples:
                invalidRange:
                  value:
                    success: false
                    error: Bad Request
                    message: Invalid start or end
                    code: BAD_REQUEST
        '401':
          description: Missing or invalid API Key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
        '403':
          description: Escopo `short_links:read` 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_AnalyticsResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/NtfShortLinks_AnalyticsPayload'
    NtfShortLinks_ErrorResponse:
      type: object
      description: Erro genérico da API v1 (short links).
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: HTTP-style error label (e.g. Unauthorized, Bad Request, Not Found).
        message:
          type: string
          nullable: true
          description: >-
            Human-readable message for end users (localized via Accept-Language
            / x-locale when applicable).
        code:
          type: string
          nullable: true
          description: >-
            Stable API v1 code (enum). Always present on errors. Use with the
            HTTP status to decide retry or fix. See [Error
            responses](/en/guides/conceitos/resposta-de-erros).
      required:
        - success
        - error
        - message
        - code
    NtfShortLinks_AnalyticsPayload:
      type: object
      required:
        - granularity
        - range
        - series
        - breakdown
      properties:
        granularity:
          type: string
          enum:
            - hour
            - day
        range:
          type: object
          required:
            - start
            - end
          properties:
            start:
              type: string
              format: date-time
            end:
              type: string
              format: date-time
        series:
          type: array
          items:
            $ref: '#/components/schemas/NtfShortLinks_AnalyticsBucket'
        breakdown:
          type: object
          required:
            - country
            - deviceType
          properties:
            country:
              type: array
              items:
                $ref: '#/components/schemas/NtfShortLinks_BreakdownRow'
            deviceType:
              type: array
              items:
                $ref: '#/components/schemas/NtfShortLinks_BreakdownRow'
    NtfShortLinks_AnalyticsBucket:
      type: object
      required:
        - bucketStart
        - clicksTotal
      properties:
        bucketStart:
          type: string
          format: date-time
        clicksTotal:
          type: integer
          minimum: 0
    NtfShortLinks_BreakdownRow:
      type: object
      required:
        - key
        - clicks
      properties:
        key:
          type: string
          description: País (ISO ou `(unknown)`), ou tipo de dispositivo.
        clicks:
          type: integer
          minimum: 0
  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`'

````