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

# Create a link

> Creates a short link. If `slug` is omitted, TrimYourl suggests one from the destination page. If `domainId` is omitted, the workspace default domain is used. UTM append defaults to on.



## OpenAPI

````yaml /openapi.json post /api/v1/links
openapi: 3.1.0
info:
  title: TrimYourl API
  version: 1.0.0
  description: >-
    Create branded short links, update them, download QR codes, read analytics,
    and credit conversions. Authenticate with a workspace API key from Settings
    → API.
servers:
  - url: https://trimyourl.com
    description: Production
security: []
tags:
  - name: Links
    description: >-
      Create, list, update, and delete short links in the workspace that owns
      the API key.
  - name: Analytics
    description: >-
      Human clicks, bots, devices, geo, and referrers for a workspace or a
      single link.
  - name: Domains
    description: Active short-link hostnames in the workspace.
  - name: QR codes
    description: Download a PNG for an existing link using the workspace QR kit.
  - name: Conversions
    description: >-
      Credit a purchase or sign-up to the short-link click that brought the
      visitor.
paths:
  /api/v1/links:
    post:
      tags:
        - Links
      summary: Create a link
      description: >-
        Creates a short link. If `slug` is omitted, TrimYourl suggests one from
        the destination page. If `domainId` is omitted, the workspace default
        domain is used. UTM append defaults to on.
      operationId: createLink
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewLink'
            example:
              destination: https://northwind.com/spring
              slug: spring-launch
              title: Spring launch
              tags:
                - launch
                - instagram
      responses:
        '200':
          description: The new link.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Link'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - bearerAuth: []
components:
  schemas:
    NewLink:
      type: object
      required:
        - destination
      properties:
        destination:
          type: string
          format: uri
          description: The long URL to shorten.
        slug:
          type: string
          description: Custom short name. Leave empty to generate one from the page.
        title:
          type: string
          description: Display title. Defaults from the destination page when omitted.
        domainId:
          type: string
          format: uuid
          description: Domain in this workspace. Defaults to the workspace default.
        folderId:
          type: string
          format: uuid
        campaignId:
          type: string
          format: uuid
        tags:
          oneOf:
            - type: array
              items:
                type: string
            - type: string
        note:
          type: string
        utmSource:
          type: string
        utmMedium:
          type: string
        utmCampaign:
          type: string
        utmTerm:
          type: string
        utmContent:
          type: string
        appendUtm:
          type: boolean
          default: true
        expiresAt:
          type: string
          format: date-time
        iosUrl:
          type: string
          format: uri
        androidUrl:
          type: string
          format: uri
        fallbackUrl:
          type: string
          format: uri
        password:
          type: string
        redirectCode:
          type: integer
          enum:
            - 301
            - 302
            - 307
          default: 302
        rotations:
          type: array
          maxItems: 3
          items:
            type: object
            properties:
              destination:
                type: string
                format: uri
              weight:
                type: integer
                minimum: 1
    Link:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
          nullable: true
        slug:
          type: string
        shortUrl:
          type: string
          format: uri
        destination:
          type: string
          format: uri
        domain:
          type: string
        folderId:
          type: string
          format: uuid
          nullable: true
        campaignId:
          type: string
          format: uuid
          nullable: true
        tags:
          type: array
          items:
            type: string
        note:
          type: string
          nullable: true
        humanClicks:
          type: integer
        clicks:
          type: integer
        health:
          type: string
        expiresAt:
          type: string
          format: date-time
          nullable: true
        passwordProtected:
          type: boolean
        iosUrl:
          type: string
          nullable: true
        androidUrl:
          type: string
          nullable: true
        fallbackUrl:
          type: string
          nullable: true
        redirectCode:
          type: integer
        utm:
          $ref: '#/components/schemas/Utm'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      example:
        id: 8f3c1a2b-4d5e-6789-abcd-ef0123456789
        title: Spring launch
        slug: spring-launch
        shortUrl: https://go.northwind.com/spring-launch
        destination: https://northwind.com/spring
        domain: go.northwind.com
        folderId: null
        campaignId: null
        tags:
          - launch
          - instagram
        note: null
        humanClicks: 42
        clicks: 50
        health: ok
        expiresAt: null
        passwordProtected: false
        iosUrl: null
        androidUrl: null
        fallbackUrl: null
        redirectCode: 302
        utm:
          source: instagram
          medium: social
          campaign: spring
          term: null
          content: null
          append: true
    Utm:
      type: object
      properties:
        source:
          type: string
          nullable: true
        medium:
          type: string
          nullable: true
        campaign:
          type: string
          nullable: true
        term:
          type: string
          nullable: true
        content:
          type: string
          nullable: true
        append:
          type: boolean
    Error:
      type: object
      properties:
        error:
          type: string
  responses:
    BadRequest:
      description: Invalid body, no domain ready, or the destination was rejected.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Workspace API key from Settings → API. Starts with `tyl_`.

````

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