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

# Create a short link

> Creates a shortened link with optional parameters for expiration, alias, and password protection.



## OpenAPI

````yaml POST /links
openapi: 3.0.1
info:
  title: iShortn API
  description: >-
    This is the API documentation for the iShortn API. This API is used to
    shorten URLs.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://ishortn.ink/api/v1
    description: Production server
security: []
paths:
  /links:
    post:
      summary: Create a shortened link
      description: >-
        Creates a shortened link with optional parameters for expiration, alias,
        and password protection.
      operationId: createShortenedLink
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  format: url
                  description: The URL to shorten.
                expiresAt:
                  type: string
                  format: date-time
                  nullable: true
                  description: The date and time when the link expires.
                expiresAfter:
                  type: integer
                  nullable: true
                  description: The number of clicks after which the link expires.
                domain:
                  type: string
                  description: If you have a custom domain, you can specify it here.
                alias:
                  type: string
                  description: Custom alias for the shortened link.
                password:
                  type: string
                  description: Password to protect the link. (Only for pro users)
              required:
                - url
            example:
              url: https://example.com
              expiresAt: '2024-12-31T23:59:59Z'
              expiresAfter: 1000
              domain: example.com
              alias: customAlias
              password: securePassword
      responses:
        '201':
          description: Link created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkDetails'
              example:
                shortLink: https://ishortn.ink/customAlias
                url: https://example.com
                alias: customAlias
                expiresAt: '2024-12-31T23:59:59Z'
                expiresAfter: 1000
                isProtected: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - apiKeyAuth: []
components:
  schemas:
    LinkDetails:
      type: object
      properties:
        shortLink:
          type: string
          description: The shortened link.
        url:
          type: string
          description: The original URL.
        alias:
          type: string
          description: The alias of the shortened link.
        expiresAt:
          type: string
          format: date-time
          nullable: true
          description: The expiration date and time of the link.
        expiresAfter:
          type: integer
          nullable: true
          description: The number of clicks after which the link expires.
        isProtected:
          type: boolean
          description: >-
            Indicates if the link is password protected (relevant for creation
            response).
  responses:
    BadRequest:
      description: Bad Request (e.g., invalid input, missing parameter, alias collision)
      content:
        application/json:
          schema:
            type: string
    Unauthorized:
      description: Unauthorized (e.g., invalid or missing API key)
      content:
        application/json:
          schema:
            type: string
          example: Invalid or missing API key
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````