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

# Create short link

> Create a short link that redirects to a URL.



## OpenAPI

````yaml /en/short-links-api/api-reference/openapi-short-links.json post /v1/short-links
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:
    post:
      tags:
        - Short links
      summary: Create short link
      description: Create a short link that redirects to a URL.
      operationId: ntfShortLinks_postV1ShortLinks
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NtfShortLinks_CreateRequest'
            examples:
              minimal:
                summary: Somente URL de destino
                value:
                  targetUrl: https://minha-loja.com/checkout
              withCustomSlug:
                summary: Slug personalizado
                value:
                  targetUrl: https://blog.exemplo.com/post/anuncio-2026
                  customCode: post-2026
      responses:
        '200':
          description: Link criado ou recuperado com sucesso.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_CreateResponse'
              examples:
                created:
                  value:
                    success: true
                    data:
                      id: clshort01exampleid0003
                      code: post-2026
                      domain: clicar.co
                      targetUrl: https://blog.exemplo.com/post/anuncio-2026
                      shortUrl: https://clicar.co/post-2026
                      source: API
                      createdAt: '2026-04-20T16:00:00.000Z'
        '400':
          description: >-
            Corpo inválido (validação), slug inválido/reservado, slug em uso,
            URL rejeitada pela política de destino, ou erro genérico de criação.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
                  - $ref: '#/components/schemas/NtfShortLinks_ValidationErrorResponse'
              examples:
                validationElysia:
                  summary: 'Validação de schema (ex.: targetUrl curta demais)'
                  value:
                    success: false
                    error: Invalid data
                    message: Does not meet validation rules (e.g. length or format).
                    fields:
                      - path: targetUrl
                        message: String must contain at least 4 character(s)
                    code: UNKNOWN_ERROR
                invalidSlug:
                  summary: Slug customizado inválido
                  value:
                    success: false
                    error: Bad Request
                    message: >-
                      Invalid slug: use 4–32 characters (letters, numbers, _ or
                      -).
                    code: BAD_REQUEST
                reservedSlug:
                  summary: Slug reservado
                  value:
                    success: false
                    error: Bad Request
                    message: This slug is reserved. Choose another one.
                    code: BAD_REQUEST
                slugOrDup:
                  summary: Slug em uso ou URL já registrada no workspace
                  value:
                    success: false
                    error: Bad Request
                    message: >-
                      Slug already in use or URL already registered for this
                      workspace.
                    code: BAD_REQUEST
                targetBlockedHost:
                  summary: URL rejeitada, host bloqueado
                  value:
                    success: false
                    error: Bad Request
                    message: 'Target URL rejected: BLOCKED_HOST'
                    code: SHORT_LINK_TARGET_BLOCKED_HOST
                targetInvalidUrl:
                  summary: URL rejeitada, inválida
                  value:
                    success: false
                    error: Bad Request
                    message: 'Target URL rejected: INVALID_URL'
                    code: SHORT_LINK_TARGET_INVALID_URL
                targetRedirect:
                  summary: URL rejeitada, redirect não permitido na validação
                  value:
                    success: false
                    error: Bad Request
                    message: 'Target URL rejected: REDIRECT'
                    code: SHORT_LINK_TARGET_REDIRECT
                targetNotOkHttp:
                  summary: URL rejeitada. HTTP não OK
                  value:
                    success: false
                    error: Bad Request
                    message: 'Target URL rejected: NOT_OK_HTTP'
                    code: SHORT_LINK_TARGET_NOT_OK_HTTP
                targetImageContent:
                  summary: URL rejeitada, conteúdo de imagem
                  value:
                    success: false
                    error: Bad Request
                    message: 'Target URL rejected: IMAGE_CONTENT'
                    code: SHORT_LINK_TARGET_IMAGE_CONTENT
                targetTimeout:
                  summary: URL rejeitada, timeout
                  value:
                    success: false
                    error: Bad Request
                    message: 'Target URL rejected: TIMEOUT'
                    code: SHORT_LINK_TARGET_TIMEOUT
                targetNetwork:
                  summary: URL rejeitada, erro de rede
                  value:
                    success: false
                    error: Bad Request
                    message: 'Target URL rejected: NETWORK'
                    code: SHORT_LINK_TARGET_NETWORK
        '401':
          description: Missing or invalid API Key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
              examples:
                unauthorized:
                  value:
                    success: false
                    error: Unauthorized
                    message: Invalid or missing API Key
                    code: UNAUTHORIZED
        '402':
          description: Workspace bloqueado.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
              examples:
                paymentRequired:
                  value:
                    success: false
                    error: Payment Required
                    message: Plan expired or suspended
                    code: WORKSPACE_BLOCKED
        '403':
          description: >-
            Escopo `short_links:manage` ausente **ou** recurso desabilitado no
            workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfShortLinks_ErrorResponse'
              examples:
                missingScope:
                  value:
                    success: false
                    error: Forbidden
                    message: 'Missing scope: short_links:manage'
                    code: FORBIDDEN
                featureDisabled:
                  value:
                    success: false
                    error: Forbidden
                    message: >-
                      Short links are disabled for this workspace. Enable them
                      in Settings.
                    code: SHORT_LINKS_DISABLED
components:
  schemas:
    NtfShortLinks_CreateRequest:
      type: object
      required:
        - targetUrl
      properties:
        targetUrl:
          type: string
          minLength: 4
          maxLength: 4096
          description: URL de destino (tipicamente `http` ou `https`).
        customCode:
          type: string
          nullable: true
          minLength: 1
          maxLength: 64
          description: >-
            Slug opcional; regras de formato, lista de reservados e unicidade no
            domínio.
    NtfShortLinks_CreateResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          required:
            - id
            - code
            - domain
            - targetUrl
            - shortUrl
            - source
            - createdAt
          properties:
            id:
              type: string
              description: cuid do link.
            code:
              type: string
              description: Path do link curto (slug).
            domain:
              type: string
              example: clicar.co
            targetUrl:
              type: string
              format: uri
            shortUrl:
              type: string
              format: uri
              description: URL pública completa.
            source:
              type: string
              enum:
                - AUTO
                - MANUAL
                - API
              description: Para POST manual, em geral `API`.
            createdAt:
              type: string
              format: date-time
    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_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: HTTP-style error label (e.g. Unauthorized, Bad Request, Not Found).
        message:
          type: string
          description: >-
            Human-readable message for end users (localized via Accept-Language
            / x-locale when applicable).
        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: >-
            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).
  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`'

````