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

# Create A Link

> Creates a new short link. `destination_url` is required. All other fields are optional.



## OpenAPI

````yaml POST /v1/links
openapi: 3.0.3
info:
  title: KlipLink API
  description: A RESTful API for managing short links and QR codes.
  version: 1.0.0
servers:
  - url: https://api.klipl.ink
security:
  - bearerAuth: []
paths:
  /v1/links:
    post:
      summary: Create a new short link
      description: >-
        Creates a new short link. `destination_url` is required. All other
        fields are optional.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - destination_url
              properties:
                destination_url:
                  type: string
                  description: The URL the short link should redirect to.
                  example: https://example.com/
                back_half:
                  type: string
                  description: >-
                    Custom slug for the short link. If omitted, one is generated
                    automatically.
                  example: your-link
                title:
                  type: string
                  description: A human-readable label for the link.
                  example: KlipLink API Guide
                domain:
                  type: string
                  description: >-
                    A custom domain to use for the short link. Must be added to
                    your account first.
                  example: links.your-website.com
      responses:
        '200':
          description: Link created successfully
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessResponse'
                  - $ref: '#/components/schemas/Link'
              example:
                success: true
                short_url: https://klipl.ink/your-link
                destination_url: https://example.com/
                created_at: '2025-11-06T14:30:00.000Z'
                clicks: 0
                title: KlipLink API Guide
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |
            curl -X POST "https://api.klipl.ink/v1/links" \
              -H "Authorization: Bearer YOUR_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "destination_url": "https://example.com/",
                "back_half": "your-link",
                "title": "KlipLink API Guide",
                "domain": "links.your-website.com"
              }'
        - lang: python
          label: Python
          source: |
            import requests

            response = requests.post(
                "https://api.klipl.ink/v1/links",
                headers={"Authorization": "Bearer YOUR_API_KEY"},
                json={
                    "destination_url": "https://example.com/",
                    "back_half": "your-link",          # optional
                    "title": "KlipLink API Guide",     # optional
                    "domain": "links.your-website.com" # optional
                }
            )
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: |
            const response = await fetch("https://api.klipl.ink/v1/links", {
              method: "POST",
              headers: {
                "Authorization": "Bearer YOUR_API_KEY",
                "Content-Type": "application/json"
              },
              body: JSON.stringify({
                destination_url: "https://example.com/",
                back_half: "your-link",          // optional
                title: "KlipLink API Guide",     // optional
                domain: "links.your-website.com" // optional
              })
            });
            const data = await response.json();
            console.log(data);
        - lang: php
          label: PHP
          source: |
            <?php
            $ch = curl_init("https://api.klipl.ink/v1/links");
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, [
                "Authorization: Bearer YOUR_API_KEY",
                "Content-Type: application/json"
            ]);
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
                "destination_url" => "https://example.com/",
                "back_half" => "your-link",           // optional
                "title" => "KlipLink API Guide",      // optional
                "domain" => "links.your-website.com"  // optional
            ]));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = json_decode(curl_exec($ch), true);
            print_r($response);
components:
  schemas:
    SuccessResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
    Link:
      type: object
      properties:
        short_url:
          type: string
          example: https://klipl.ink/your-link
        destination_url:
          type: string
          example: https://example.com/
        clicks:
          type: integer
          example: 255
        created_at:
          type: string
          format: date-time
          example: '2025-11-06T14:30:00.000Z'
        title:
          type: string
          example: Example Link
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````